feat: 清理openspec
This commit is contained in:
@@ -159,43 +159,36 @@ func assertLogProcessStateEvent(t *testing.T, subscription LogEventSubscription,
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceCreatesTargetBoundDraftAndRequiresDedicatedRunRegistration(t *testing.T) {
|
||||
func TestCoreServiceCreatesUnboundDraftAndAttachesRunFromHeartbeat(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",
|
||||
})
|
||||
draft, err := svc.CreateServerInstanceWorkflow(domain.ServerLifecycleCreate{ID: "server-dedicated", PluginID: plugin.ID, Name: "Dedicated SCUM", IdempotencyKey: "dedicated-draft"})
|
||||
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")
|
||||
if draft.Instance.State != domain.ServerInstanceStateDraft || draft.Job.ID != "" || draft.Instance.RunEndpointID != "" {
|
||||
t.Fatalf("expected draft without a reserved Run identity, got %+v", draft)
|
||||
}
|
||||
|
||||
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)
|
||||
hello := validRunControlHello()
|
||||
hello.ServerInstanceID = draft.Instance.ID
|
||||
hello.PluginID = plugin.ID
|
||||
hello.ComponentKind = domain.DistributionComponentRun
|
||||
hello.KeyGeneration = key.Generation
|
||||
hello.RegistrationToken = plainKey
|
||||
hello.RunEndpointID = "run-local"
|
||||
hello.DisplayName = "Automatic SCUM Run"
|
||||
if registered, err := svc.RegisterRunHello(hello); err != nil || !registered.Accepted {
|
||||
t.Fatalf("register automatic Run heartbeat: result=%+v err=%v", registered, 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)
|
||||
attached, err := svc.GetServerInstance(draft.Instance.ID)
|
||||
if err != nil || attached.RunEndpointID != "run-local" {
|
||||
t.Fatalf("expected heartbeat to attach Run endpoint, instance=%+v err=%v", attached, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user