- Notifications
You must be signed in to change notification settings - Fork928
chore: refactorAgentHasNotConnectedSinceWeek_LogsExpired
#13802
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -11,6 +11,7 @@ import ( | ||||||
"time" | ||||||
"github.com/google/uuid" | ||||||
"github.com/stretchr/testify/assert" | ||||||
"github.com/stretchr/testify/require" | ||||||
"go.uber.org/goleak" | ||||||
"golang.org/x/exp/slices" | ||||||
@@ -183,20 +184,29 @@ func TestDeleteOldWorkspaceAgentLogs(t *testing.T) { | ||||||
// given | ||||||
agent := mustCreateAgentWithLogs(ctx, t, db, user, org, tmpl, tv, now.Add(-8*24*time.Hour), t.Name()) | ||||||
// Make sure that agent logs have been collected. | ||||||
agentLogs, err := db.GetWorkspaceAgentLogsAfter(ctx, database.GetWorkspaceAgentLogsAfterParams{ | ||||||
AgentID: agent, | ||||||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||
}) | ||||||
require.NoError(t, err) | ||||||
require.NotZero(t, agentLogs, "agent logs must be present") | ||||||
// when | ||||||
closer := dbpurge.New(ctx, logger, db) | ||||||
defer closer.Close() | ||||||
// then | ||||||
assert.Eventually(t, func() bool { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
| ||||||
agentLogs, err = db.GetWorkspaceAgentLogsAfter(ctx, database.GetWorkspaceAgentLogsAfterParams{ | ||||||
AgentID: agent, | ||||||
}) | ||||||
if err != nil { | ||||||
return false | ||||||
} | ||||||
return !containsAgentLog(agentLogs, t.Name()) | ||||||
}, testutil.WaitShort, testutil.IntervalFast) | ||||||
require.NoError(t, err) | ||||||
require.NotContains(t, agentLogs, t.Name()) | ||||||
}) | ||||||
t.Run("AgentConnectedSixDaysAgo_LogsValid", func(t *testing.T) { | ||||||
Uh oh!
There was an error while loading.Please reload this page.