Fix guided lifecycle job scoping
This commit is contained in:
@@ -129,8 +129,23 @@ func TestFileStorePersistsAndReloadsResources(t *testing.T) {
|
||||
LastReconciledAt: stamp,
|
||||
ReconcileCount: 2,
|
||||
ReconcileOutcome: "confirmed active attempt",
|
||||
ExecutionInput: domain.JobExecutionInput{WorkspaceScope: "local", Content: "name=approved\n", ExpectedVersion: 1, ExpectedChecksum: "sha256:" + strings.Repeat("1", 64), MaxReadBytes: 64 * 1024, Inputs: map[string]string{"templateKey": "players.by-id", "playerId": "steam-123"}},
|
||||
ExecutionResult: domain.JobExecutionResult{Kind: "file.read", Version: 2, Checksum: "sha256:" + strings.Repeat("2", 64), SizeBytes: 15, AuditSummary: "bounded read", Content: "private-read"},
|
||||
ExecutionInput: domain.JobExecutionInput{
|
||||
WorkspaceScope: "local",
|
||||
Content: "name=approved\n",
|
||||
ExpectedVersion: 1,
|
||||
ExpectedChecksum: "sha256:" + strings.Repeat("1", 64),
|
||||
MaxReadBytes: 64 * 1024,
|
||||
Inputs: map[string]string{"templateKey": "players.by-id", "playerId": "steam-123"},
|
||||
Deployment: &domain.ServerDeploymentDefinition{
|
||||
Mode: domain.ServerDeploymentModeGuided,
|
||||
ProfileKey: "local",
|
||||
CreateInputs: map[string]string{"gamePort": "27000", "maxPlayers": "128"},
|
||||
ServerRoot: "D:\\scumserver",
|
||||
Revision: 2,
|
||||
},
|
||||
ServerDeploymentPlan: &domain.ServerDeploymentPlan{SchemaVersion: "1", Operation: "install", PluginID: "game.runtime", Prerequisites: []domain.RuntimeServerPrerequisite{{Key: "steamcmd", Kind: "tool"}}},
|
||||
},
|
||||
ExecutionResult: domain.JobExecutionResult{Kind: "file.read", Version: 2, Checksum: "sha256:" + strings.Repeat("2", 64), SizeBytes: 15, AuditSummary: "bounded read", Content: "private-read"},
|
||||
}
|
||||
if err := store.Jobs().Create(job); err != nil {
|
||||
t.Fatalf("create job: %v", err)
|
||||
@@ -194,7 +209,7 @@ func TestFileStorePersistsAndReloadsResources(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("get reloaded job by idempotency: %v", err)
|
||||
}
|
||||
if gotJob.ID != "job-1" || gotJob.ServerInstanceID != "server-1" || gotJob.Attempt != 2 || gotJob.RetryPolicy.MaxAttempts != 4 || gotJob.LeaseTokenHash != strings.Repeat("d", 64) || gotJob.ReconcileCount != 2 || gotJob.ExecutionInput.Content != "name=approved\n" || gotJob.ExecutionInput.Inputs["templateKey"] != "players.by-id" || gotJob.ExecutionInput.Inputs["playerId"] != "steam-123" || gotJob.ExecutionResult.Content != "private-read" {
|
||||
if gotJob.ID != "job-1" || gotJob.ServerInstanceID != "server-1" || gotJob.Attempt != 2 || gotJob.RetryPolicy.MaxAttempts != 4 || gotJob.LeaseTokenHash != strings.Repeat("d", 64) || gotJob.ReconcileCount != 2 || gotJob.ExecutionInput.Content != "name=approved\n" || gotJob.ExecutionInput.Inputs["templateKey"] != "players.by-id" || gotJob.ExecutionInput.Inputs["playerId"] != "steam-123" || gotJob.ExecutionInput.Deployment == nil || gotJob.ExecutionInput.Deployment.CreateInputs["gamePort"] != "27000" || gotJob.ExecutionInput.ServerDeploymentPlan == nil || gotJob.ExecutionInput.ServerDeploymentPlan.Prerequisites[0].Key != "steamcmd" || gotJob.ExecutionResult.Content != "private-read" {
|
||||
t.Fatalf("unexpected reloaded job: %+v", gotJob)
|
||||
}
|
||||
gotJob.ExecutionInput.Inputs["playerId"] = "mutated"
|
||||
@@ -248,7 +263,20 @@ func TestMySQLSnapshotRoundTripsDurableJobSchedulingMetadata(t *testing.T) {
|
||||
Attempt: 2, QueueEligibleAt: stamp, LeaseTokenHash: strings.Repeat("e", 64), LeaseSessionGen: 4,
|
||||
LeaseExpiresAt: stamp.Add(time.Minute), LastProgressSeq: 8, CancelReason: "stop", CancelRequestedAt: stamp,
|
||||
LastReconciledAt: stamp, ReconcileCount: 3, ReconcileOutcome: "confirmed active attempt", CreatedAt: stamp, UpdatedAt: stamp,
|
||||
ExecutionInput: domain.JobExecutionInput{WorkspaceScope: "local", Content: "mysql-approved", ExpectedVersion: 1, ExpectedChecksum: "sha256:" + strings.Repeat("3", 64), MaxReadBytes: 64 * 1024, Inputs: map[string]string{"templateKey": "players.by-id", "playerId": "steam-456"}},
|
||||
ExecutionInput: domain.JobExecutionInput{
|
||||
WorkspaceScope: "local",
|
||||
Content: "mysql-approved",
|
||||
ExpectedVersion: 1,
|
||||
ExpectedChecksum: "sha256:" + strings.Repeat("3", 64),
|
||||
MaxReadBytes: 64 * 1024,
|
||||
Inputs: map[string]string{"templateKey": "players.by-id", "playerId": "steam-456"},
|
||||
Deployment: &domain.ServerDeploymentDefinition{Mode: domain.ServerDeploymentModeGuided, ProfileKey: "local", CreateInputs: map[string]string{"gamePort": "27000"}, ServerRoot: "D:\\scumserver", Revision: 3},
|
||||
ServerDeploymentPlan: &domain.ServerDeploymentPlan{
|
||||
SchemaVersion: "1",
|
||||
Operation: "install",
|
||||
PluginID: "game.runtime",
|
||||
},
|
||||
},
|
||||
ExecutionResult: domain.JobExecutionResult{Kind: "file.write", Version: 2, Checksum: "sha256:" + strings.Repeat("4", 64), SizeBytes: 14, AuditSummary: "atomic write"},
|
||||
}
|
||||
if err := source.MemoryStore.Jobs().Create(job); err != nil {
|
||||
@@ -265,7 +293,7 @@ func TestMySQLSnapshotRoundTripsDurableJobSchedulingMetadata(t *testing.T) {
|
||||
target := &MySQLStore{MemoryStore: NewMemoryStore()}
|
||||
target.loadSnapshot(snapshot)
|
||||
got, err := target.MemoryStore.Jobs().Get(job.ID)
|
||||
if err != nil || got.Attempt != job.Attempt || got.LeaseTokenHash != job.LeaseTokenHash || got.LastProgressSeq != job.LastProgressSeq || got.ReconcileCount != job.ReconcileCount || got.ExecutionInput.Content != job.ExecutionInput.Content || got.ExecutionInput.Inputs["templateKey"] != "players.by-id" || got.ExecutionInput.Inputs["playerId"] != "steam-456" || got.ExecutionResult.Checksum != job.ExecutionResult.Checksum {
|
||||
if err != nil || got.Attempt != job.Attempt || got.LeaseTokenHash != job.LeaseTokenHash || got.LastProgressSeq != job.LastProgressSeq || got.ReconcileCount != job.ReconcileCount || got.ExecutionInput.Content != job.ExecutionInput.Content || got.ExecutionInput.Inputs["templateKey"] != "players.by-id" || got.ExecutionInput.Inputs["playerId"] != "steam-456" || got.ExecutionInput.Deployment == nil || got.ExecutionInput.Deployment.CreateInputs["gamePort"] != "27000" || got.ExecutionInput.ServerDeploymentPlan == nil || got.ExecutionInput.ServerDeploymentPlan.PluginID != "game.runtime" || got.ExecutionResult.Checksum != job.ExecutionResult.Checksum {
|
||||
t.Fatalf("unexpected MySQL snapshot job: job=%+v err=%v", got, err)
|
||||
}
|
||||
got.ExecutionInput.Inputs["playerId"] = "mutated"
|
||||
|
||||
Reference in New Issue
Block a user