From 0d7ab5863f0f8514001ae45bcb2308d6442ce0d5 Mon Sep 17 00:00:00 2001 From: ATMackay Date: Mon, 20 Oct 2025 22:02:06 +1100 Subject: [PATCH] fix(integration): Fix test logs --- integration/add_inventory_test.go | 2 +- integration/concurrent_write_test.go | 11 +++++++---- integration/utils.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/integration/add_inventory_test.go b/integration/add_inventory_test.go index 6bac1e7..1ebae8c 100644 --- a/integration/add_inventory_test.go +++ b/integration/add_inventory_test.go @@ -23,7 +23,7 @@ func Test_AddInventoryItems(t *testing.T) { ctx, cancelFn := context.WithTimeout(context.Background(), 600*time.Second) // Set hard limit of 10 minutes defer cancelFn() - stack := makeStack(t, ctx, &stackOpts{dbLogs: true, appLogs: true}) // Modify logging options as required + stack := makeStack(t, ctx, &stackOpts{dbLogs: false, appLogs: true, debug: false}) // Modify logging options as required // 4) Create Client baseURL := stack.app.url() diff --git a/integration/concurrent_write_test.go b/integration/concurrent_write_test.go index 482a1c5..c32252d 100644 --- a/integration/concurrent_write_test.go +++ b/integration/concurrent_write_test.go @@ -5,6 +5,7 @@ package integration import ( "context" "fmt" + "math/rand/v2" "sync" "sync/atomic" "testing" @@ -20,10 +21,10 @@ func Test_ConcurrentWrite(t *testing.T) { ctx := context.Background() // Raise stack - stack := makeStack(t, ctx, &stackOpts{dbLogs: false, appLogs: true}) + stack := makeStack(t, ctx, &stackOpts{dbLogs: false, appLogs: true, debug: false}) baseURL := stack.app.url() // Make client pool - poolSize := 10 + poolSize := max(1, rand.IntN(10)) clients := make(chan *client.Client, poolSize) for range poolSize { cl := makeClient(t, baseURL, stack.app.authPsswd) @@ -33,7 +34,7 @@ func Test_ConcurrentWrite(t *testing.T) { var mu sync.Mutex errG, gCtx := errgroup.WithContext(ctx) - errG.SetLimit(poolSize) + // errG.SetLimit(poolSize) // Execute write test @@ -62,8 +63,10 @@ func Test_ConcurrentWrite(t *testing.T) { t.Fatal(err) } + dur := duration.Load() + // Log stats - t.Logf("Wrote %d items, avg write time %.2fms", itemCount, float64(duration.Load())/float64(itemCount)/1e6) + t.Logf("Wrote %d items in %vs, avg write time %.2fms", itemCount, float64(dur)/1e9, float64(dur)/float64(itemCount)/1e6) // Check items have been added diff --git a/integration/utils.go b/integration/utils.go index fde25f0..045d51e 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -171,8 +171,8 @@ func createCheckoutAppContainer(t *testing.T, ctx context.Context, net *testcontainers.DockerNetwork, pg *pgContainer, - debugLogs bool, withLogger bool, + debugLogs bool, ) *appContainer { logLevel := "info" if debugLogs {