From ba1562f4411c4673046f3bbf2a6b2dd378705460 Mon Sep 17 00:00:00 2001 From: Ed Beaty Date: Tue, 19 Mar 2024 09:03:20 -0700 Subject: [PATCH] . --- charts/tests/ut/cp_network-attachments.bats | 4 +- charts/tests/ut/cp_statefulset.bats | 41 +++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/charts/tests/ut/cp_network-attachments.bats b/charts/tests/ut/cp_network-attachments.bats index 5fb4e6a5..dbe52ae9 100644 --- a/charts/tests/ut/cp_network-attachments.bats +++ b/charts/tests/ut/cp_network-attachments.bats @@ -44,8 +44,8 @@ setup_file () { @test "Control Plane NetworkAttachmentDefinition: Global annotations and commonAnnotations can be added and are correctly merged" { template \ - --set-json 'interfaces=[{"type": "multus"}]' -\ - -set 'global.annotations.foo=bar' \ + --set-json 'interfaces=[{"type": "multus"}]' \ + --set 'global.annotations.foo=bar' \ --set 'commonAnnotations.baz=baa' assert_query_equal '.metadata.annotations.foo' "bar" assert_query_equal '.metadata.annotations.baz' "baa" diff --git a/charts/tests/ut/cp_statefulset.bats b/charts/tests/ut/cp_statefulset.bats index 71315986..9aaca6f4 100644 --- a/charts/tests/ut/cp_statefulset.bats +++ b/charts/tests/ut/cp_statefulset.bats @@ -322,11 +322,52 @@ setup_file () { } @test "Control Plane StatefulSet: XR_INTERFACES container env vars is correctly set" { + template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni"}]' + assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" + assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0" +} + +@test "Control Plane StatefulSet: set snoopIpv4Address flag in XR_INTERFACES" { + template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "snoopIpv4Address": true}]' + assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" + assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0,snoop_v4" +} + +@test "Control Plane StatefulSet: set snoopIpv4DefaultRoot flag in XR_INTERFACES" { + template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "snoopIpv4DefaultRoot": true}]' + assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" + assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0,snoop_v4_default_route" +} + +@test "Control Plane StatefulSet: set snoopIpv6Address flag in XR_INTERFACES" { + template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "snoopIpv6Address": true}]' + assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" + assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0,snoop_v6" +} + +@test "Control Plane StatefulSet: set snoopIpv6DefaultRoot flag in XR_INTERFACES" { + template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "snoopIpv6DefaultRoot": true}]' + assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" + assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0,snoop_v6_default_route" +} + +@test "Control Plane StatefulSet: set chksum flag in XR_INTERFACES" { template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "chksum": true}]' assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0,chksum" } +@test "Control Plane StatefulSet: set xrName flag in XR_INTERFACES" { + template --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "xrName": "foo"}]' + assert_query_equal '.spec.template.spec.containers[0].env[1].name' "XR_INTERFACES" + assert_query_equal '.spec.template.spec.containers[0].env[1].value' "linux:net1;linux:eth0,xr_name=foo" +} + +@test "Control Plane StatefulSet: don't set unsupported flags XR_INTERFACES" { + template_failure --set-json 'interfaces=[{"type": "multus"}, {"type": "defaultCni", "foo": "bar"}]' + assert_error_message_contains "abcd" +} + @test "Control Plane StatefulSet: XR_MGMT_INTERFACES container env vars is correctly set" { template --set-json 'mgmtInterfaces=[{"type": "multus", "chksum": true}, {"type": "defaultCni"}]' assert_query_equal '.spec.template.spec.containers[0].env[2].name' "XR_MGMT_INTERFACES"