separate server run bindings from deployment targets
This commit is contained in:
@@ -85,6 +85,46 @@ func TestCoreServiceServerLifecycleWorkflows(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceCreatesTargetBoundDraftAndRequiresDedicatedRunRegistration(t *testing.T) {
|
||||
svc, _ := newLifecycleRunService(t)
|
||||
plugin := createLifecyclePlugin(t, svc)
|
||||
|
||||
draft, err := svc.CreateServerInstanceWorkflow(domain.ServerLifecycleCreate{
|
||||
ID: "server-dedicated", PluginID: plugin.ID, DeploymentTargetID: "run-local", Name: "Dedicated SCUM", IdempotencyKey: "dedicated-draft", ProfileKey: "local",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create target-bound draft: %v", err)
|
||||
}
|
||||
if draft.Instance.State != domain.ServerInstanceStateDraft || draft.Job.ID != "" || draft.Instance.DeploymentTargetID != "run-local" || draft.Instance.RunEndpointID != "server-run-server-dedicated" {
|
||||
t.Fatalf("expected draft with separate target and reserved Run identity, got %+v", draft)
|
||||
}
|
||||
if _, err := svc.DeployServerInstanceForSession("", domain.ServerLifecycleCommand{ServerInstanceID: draft.Instance.ID, ExpectedConfigVersion: draft.Instance.ConfigVersion, IdempotencyKey: "before-register"}); err == nil {
|
||||
t.Fatal("expected deployment without a registered dedicated Run to fail")
|
||||
}
|
||||
|
||||
key, plainKey, err := svc.ensureActiveComponentKey(draft.Instance.ID, domain.DistributionComponentRun, "")
|
||||
if err != nil {
|
||||
t.Fatalf("create Run key: %v", err)
|
||||
}
|
||||
wrong := validRunControlHello()
|
||||
wrong.ServerInstanceID = draft.Instance.ID
|
||||
wrong.PluginID = plugin.ID
|
||||
wrong.ComponentKind = domain.DistributionComponentRun
|
||||
wrong.KeyGeneration = key.Generation
|
||||
wrong.RegistrationToken = plainKey
|
||||
wrong.RunEndpointID = "run-local"
|
||||
if _, err := svc.RegisterRunHello(wrong); err == nil || !strings.Contains(err.Error(), "does not match") {
|
||||
t.Fatalf("expected mismatched endpoint registration rejection, got %v", err)
|
||||
}
|
||||
|
||||
correct := wrong
|
||||
correct.RunEndpointID = draft.Instance.RunEndpointID
|
||||
correct.DisplayName = "Dedicated SCUM Run"
|
||||
if registered, err := svc.RegisterRunHello(correct); err != nil || !registered.Accepted {
|
||||
t.Fatalf("register dedicated Run: result=%+v err=%v", registered, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceFreezesReadyDLLExtensionIntoWindowsStartJob(t *testing.T) {
|
||||
svc, sessionToken := newLifecycleRunService(t)
|
||||
setLifecycleEndpointTarget(t, svc, "windows", "amd64")
|
||||
|
||||
Reference in New Issue
Block a user