From 52f708ca1757d2afcfac25085f5f110f199873db Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sat, 28 Dec 2024 08:15:10 -0500 Subject: [PATCH] Add helper func for empty show output Signed-off-by: Matt Lord --- go/test/endtoend/vreplication/helper_test.go | 14 +++++++++++++- .../vreplication/partial_movetables_seq_test.go | 9 ++------- .../vreplication/partial_movetables_test.go | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/go/test/endtoend/vreplication/helper_test.go b/go/test/endtoend/vreplication/helper_test.go index 971d78e401b..2ef32b9f33a 100644 --- a/go/test/endtoend/vreplication/helper_test.go +++ b/go/test/endtoend/vreplication/helper_test.go @@ -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)) } @@ -1058,3 +1058,15 @@ func parseKeyspaceWorkflow(t *testing.T, ksWorkflow string) (string, string) { require.True(t, ok, "invalid . value: %s", ksWorkflow) return keyspace, workflow } + +func isEmptyWorkflowShowOutput(output string) bool { + const ( + emptyJSON = `{}` + emptyNonCompactWorkflowShowResponse = `{ + "workflows": [] +} +` + ) + + return output == emptyJSON || output == emptyNonCompactWorkflowShowResponse +} diff --git a/go/test/endtoend/vreplication/partial_movetables_seq_test.go b/go/test/endtoend/vreplication/partial_movetables_seq_test.go index 4fc5600661f..959a0169950 100644 --- a/go/test/endtoend/vreplication/partial_movetables_seq_test.go +++ b/go/test/endtoend/vreplication/partial_movetables_seq_test.go @@ -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 @@ -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. diff --git a/go/test/endtoend/vreplication/partial_movetables_test.go b/go/test/endtoend/vreplication/partial_movetables_test.go index 22131dbf437..09e80b19bd4 100644 --- a/go/test/endtoend/vreplication/partial_movetables_test.go +++ b/go/test/endtoend/vreplication/partial_movetables_test.go @@ -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.