fix: lease monitor tasks by account identity
This commit is contained in:
@@ -239,19 +239,28 @@ func TestBuildCountPublishTasksByStatusesQueryHidesDeletedPublishRecords(t *test
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeaseNextQueuedMonitorTaskSQLSerializesPerClientPlatform(t *testing.T) {
|
||||
func TestLeaseNextQueuedMonitorTaskSQLUsesAccountIdentityAndClientSlots(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
normalized := normalizeSQLForDesktopTaskTest(leaseNextQueuedMonitorTaskSQL())
|
||||
for _, fragment := range []string{
|
||||
"WITH current_accounts AS",
|
||||
"client_id = $3",
|
||||
"dt.target_account_id = target_account.desktop_id",
|
||||
"target_account.account_fingerprint",
|
||||
"target_account.platform_uid",
|
||||
"hashtextextended",
|
||||
"pg_try_advisory_xact_lock(account_slot_lock_key)",
|
||||
"SET target_client_id = $3, target_account_id = candidate.lease_account_id",
|
||||
"NOT EXISTS ( SELECT 1 FROM desktop_tasks AS active",
|
||||
"active.target_client_id = $3",
|
||||
"active.platform_id = dt.platform_id",
|
||||
"active.status = 'in_progress'",
|
||||
"active.desktop_id <> dt.desktop_id",
|
||||
"COUNT(DISTINCT active_platform.platform_id)",
|
||||
"active_platform.target_client_id = $3",
|
||||
"< $8::integer",
|
||||
"< $6::integer",
|
||||
"active_client_platform.target_client_id = $3",
|
||||
"active_client_platform.platform_id = dt.platform_id",
|
||||
"recent.status = 'succeeded'",
|
||||
"recent.updated_at >= now() - interval '2 seconds'",
|
||||
"recent.status IN ('failed', 'unknown', 'aborted')",
|
||||
@@ -264,19 +273,30 @@ func TestLeaseNextQueuedMonitorTaskSQLSerializesPerClientPlatform(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeaseQueuedDesktopTaskByIDSQLSerializesMonitorPerClientPlatform(t *testing.T) {
|
||||
func TestLeaseQueuedDesktopTaskByIDSQLUsesAccountIdentityAndClientSlots(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
normalized := normalizeSQLForDesktopTaskTest(leaseQueuedDesktopTaskByIDSQL())
|
||||
for _, fragment := range []string{
|
||||
"WITH current_accounts AS",
|
||||
"client_id = $4",
|
||||
"dt.kind <> 'monitor' OR ca.desktop_id IS NOT NULL",
|
||||
"target_account.account_fingerprint",
|
||||
"target_account.platform_uid",
|
||||
"SELECT dt.desktop_id, dt.kind, ca.desktop_id AS lease_account_id",
|
||||
"locked_candidate AS",
|
||||
"pg_try_advisory_xact_lock(account_slot_lock_key)",
|
||||
"FROM locked_candidate WHERE t.desktop_id = locked_candidate.desktop_id",
|
||||
"target_account_id = CASE WHEN t.kind = 'monitor' THEN locked_candidate.lease_account_id ELSE t.target_account_id END",
|
||||
"dt.kind <> 'monitor' OR NOT EXISTS",
|
||||
"active.target_client_id = $4",
|
||||
"active.platform_id = dt.platform_id",
|
||||
"active.status = 'in_progress'",
|
||||
"active.desktop_id <> dt.desktop_id",
|
||||
"COUNT(DISTINCT active_platform.platform_id)",
|
||||
"active_platform.target_client_id = $4",
|
||||
"< $10::integer",
|
||||
"< $8::integer",
|
||||
"active_client_platform.target_client_id = $4",
|
||||
"active_client_platform.platform_id = dt.platform_id",
|
||||
"recent.status = 'succeeded'",
|
||||
"recent.updated_at >= now() - interval '2 seconds'",
|
||||
"recent.status IN ('failed', 'unknown', 'aborted')",
|
||||
|
||||
Reference in New Issue
Block a user