MCPcopy
hub / github.com/docker/compose / TestReconcileContainers_DependsOnChain

Function TestReconcileContainers_DependsOnChain

pkg/compose/reconcile_test.go:589–619  ·  view source on GitHub ↗

TestReconcileContainers_DependsOnChain verifies that a dependent service's container creation depends on the last plan node of the service it depends on (via reconciler.serviceNodes). Without this, services declared in depends_on could start before their dependencies' operations complete.

(t *testing.T)

Source from the content-addressed store, hash-verified

587// on (via reconciler.serviceNodes). Without this, services declared in
588// depends_on could start before their dependencies' operations complete.
589func TestReconcileContainers_DependsOnChain(t *testing.T) {
590 project := &types.Project{
591 Name: "myproject",
592 Services: types.Services{
593 "db": {Name: "db", Scale: intPtr(1)},
594 "web": {
595 Name: "web",
596 Scale: intPtr(1),
597 DependsOn: types.DependsOnConfig{
598 "db": {Condition: types.ServiceConditionStarted},
599 },
600 },
601 },
602 }
603 observed := &ObservedState{
604 ProjectName: "myproject",
605 Containers: map[string][]ObservedContainer{},
606 Networks: map[string]ObservedNetwork{},
607 Volumes: map[string]ObservedVolume{},
608 }
609
610 plan, err := reconcile(t.Context(), project, observed, defaultReconcileOptions(), noPrompt)
611 assert.NilError(t, err)
612
613 // db has no dependencies, so its CreateContainer has no deps.
614 // web depends on db, so its CreateContainer must depend on db's node #1.
615 assert.Equal(t, plan.String(), strings.TrimSpace(`
616[] -> #1 service:db:1, CreateContainer, no existing container
617[1] -> #2 service:web:1, CreateContainer, no existing container
618`)+"\n")
619}
620
621// TestReconcileContainers_DependsOnScaleDown verifies that scale-down of a
622// service still propagates through serviceNodes, so a dependent service waits

Callers

nothing calls this directly

Calls 4

intPtrFunction · 0.85
reconcileFunction · 0.85
defaultReconcileOptionsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected