Skip to content

chore(coderd): fix test flake with auditor #11316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions coderd/workspacebuilds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ func TestWorkspaceBuild(t *testing.T) {
_ = coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
// Create workspace will also start a build, so we need to wait for
// it to ensure all events are recorded.
require.Len(t, auditor.AuditLogs(), 2)
require.Equal(t, auditor.AuditLogs()[0].Ip.IPNet.IP.String(), "127.0.0.1")
require.Equal(t, auditor.AuditLogs()[1].Ip.IPNet.IP.String(), "127.0.0.1")
require.Eventually(t, func() bool {
logs := auditor.AuditLogs()
return len(logs) == 2 &&
assert.Equal(t, logs[0].Ip.IPNet.IP.String(), "127.0.0.1") &&
assert.Equal(t, logs[1].Ip.IPNet.IP.String(), "127.0.0.1")
}, testutil.WaitShort, testutil.IntervalFast)
}

func TestWorkspaceBuildByBuildNumber(t *testing.T) {
Expand Down Expand Up @@ -969,8 +972,11 @@ func TestPostWorkspaceBuild(t *testing.T) {
require.NoError(t, err)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, build.ID)

require.Len(t, auditor.AuditLogs(), 1)
require.Equal(t, auditor.AuditLogs()[0].Ip.IPNet.IP.String(), "127.0.0.1")
require.Eventually(t, func() bool {
logs := auditor.AuditLogs()
return len(logs) > 0 &&
assert.Equal(t, logs[0].Ip.IPNet.IP.String(), "127.0.0.1")
}, testutil.WaitShort, testutil.IntervalFast)
})

t.Run("IncrementBuildNumber", func(t *testing.T) {
Expand Down