-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[usage] Join workspace instances with workspaces to get project and type #11312
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,66 +18,67 @@ import ( | |
func TestListWorkspaceInstancesInRange(t *testing.T) { | ||
conn := dbtest.ConnectForTests(t) | ||
|
||
workspaceID := "gitpodio-gitpod-gyjr82jkfnd" | ||
workspace := dbtest.CreateWorkspaces(t, conn, dbtest.NewWorkspace(t, db.Workspace{}))[0] | ||
|
||
valid := []db.WorkspaceInstance{ | ||
// In the middle of May | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
Comment on lines
+21
to
+26
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. Was this change necessary or just tidying up? 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. To ensure the joining works correctly, we needed to create an actual Workspace record in the DB (line 21). That Workspace gets a random ID each time, so it's references here. Aside, getting a random ID is a good thing, as it allows tests against the DB to run concurrently without interfering with each other. |
||
CreationTime: db.NewVarcharTime(time.Date(2022, 05, 15, 12, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 05, 15, 12, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 05, 15, 13, 00, 00, 00, time.UTC)), | ||
}), | ||
// Start of May | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 05, 1, 0, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 05, 1, 0, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 05, 1, 1, 00, 00, 00, time.UTC)), | ||
}), | ||
// End of May | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 05, 31, 23, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 05, 31, 23, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 05, 31, 23, 59, 59, 999999, time.UTC)), | ||
}), | ||
// Started in April, but continued into May | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 04, 30, 23, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 04, 30, 23, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 05, 1, 0, 0, 0, 0, time.UTC)), | ||
}), | ||
// Started in May, but continued into June | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 05, 31, 23, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 05, 31, 23, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 06, 1, 1, 0, 0, 0, time.UTC)), | ||
}), | ||
// Started in April, but continued into June (ran for all of May) | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 04, 31, 23, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 04, 31, 23, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 06, 1, 1, 0, 0, 0, time.UTC)), | ||
}), | ||
// Stopped in May, no creation time, should be retrieved but this is a poor data quality record. | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 05, 1, 1, 0, 0, 0, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 05, 1, 1, 0, 0, 0, time.UTC)), | ||
}), | ||
// Started in April, no stop time, still running | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 04, 31, 23, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 04, 31, 23, 00, 00, 00, time.UTC)), | ||
}), | ||
|
@@ -86,7 +87,7 @@ func TestListWorkspaceInstancesInRange(t *testing.T) { | |
// Start of June | ||
dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{ | ||
ID: uuid.New(), | ||
WorkspaceID: workspaceID, | ||
WorkspaceID: workspace.ID, | ||
CreationTime: db.NewVarcharTime(time.Date(2022, 06, 1, 00, 00, 00, 00, time.UTC)), | ||
StartedTime: db.NewVarcharTime(time.Date(2022, 06, 1, 00, 00, 00, 00, time.UTC)), | ||
StoppedTime: db.NewVarcharTime(time.Date(2022, 06, 1, 1, 0, 0, 0, time.UTC)), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test this query against larger data sets to see how it performs, or happy to deploy to prod as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can give it a go against prod data