Skip to content

Commit

Permalink
improve error messages causing test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Jan 6, 2024
1 parent d88f76d commit 8eae927
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
4 changes: 2 additions & 2 deletions flow/e2e/bigquery/peer_flow_bq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1592,8 +1592,8 @@ func (s PeerFlowE2ETestSuiteBQ) Test_Soft_Delete_UD_Same_Batch() {

env.ExecuteWorkflow(peerflow.CDCFlowWorkflowWithConfig, config, &limits, nil)

newerSyncedAtQuery := fmt.Sprintf(`
SELECT COUNT(*) FROM`+"`%s.%s`"+`WHERE _PEERDB_IS_DELETED`,
newerSyncedAtQuery := fmt.Sprintf(
"SELECT COUNT(*) FROM `%s.%s` WHERE _PEERDB_IS_DELETED",
s.bqHelper.datasetName, dstName)
numNewRows, err := s.bqHelper.RunInt64Query(newerSyncedAtQuery)
require.NoError(s.t, err)
Expand Down
26 changes: 5 additions & 21 deletions flow/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,7 @@ func EnvNoError(t *testing.T, env *testsuite.TestWorkflowEnvironment, err error)
t.Helper()

if err != nil {
t.Error(err.Error())
env.CancelWorkflow()
runtime.Goexit()
}
}

// See EnvNoError
func EnvEqual[T comparable](t *testing.T, env *testsuite.TestWorkflowEnvironment, x T, y T) {
t.Helper()

if x != y {
t.Error("not equal", x, y)
t.Error("UNEXPECTED ERROR", err.Error())
env.CancelWorkflow()
runtime.Goexit()
}
Expand All @@ -91,7 +80,7 @@ func EnvTrue(t *testing.T, env *testsuite.TestWorkflowEnvironment, val bool) {
t.Helper()

if !val {
t.Error("assertion failed")
t.Error("UNEXPECTED FALSE")
env.CancelWorkflow()
runtime.Goexit()
}
Expand Down Expand Up @@ -539,14 +528,9 @@ func RequireEqualRecordBatches(t *testing.T, q *model.QRecordBatch, other *model
require.True(t, e2eshared.CheckEqualRecordBatches(t, q, other))
}

// See EnvNoError
func EnvEqualRecordBatches(t *testing.T, env *testsuite.TestWorkflowEnvironment, q *model.QRecordBatch, other *model.QRecordBatch) {
t.Helper()

if !e2eshared.CheckEqualRecordBatches(t, q, other) {
env.CancelWorkflow()
runtime.Goexit()
}
EnvTrue(t, env, e2eshared.CheckEqualRecordBatches(t, q, other))
}

func EnvWaitFor(t *testing.T, env *testsuite.TestWorkflowEnvironment, timeout time.Duration, reason string, f func(ctx context.Context) bool) {
Expand All @@ -555,10 +539,10 @@ func EnvWaitFor(t *testing.T, env *testsuite.TestWorkflowEnvironment, timeout ti
ctx, cleanup := context.WithTimeout(context.Background(), timeout)
defer cleanup()
deadline, _ := ctx.Deadline()
t.Log("WaitFor", reason)
for !f(ctx) {
t.Log(time.Now(), deadline)
if time.Now().Compare(deadline) >= 0 {
t.Error("WaitFor timed out", reason)
t.Error("UNEXPECTED TIMEOUT", reason)
env.CancelWorkflow()
runtime.Goexit()
}
Expand Down

0 comments on commit 8eae927

Please sign in to comment.