Skip to content

Commit

Permalink
Add helper func for empty show output
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Dec 28, 2024
1 parent d8dd893 commit 52f708c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
14 changes: 13 additions & 1 deletion go/test/endtoend/vreplication/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func waitForWorkflowToBeCreated(t *testing.T, vc *VitessCluster, ksWorkflow stri
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
return err == nil && isEmptyWorkflowShowOutput(output)
}, defaultTimeout))
}

Expand Down Expand Up @@ -1058,3 +1058,15 @@ func parseKeyspaceWorkflow(t *testing.T, ksWorkflow string) (string, string) {
require.True(t, ok, "invalid <keyspace>.<workflow> value: %s", ksWorkflow)
return keyspace, workflow
}

func isEmptyWorkflowShowOutput(output string) bool {
const (
emptyJSON = `{}`
emptyNonCompactWorkflowShowResponse = `{
"workflows": []
}
`
)

return output == emptyJSON || output == emptyNonCompactWorkflowShowResponse
}
9 changes: 2 additions & 7 deletions go/test/endtoend/vreplication/partial_movetables_seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ import (
As part of a separate cleanup we will build on this framework to replace the existing one.
*/

const emptyWorkflowShowResponse = `{
"workflows": []
}
`

type keyspace struct {
name string
vschema string
Expand Down Expand Up @@ -505,13 +500,13 @@ func TestPartialMoveTablesWithSequences(t *testing.T) {

output, err := tc.vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", reverseKs, "show", "--workflow", reverseWf)
require.NoError(t, err)
require.Equal(t, emptyWorkflowShowResponse, output)
require.True(t, isEmptyWorkflowShowOutput(output))

// Be sure that we've deleted the original workflow.
_, _ = tc.vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", targetKs, "delete", "--workflow", wf)
output, err = tc.vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", targetKs, "show", "--workflow", wf)
require.NoError(t, err)
require.Equal(t, emptyWorkflowShowResponse, output)
require.True(t, isEmptyWorkflowShowOutput(output))
}

// Confirm that the global routing rules are now gone.
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/vreplication/partial_movetables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ func testPartialMoveTablesBasic(t *testing.T, flavor workflowFlavor) {

output, err := vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", reverseKs, "show", "--workflow", reverseWf, "--shards", opts.shardSubset)
require.NoError(t, err)
require.Equal(t, emptyWorkflowShowResponse, output)
require.True(t, isEmptyWorkflowShowOutput(output))

// Be sure we've deleted the original workflow.
_, _ = vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", targetKs, "delete", "--workflow", wf, "--shards", opts.shardSubset)
output, err = vc.VtctldClient.ExecuteCommandWithOutput("Workflow", "--keyspace", targetKs, "show", "--workflow", wf, "--shards", opts.shardSubset)
require.NoError(t, err, output)
require.Equal(t, emptyWorkflowShowResponse, output)
require.True(t, isEmptyWorkflowShowOutput(output))
}

// Confirm that the global routing rules are now gone.
Expand Down

0 comments on commit 52f708c

Please sign in to comment.