Allow active deployment edits
This commit is contained in:
@@ -65,6 +65,40 @@ func TestCoreServiceSavesDraftDeploymentRedactsReadsAndDispatchesOnlyToCompatibl
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceUpdatesDeploymentWhileServerIsActive(t *testing.T) {
|
||||
svc, _ := newLifecycleRunService(t)
|
||||
createLifecyclePlugin(t, svc)
|
||||
ownerSession := createServiceUserAndLogin(t, svc, domain.User{ID: "deployment-active-owner", DisplayName: "Deployment Active Owner", Email: "deployment-active-owner@example.test", Roles: []string{"server-owner"}, PasswordHash: "secret-password"})
|
||||
|
||||
for _, state := range []domain.ServerInstanceState{domain.ServerInstanceStateInstalling, domain.ServerInstanceStateRunning} {
|
||||
stateLabel := string(state)
|
||||
created, err := svc.CreateServerInstanceWorkflowForSession(ownerSession, domain.ServerLifecycleCreate{
|
||||
ID: "active-deployment-edit-" + stateLabel, PluginID: "server.scum", Name: "Active Deployment Edit " + stateLabel, IdempotencyKey: "active-deployment-edit-" + stateLabel,
|
||||
Deployment: domain.ServerDeploymentDefinition{Mode: domain.ServerDeploymentModeCustom, ServerRoot: "/srv/active-server-" + stateLabel, WorkingDirectory: "/srv/active-server-" + stateLabel, StartCommand: "./start"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create %s deployment fixture: %v", state, err)
|
||||
}
|
||||
instance, err := svc.store.ServerInstances().Get(created.Instance.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("get %s deployment fixture: %v", state, err)
|
||||
}
|
||||
instance.RunEndpointID = "run-local"
|
||||
instance.State = state
|
||||
if err := svc.store.ServerInstances().Update(instance); err != nil {
|
||||
t.Fatalf("mark fixture %s: %v", state, err)
|
||||
}
|
||||
|
||||
view, err := svc.UpdateServerDeploymentForSession(ownerSession, instance.ID, domain.ServerDeploymentUpdate{Mode: domain.ServerDeploymentModeCustom, ServerRoot: "/srv/active-server-next-" + stateLabel, StartCommand: "./start-next"})
|
||||
if err != nil {
|
||||
t.Fatalf("update %s deployment: %v", state, err)
|
||||
}
|
||||
if view.Revision != instance.Deployment.Revision+1 || !view.ServerRootConfigured || !view.StartCommandConfigured {
|
||||
t.Fatalf("expected %s deployment revision and protected field flags to update, view=%+v", state, view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreServiceSCUMGuidedDeployDispatchesPluginOwnedInstallAction(t *testing.T) {
|
||||
svc := newTestCoreService()
|
||||
runHello := validRunControlHello()
|
||||
|
||||
Reference in New Issue
Block a user