Skip to content

Commit a3bb48e

Browse files
authored
fix(e2e): Address flakes in TestCliSearch (#6080)
* fix(e2e): Address flake in session count There was a failure where this returned 1 session when the test expected 0. This commit updates the search to only look at sessions within the created project in this test. * fix(e2e): Address flake in cache status This commit addresses a flake where the test attempted to stop and start a cache, but when it goes to start the cache, it claims that the cache is already running. A theory is that the test tries start the cache too quickly after stopping it. Now, we add in a status call to check the status of the cache before proceeding.
1 parent 3a7f5d0 commit a3bb48e

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

testing/internal/e2e/tests/base/search_test.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ func TestCliSearch(t *testing.T) {
287287
e2e.WithArgs(
288288
"search",
289289
"-resource", "sessions",
290+
"-query", fmt.Sprintf(`scope_id = "%s"`, projectId),
290291
"-force-refresh", "true",
291292
"-format", "json",
292293
),
@@ -370,9 +371,26 @@ func TestCliSearch(t *testing.T) {
370371
)
371372

372373
// Restart cache and confirm search works
373-
t.Log("Restarting cache...")
374+
t.Log("Stopping cache...")
374375
output = e2e.RunCommand(ctx, "boundary", e2e.WithArgs("cache", "stop"))
375376
require.NoError(t, output.Err, string(output.Stderr))
377+
err = backoff.RetryNotify(
378+
func() error {
379+
output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("cache", "status", "-format", "json"))
380+
381+
if strings.Contains(string(output.Stderr), "The cache process is not running") {
382+
return nil
383+
}
384+
385+
return fmt.Errorf("Waiting for cache to stop: %s", string(output.Stdout))
386+
},
387+
backoff.WithMaxRetries(backoff.NewConstantBackOff(1*time.Second), 5),
388+
func(err error, td time.Duration) {
389+
t.Logf("%s. Retrying...", err.Error())
390+
},
391+
)
392+
require.NoError(t, err)
393+
t.Log("Starting cache...")
376394
output = e2e.RunCommand(ctx, "boundary",
377395
e2e.WithArgs(
378396
"cache", "start",
@@ -419,9 +437,26 @@ func TestCliSearch(t *testing.T) {
419437

420438
// Log out and restart cache. Log in and confirm search works
421439
output = e2e.RunCommand(ctx, "boundary", e2e.WithArgs("logout"))
422-
t.Log("Restarting cache...")
440+
t.Log("Stopping cache...")
423441
output = e2e.RunCommand(ctx, "boundary", e2e.WithArgs("cache", "stop"))
424442
require.NoError(t, output.Err, string(output.Stderr))
443+
err = backoff.RetryNotify(
444+
func() error {
445+
output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("cache", "status", "-format", "json"))
446+
447+
if strings.Contains(string(output.Stderr), "The cache process is not running") {
448+
return nil
449+
}
450+
451+
return fmt.Errorf("Waiting for cache to stop: %s", string(output.Stdout))
452+
},
453+
backoff.WithMaxRetries(backoff.NewConstantBackOff(1*time.Second), 5),
454+
func(err error, td time.Duration) {
455+
t.Logf("%s. Retrying...", err.Error())
456+
},
457+
)
458+
require.NoError(t, err)
459+
t.Log("Starting cache...")
425460
output = e2e.RunCommand(ctx, "boundary",
426461
e2e.WithArgs(
427462
"cache", "start",

0 commit comments

Comments
 (0)