Skip to content

Commit

Permalink
add util func for keyspace.workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Dec 27, 2024
1 parent ef46b1b commit 4617172
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions go/test/endtoend/vreplication/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ func assertQueryDoesNotExecutesOnTablet(t *testing.T, conn *mysql.Conn, tablet *
}

func waitForWorkflowToBeCreated(t *testing.T, vc *VitessCluster, ksWorkflow string) {
keyspace, workflow, ok := strings.Cut(ksWorkflow, ".")
require.True(t, ok, "invalid <keyspace>.<workflow> value: %s", ksWorkflow)
keyspace, workflow := parseKeyspaceWorkflow(t, ksWorkflow)
require.NoError(t, waitForCondition("workflow to be created", func() bool {
output, err := vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", keyspace, "show", "--workflow", workflow, "--compact", "--include-logs=false")
return err == nil && output != emptyWorkflowShowResponse
Expand All @@ -359,8 +358,7 @@ func waitForWorkflowToBeCreated(t *testing.T, vc *VitessCluster, ksWorkflow stri
// additional stream sub-state such as "message==for vdiff".
// Invalid checks are ignored.
func waitForWorkflowState(t *testing.T, vc *VitessCluster, ksWorkflow string, wantState string, fieldEqualityChecks ...string) {
keyspace, workflow, ok := strings.Cut(ksWorkflow, ".")
require.True(t, ok, "invalid <keyspace>.<workflow> value: %s", ksWorkflow)
keyspace, workflow := parseKeyspaceWorkflow(t, ksWorkflow)
done := false
timer := time.NewTimer(workflowStateTimeout)
log.Infof("Waiting for workflow %q to fully reach %q state", ksWorkflow, wantState)
Expand Down Expand Up @@ -1053,3 +1051,10 @@ func validateOverrides(t *testing.T, tabs map[string]*cluster.VttabletProcess, w
}
}
}

func parseKeyspaceWorkflow(t *testing.T, ksWorkflow string) (string, string) {
t.Helper()
keyspace, workflow, ok := strings.Cut(ksWorkflow, ".")
require.True(t, ok, "invalid <keyspace>.<workflow> value: %s", ksWorkflow)
return keyspace, workflow
}

0 comments on commit 4617172

Please sign in to comment.