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)
| 587 | // on (via reconciler.serviceNodes). Without this, services declared in |
| 588 | // depends_on could start before their dependencies' operations complete. |
| 589 | func 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 |
nothing calls this directly
no test coverage detected