Skip to content

Commit

Permalink
engine: keep trying to watch for Docker Compose events if we didn't a…
Browse files Browse the repository at this point in the history
…ctually start watching the first time (#1257)

* engine: keep trying to watch for Docker Compose events if we didn't actually start watching the first time

* test
  • Loading branch information
maiamcc authored and nicks committed Mar 7, 2019
1 parent 55759eb commit 5eeae69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/engine/docker_compose_event_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func (w *DockerComposeEventWatcher) OnChange(ctx context.Context, st store.RStor
if !w.needsWatch(st) {
return
}
w.watching = true

state := st.RLockState()
configPath := state.DockerComposeConfigPath()
Expand All @@ -41,6 +40,7 @@ func (w *DockerComposeEventWatcher) OnChange(ctx context.Context, st store.RStor
return
}

w.watching = true
ch, err := w.startWatch(ctx, configPath)
if err != nil {
err = errors.Wrap(err, "Subscribing to docker-compose events")
Expand Down
23 changes: 23 additions & 0 deletions internal/engine/upper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,29 @@ func TestDockerComposeEventSetsStatus(t *testing.T) {
})
}

func TestDockerComposeStartsEventWatcher(t *testing.T) {
f := newTestFixture(t)
_, m := f.setupDCFixture()

// Actual behavior is that we init with zero manifests, and add in manifests
// after Tiltfile loads. Mimic that here.
f.Start([]model.Manifest{}, true)
time.Sleep(10 * time.Millisecond)

f.store.Dispatch(ConfigsReloadedAction{Manifests: []model.Manifest{m}})
f.waitForCompletedBuildCount(1)

// Is DockerComposeEventWatcher watching for events??
err := f.dcc.SendEvent(dcContainerEvtForManifest(m, dockercompose.ActionCreate))
if err != nil {
f.T().Fatal(err)
}

f.WaitUntilManifestState("resource status = 'In Progress'", m.ManifestName(), func(ms store.ManifestState) bool {
return ms.DCResourceState().Status == dockercompose.StatusInProg
})
}

func TestDockerComposeRecordsBuildLogs(t *testing.T) {
f := newTestFixture(t)
m, _ := f.setupDCFixture()
Expand Down

0 comments on commit 5eeae69

Please sign in to comment.