feat: prepare installation workspaces through existing readiness services
This commit is contained in:
@@ -86,7 +86,7 @@ type dockerFixture struct {
|
||||
|
||||
func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (compose.Result, error) {
|
||||
if input != nil {
|
||||
if args[len(args)-1] != bindingClient {
|
||||
if args[len(args)-1] != bindingClient && args[len(args)-1] != readinessClient {
|
||||
return compose.Result{}, fmt.Errorf("unexpected interactive input")
|
||||
}
|
||||
command := strings.Join(args, " ")
|
||||
@@ -101,6 +101,12 @@ func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (
|
||||
return compose.Result{}, fmt.Errorf("file newline leaked into scalar credential")
|
||||
}
|
||||
r.calls = append(r.calls, append([]string{}, args...))
|
||||
if args[len(args)-1] == readinessClient {
|
||||
if r.fail == "schema-review" {
|
||||
return compose.Result{ExitCode: 1, Stdout: `{"ok":false,"code":"schema_review_required","completed":0,"workspaceId":"chinook","runId":"e9ca48f6-0a09-49bd-a003-04f9d518d702"}`}, nil
|
||||
}
|
||||
return compose.Result{Stdout: `{"ok":true,"code":"workspaces_prepared","completed":1}`}, nil
|
||||
}
|
||||
return compose.Result{Stdout: `{"ok":true,"code":"bindings_ready","completed":1}`}, nil
|
||||
}
|
||||
r.calls = append(r.calls, append([]string{}, args...))
|
||||
@@ -137,6 +143,9 @@ func (r *dockerFixture) Run(_ context.Context, args []string, input io.Reader) (
|
||||
if strings.Contains(line, " ps ") {
|
||||
return compose.Result{Stdout: `[{"Service":"core","State":"running","Health":"healthy"},{"Service":"frontend","State":"running","Health":"healthy"},{"Service":"catalog-db","State":"running","Health":"healthy"},{"Service":"qdrant","State":"running","Health":"healthy"},{"Service":"embedding","State":"running","Health":"healthy"},{"Service":"embedding-model-init","State":"exited","ExitCode":0}]`}, nil
|
||||
}
|
||||
if strings.Contains(line, "/app/backend/dist/operator-command.js") {
|
||||
return compose.Result{Stdout: `{"ready":true}`}, nil
|
||||
}
|
||||
return compose.Result{Stdout: `{"ok":true}`}, nil
|
||||
}
|
||||
|
||||
@@ -162,7 +171,7 @@ func TestApplyReleasedPlanWithoutInputAndRepeatPreservesData(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !result.PlatformReady || result.WorkspaceReady {
|
||||
if !result.PlatformReady || !result.WorkspaceReady || result.Stage != "workspace-ready" {
|
||||
t.Fatalf("wrong readiness: %+v", result)
|
||||
}
|
||||
}
|
||||
@@ -185,6 +194,22 @@ func TestApplyReleasedPlanWithoutInputAndRepeatPreservesData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkspaceReviewAndRuntimeFailureNeverClaimWorkspaceReady(t *testing.T) {
|
||||
for _, stage := range []string{"schema-review", "operator-command.js pi-test"} {
|
||||
t.Run(stage, func(t *testing.T) {
|
||||
path, p := fixture(t)
|
||||
r := &dockerFixture{fail: stage}
|
||||
result, err := Run(context.Background(), Request{PlanPath: path, InstallationPath: p.Installation.Path}, r, func(context.Context, preflight.Plan) error { return nil })
|
||||
if err == nil || !result.PlatformReady || !result.BindingsReady || result.WorkspaceReady {
|
||||
t.Fatalf("readiness failure hidden: %+v %v", result, err)
|
||||
}
|
||||
if stage == "schema-review" && (result.WorkspacePreparation == nil || result.WorkspacePreparation.Code != "schema_review_required") {
|
||||
t.Fatalf("human gate lost: %+v", result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
func flatten(calls [][]string) []string {
|
||||
out := []string{}
|
||||
for _, c := range calls {
|
||||
|
||||
Reference in New Issue
Block a user