Skip to content

Commit 9cdcaeb

Browse files
authored
Merge pull request #203 from cozystack/test/vip-empty-bond-skip-regression-pin
test(engine): pin empty-bond skip under VIP-active path
2 parents 92ffd52 + 333058f commit 9cdcaeb

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎pkg/engine/contract_network_multidoc_test.go‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,64 @@ func TestContract_NetworkMultidoc_BondWithoutSlaves_SkipsBondConfig_Generic(t *t
263263
}
264264
}
265265

266+
// TestContract_NetworkMultidoc_BondWithoutSlaves_WithVIP_SkipsBondConfig
267+
// pins the empty-slaves guardrail against the VIP-active code path.
268+
// Field report (#9327 / #9351): an operator on v0.27.0 saw an empty
269+
// BondConfig emitted "only when VIP is in use" — the existing
270+
// TestContract_NetworkMultidoc_BondWithoutSlaves_SkipsBondConfig pins
271+
// the no-VIP shape, so a hidden VIP-conditional branch could still
272+
// emit BondConfig{links: <empty>} without breaking the existing
273+
// contract. This test exercises the same empty-bond fixture with
274+
// floatingIP set, which activates the Layer2VIPConfig / floatingIP-
275+
// strip branches above the bond emission. The contract is identical:
276+
// no `kind: BondConfig` in the output, the bond stub is skipped.
277+
//
278+
// Operator UX guarantee: the Layer2VIPConfig document must still be
279+
// emitted (the VIP-link selector picks eth0 because the VIP shares
280+
// its subnet), and eth0 must still surface as a LinkConfig — the
281+
// VIP path must not collateral-damage the rest of the link graph.
282+
func TestContract_NetworkMultidoc_BondWithoutSlaves_WithVIP_SkipsBondConfig(t *testing.T) {
283+
out := renderCozystackWith(t, emptyBondTopologyLookup(), map[string]any{
284+
"advertisedSubnets": []any{testAdvertisedSubnet},
285+
"floatingIP": "192.168.1.50",
286+
})
287+
288+
if strings.Contains(out, "kind: BondConfig") {
289+
t.Errorf("empty-slaves bond must NOT emit BondConfig even when floatingIP activates the VIP path; got:\n%s", out)
290+
}
291+
292+
if strings.Contains(out, "name: bond0") {
293+
t.Errorf("empty-slaves bond's master link should not surface as a config document under the VIP path; got:\n%s", out)
294+
}
295+
296+
// Positive-shape pin: the VIP path must still emit its
297+
// Layer2VIPConfig (eth0 carries 192.168.1.100/24, so the VIP
298+
// 192.168.1.50 lands on eth0), and eth0 itself must still
299+
// render as a LinkConfig with its address.
300+
assertContains(t, out, "kind: Layer2VIPConfig")
301+
assertContains(t, out, "kind: LinkConfig")
302+
assertContains(t, out, "name: eth0")
303+
}
304+
305+
// TestContract_NetworkMultidoc_BondWithoutSlaves_WithVIP_SkipsBondConfig_Generic
306+
// is the generic-preset counterpart. Both presets share the empty-
307+
// slaves guard at the bond emission site; both must hold the
308+
// guarantee under the VIP-active code path too.
309+
func TestContract_NetworkMultidoc_BondWithoutSlaves_WithVIP_SkipsBondConfig_Generic(t *testing.T) {
310+
out := renderGenericWith(t, emptyBondTopologyLookup(), map[string]any{
311+
"advertisedSubnets": []any{testAdvertisedSubnet},
312+
"floatingIP": "192.168.1.50",
313+
})
314+
315+
if strings.Contains(out, "kind: BondConfig") {
316+
t.Errorf("generic preset: empty-slaves bond must NOT emit BondConfig under the VIP path; got:\n%s", out)
317+
}
318+
319+
if strings.Contains(out, "name: bond0") {
320+
t.Errorf("generic preset: bond stub should not surface as a config document under the VIP path; got:\n%s", out)
321+
}
322+
}
323+
266324
// Contract: bond slaves never appear as standalone LinkConfig
267325
// documents. configurable_link_names filters them out via spec.slaveKind.
268326
func TestContract_NetworkMultidoc_BondSlavesNotEmittedAsLinkConfig(t *testing.T) {

0 commit comments

Comments
 (0)