Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/druid/core/services/runtime_session_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func (s *RuntimeSession) Hydrate() error {
s.runtimeScroll.Status = deriveRuntimeScrollStatus(s.runtimeScroll.Procedures, s.scrollService.GetFile().Commands)
err := s.store.UpdateScroll(s.runtimeScroll)
s.mu.Unlock()
return err
if err != nil {
return err
}
s.triggerRunQueue()
return nil
}

func (s *RuntimeSession) AutoStartServe() error {
Expand Down
50 changes: 50 additions & 0 deletions apps/druid/core/services/runtime_supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,56 @@ func TestRuntimeSupervisorStartHydratesRunningScroll(t *testing.T) {
}
}

func TestRuntimeSupervisorStartRunsHydratedRestartCommand(t *testing.T) {
store := newTestStateStore(t)
scrollYAML := multiProcedureScrollYAML()
runtimeScroll := &domain.RuntimeScroll{
ID: "running-restart-scroll",
Artifact: "local",
Root: "runtime://running-restart-scroll",
ScrollName: "cached",
ScrollYAML: scrollYAML,
Status: domain.RuntimeScrollStatusRunning,
Procedures: domain.ProcedureStatusMap{
"start": {
"coldstart": {Status: domain.ScrollLockStatusRunning},
"start": {Status: domain.ScrollLockStatusWaiting},
},
},
}
if err := store.CreateScroll(runtimeScroll); err != nil {
t.Fatal(err)
}
called := make(chan ports.RuntimeCommand, 1)
release := make(chan struct{})
supervisor := NewRuntimeSupervisor(store, coreservices.NewRuntimeScrollManager(store), &fakeWorkerBackend{
runCommand: func(command ports.RuntimeCommand) (*int, error) {
called <- command
<-release
return nil, nil
},
})

if err := supervisor.Start(); err != nil {
t.Fatal(err)
}
defer func() {
close(release)
if session := supervisor.sessions["running-restart-scroll"]; session != nil {
session.stopDeploymentQueue()
}
}()

select {
case command := <-called:
if command.Name != "start" {
t.Fatalf("hydrated command = %s, want start", command.Name)
}
case <-time.After(2 * time.Second):
t.Fatal("timed out waiting for hydrated restart command to run")
}
}

func TestRuntimeSupervisorEnsureCanCreate(t *testing.T) {
artifact := t.TempDir()
if err := os.WriteFile(filepath.Join(artifact, "scroll.yaml"), []byte(cachedScrollYAML("start")), 0644); err != nil {
Expand Down
Loading