From f6772336cb3960530465564206fbe433bc7658b0 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Fri, 13 Sep 2024 15:24:37 -0400 Subject: [PATCH 01/14] Fixes annotations not working, pushing to test bats tests --- .../templates/gateway-resources-job.yaml | 3 +- .../test/unit/gateway-resources-job.bats | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/charts/consul/templates/gateway-resources-job.yaml b/charts/consul/templates/gateway-resources-job.yaml index 5f3110479c..ff53129eb3 100644 --- a/charts/consul/templates/gateway-resources-job.yaml +++ b/charts/consul/templates/gateway-resources-job.yaml @@ -69,7 +69,8 @@ spec: - {{- toYaml .Values.connectInject.apiGateway.managedGatewayClass.nodeSelector | nindent 14 -}} {{- end }} {{- if .Values.connectInject.apiGateway.managedGatewayClass.tolerations }} - - -tolerations={{ .Values.connectInject.apiGateway.managedGatewayClass.tolerations }} + - -tolerations + - {{- toYaml .Values.connectInject.apiGateway.managedGatewayClass.tolerations | nindent 14 -}} {{- end }} {{- if .Values.connectInject.apiGateway.managedGatewayClass.copyAnnotations.service }} - -service-annotations diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 32173838fe..f94dc273da 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -63,7 +63,7 @@ target=templates/gateway-resources-job.yaml [ "${actual}" = "true" ] } -@test "apiGateway/GatewayClassConfig: custom configuration" { +@test "apiGateway/GatewayClassConfig: custom configuration blah" { cd `chart_dir` local spec=$(helm template \ -s $target \ @@ -71,7 +71,6 @@ target=templates/gateway-resources-job.yaml --set 'connectInject.apiGateway.managedGatewayClass.deployment.minInstances=1' \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.maxInstances=3' \ --set 'connectInject.apiGateway.managedGatewayClass.nodeSelector=foo: bar' \ - --set 'connectInject.apiGateway.managedGatewayClass.tolerations=- key: bar' \ --set 'connectInject.apiGateway.managedGatewayClass.copyAnnotations.service.annotations=- bingo' \ --set 'connectInject.apiGateway.managedGatewayClass.serviceType=Foo' \ --set 'connectInject.apiGateway.managedGatewayClass.openshiftSCCName=hello' \ @@ -96,16 +95,13 @@ target=templates/gateway-resources-job.yaml local actual=$(echo "$spec" | jq '.[13]') [ "${actual}" = "\"foo: bar\"" ] - local actual=$(echo "$spec" | jq '.[14] | ."-tolerations=- key"') - [ "${actual}" = "\"bar\"" ] - - local actual=$(echo "$spec" | jq '.[15]') + local actual=$(echo "$spec" | jq '.[14]') [ "${actual}" = "\"-service-annotations\"" ] - local actual=$(echo "$spec" | jq '.[16]') + local actual=$(echo "$spec" | jq '.[15]') [ "${actual}" = "\"- bingo\"" ] - local actual=$(echo "$spec" | jq '.[17]') + local actual=$(echo "$spec" | jq '.[16]') [ "${actual}" = "\"-service-type=Foo\"" ] } @@ -138,3 +134,25 @@ target=templates/gateway-resources-job.yaml tee /dev/stderr) [ "${actual}" = "{}" ] } + + +#-------------------------------------------------------------------- +# annotations +@test "apiGateway/GatewayClassConfig: tolerations" { + cd `chart_dir` + local spec=$(helm template \ + -s templates/gateway-resources-job.yaml \ + --set 'connectInject.apiGateway.managedGatewayClass.tolerations=- "operator": "Equal" \ +"effect": "NoSchedule" \ +"key": "node" \ +"value": "clients" \ +- "operator": "Equal" \ +"effect": "NoSchedule" \ +"key": "node2" \ +"value": "clients2"' \ + . | tee /dev/stderr | + yq '.spec.template.spec.containers[0].args' | tee /dev/stderr) + + local actual=$(echo "$spec" | jq '.[14] | ."-tolerations=- key"') + [ "${actual}" = "\"node\"" ] +} \ No newline at end of file From f501b955b939a5301a95cc4eb0ea059936941a41 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 16 Sep 2024 11:00:07 -0400 Subject: [PATCH 02/14] Added bats test --- charts/consul/test/unit/gateway-resources-job.bats | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index f94dc273da..16b5e1dae1 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -137,10 +137,11 @@ target=templates/gateway-resources-job.yaml #-------------------------------------------------------------------- -# annotations +# tolerations + @test "apiGateway/GatewayClassConfig: tolerations" { cd `chart_dir` - local spec=$(helm template \ + local tolerations=$(helm template \ -s templates/gateway-resources-job.yaml \ --set 'connectInject.apiGateway.managedGatewayClass.tolerations=- "operator": "Equal" \ "effect": "NoSchedule" \ @@ -151,8 +152,6 @@ target=templates/gateway-resources-job.yaml "key": "node2" \ "value": "clients2"' \ . | tee /dev/stderr | - yq '.spec.template.spec.containers[0].args' | tee /dev/stderr) - - local actual=$(echo "$spec" | jq '.[14] | ."-tolerations=- key"') - [ "${actual}" = "\"node\"" ] + yq '.spec.template.spec.containers[0].args.[13] | contains("\"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" \n- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"")' | tee /dev/stderr) + [ "${tolerations}" = "true" ] } \ No newline at end of file From 44fed44d2789aea88c688eddcc49c502797fe53b Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 16 Sep 2024 13:05:32 -0400 Subject: [PATCH 03/14] bats start small --- charts/consul/test/unit/gateway-resources-job.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 16b5e1dae1..fceb75761b 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -152,6 +152,6 @@ target=templates/gateway-resources-job.yaml "key": "node2" \ "value": "clients2"' \ . | tee /dev/stderr | - yq '.spec.template.spec.containers[0].args.[13] | contains("\"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" \n- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"")' | tee /dev/stderr) + yq '.spec.template.spec.containers[0].args.[13] | contains("\"operator\": ")' | tee /dev/stderr) [ "${tolerations}" = "true" ] } \ No newline at end of file From f8d0bc64e6333a3e6fca41b99c6e6a6ac09cbfb6 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 16 Sep 2024 13:19:08 -0400 Subject: [PATCH 04/14] bats try again --- charts/consul/test/unit/gateway-resources-job.bats | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index fceb75761b..808a797f5f 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -151,7 +151,13 @@ target=templates/gateway-resources-job.yaml "effect": "NoSchedule" \ "key": "node2" \ "value": "clients2"' \ - . | tee /dev/stderr | - yq '.spec.template.spec.containers[0].args.[13] | contains("\"operator\": ")' | tee /dev/stderr) - [ "${tolerations}" = "true" ] + .| tee /dev/stderr | + yq '.spec.template.spec.containers[0]' | tee /dev/stderr) + echo "cupcakes" + echo $tolerations + local actual=$(echo "$tolerations" | yq '.args.[13] | contains("\"operator\": ")' | tee /dev/stderr) + echo "if fails-----------------------------------------------------------" + echo $actual + echo $actual >&3 + [ "${actual}" = true ] } \ No newline at end of file From ae82e6cd3f12b361be0bb323aed6eb8a1753c4b2 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 16 Sep 2024 13:53:54 -0400 Subject: [PATCH 05/14] bats try again --- charts/consul/test/unit/gateway-resources-job.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 808a797f5f..eb2620460d 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -155,7 +155,7 @@ target=templates/gateway-resources-job.yaml yq '.spec.template.spec.containers[0]' | tee /dev/stderr) echo "cupcakes" echo $tolerations - local actual=$(echo "$tolerations" | yq '.args.[13] | contains("\"operator\": ")' | tee /dev/stderr) + local actual=$(echo "$tolerations" | yq '.args.[13] | contains("operator")' | tee /dev/stderr) echo "if fails-----------------------------------------------------------" echo $actual echo $actual >&3 From d90cc9382c91955e61ecc0d3d335f8d5f3602dda Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 16 Sep 2024 14:08:34 -0400 Subject: [PATCH 06/14] bats try again --- charts/consul/test/unit/gateway-resources-job.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index eb2620460d..4db6537f25 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -151,12 +151,12 @@ target=templates/gateway-resources-job.yaml "effect": "NoSchedule" \ "key": "node2" \ "value": "clients2"' \ - .| tee /dev/stderr | + . | tee /dev/stderr | yq '.spec.template.spec.containers[0]' | tee /dev/stderr) - echo "cupcakes" - echo $tolerations - local actual=$(echo "$tolerations" | yq '.args.[13] | contains("operator")' | tee /dev/stderr) + + local actual=$(echo "$tolerations" | yq '.args.[13] | contains("blah")' | tee /dev/stderr) echo "if fails-----------------------------------------------------------" + echo $tolerations echo $actual echo $actual >&3 [ "${actual}" = true ] From ef58d91c9b92c6db72e99dbeb50ca369bfa2989e Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 16 Sep 2024 14:29:01 -0400 Subject: [PATCH 07/14] bats try again --- charts/consul/test/unit/gateway-resources-job.bats | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 4db6537f25..4ccc898334 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -157,6 +157,7 @@ target=templates/gateway-resources-job.yaml local actual=$(echo "$tolerations" | yq '.args.[13] | contains("blah")' | tee /dev/stderr) echo "if fails-----------------------------------------------------------" echo $tolerations + echo "$tolerations" | yq '.args.[13]' echo $actual echo $actual >&3 [ "${actual}" = true ] From 9b6349454d010a7e50dff9b3a204d0019d333367 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Tue, 17 Sep 2024 15:39:48 -0400 Subject: [PATCH 08/14] Adds changelog, updates command test, tries again with bats --- .changelog/2392.txt | 5 +- .../test/unit/gateway-resources-job.bats | 11 +--- .../gateway-resources/command_test.go | 53 +++++++++++++++++-- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/.changelog/2392.txt b/.changelog/2392.txt index e268c796ff..05b7fb01da 100644 --- a/.changelog/2392.txt +++ b/.changelog/2392.txt @@ -1,6 +1,3 @@ -```release-note:breaking-change -control-plane: All policies managed by consul-k8s will now be updated on upgrade. If you previously edited the policies after install, your changes will be overwritten. -``` ```release-note:bug -control-plane: Always update ACL policies upon upgrade. +helm: fix issue where the API Gateway GatewayClassConfig tolerations can not be parsed by the Helm chart. ``` diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 4ccc898334..8028780ec3 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -152,13 +152,6 @@ target=templates/gateway-resources-job.yaml "key": "node2" \ "value": "clients2"' \ . | tee /dev/stderr | - yq '.spec.template.spec.containers[0]' | tee /dev/stderr) - - local actual=$(echo "$tolerations" | yq '.args.[13] | contains("blah")' | tee /dev/stderr) - echo "if fails-----------------------------------------------------------" - echo $tolerations - echo "$tolerations" | yq '.args.[13]' - echo $actual - echo $actual >&3 - [ "${actual}" = true ] + yq '.spec.template.spec.containers[0].args.[13] | contains("operator")' | tee /dev/stderr) + [ "${tolerations}" = "true" ] } \ No newline at end of file diff --git a/control-plane/subcommand/gateway-resources/command_test.go b/control-plane/subcommand/gateway-resources/command_test.go index 6e8230102c..5612547525 100644 --- a/control-plane/subcommand/gateway-resources/command_test.go +++ b/control-plane/subcommand/gateway-resources/command_test.go @@ -161,9 +161,14 @@ func TestRun_flagValidation(t *testing.T) { flagNodeSelector: ` foo: 1 bar: 2`, - flagTolerations: ` -- value: foo -- value: bar`, + flagTolerations: `- "operator": "Equal" + "effect": "NoSchedule" + "key": "node" + "value": "clients" +- "operator": "Equal" + "effect": "NoSchedule" + "key": "node2" + "value": "clients2"`, flagServiceAnnotations: ` - foo - bar`, @@ -254,6 +259,48 @@ func TestRun(t *testing.T) { "-component", "test", "-controller-name", "test", "-openshift-scc-name", "restricted-v2", + "-node-selector", `beta.kubernetes.io/arch: amd64`, + "-tolerations", ` + - + | + - "operator": "Equal" + "effect": "NoSchedule" + "key": "node" + "value": "clients" + - "operator": "Equal" + "effect": "NoSchedule" + "key": "node2" + "value": "clients2"`, + //{ + // "operator": "Equal" + // "effect": "NoSchedule" + // "key": "node" + // "value": "clients" + //}, + //{ + // "operator": "Equal" + // "effect": "NoSchedule" + // "key": "node2" + // "value": "clients2" + //}`, + //- "operator": "Equal" + // "effect": "NoSchedule" + // "key": "node" + // "value": "clients" + //- "operator": "Equal" + // "effect": "NoSchedule" + // "key": "node2" + // "value": "clients2"`, + //- / + //| / + //- \"operator\": \"Equal\" + //\"effect\": \"NoSchedule\" + //\"key\": \"node\" + //\"value\": \"clients\", + //- \"operator\": \"Equal\" + //\"effect\": \"NoSchedule\" + //\"key\": \"node2\" + //\"value\": \"clients2\""`, }) require.Equal(t, 0, code) From 4024d004b884446b652901a26b433dee776fda83 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Tue, 17 Sep 2024 15:41:28 -0400 Subject: [PATCH 09/14] Accidentally put changelog in wrong file --- .changelog/2392.txt | 5 ++++- .changelog/4315.txt | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changelog/4315.txt diff --git a/.changelog/2392.txt b/.changelog/2392.txt index 05b7fb01da..e268c796ff 100644 --- a/.changelog/2392.txt +++ b/.changelog/2392.txt @@ -1,3 +1,6 @@ +```release-note:breaking-change +control-plane: All policies managed by consul-k8s will now be updated on upgrade. If you previously edited the policies after install, your changes will be overwritten. +``` ```release-note:bug -helm: fix issue where the API Gateway GatewayClassConfig tolerations can not be parsed by the Helm chart. +control-plane: Always update ACL policies upon upgrade. ``` diff --git a/.changelog/4315.txt b/.changelog/4315.txt new file mode 100644 index 0000000000..05b7fb01da --- /dev/null +++ b/.changelog/4315.txt @@ -0,0 +1,3 @@ +```release-note:bug +helm: fix issue where the API Gateway GatewayClassConfig tolerations can not be parsed by the Helm chart. +``` From e22efb746291d411ea0d1f9509a4e3608cf2982a Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Wed, 18 Sep 2024 15:53:04 -0400 Subject: [PATCH 10/14] Accidentally left some test data --- .../gateway-resources/command_test.go | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/control-plane/subcommand/gateway-resources/command_test.go b/control-plane/subcommand/gateway-resources/command_test.go index 5612547525..ef88886004 100644 --- a/control-plane/subcommand/gateway-resources/command_test.go +++ b/control-plane/subcommand/gateway-resources/command_test.go @@ -259,48 +259,6 @@ func TestRun(t *testing.T) { "-component", "test", "-controller-name", "test", "-openshift-scc-name", "restricted-v2", - "-node-selector", `beta.kubernetes.io/arch: amd64`, - "-tolerations", ` - - - | - - "operator": "Equal" - "effect": "NoSchedule" - "key": "node" - "value": "clients" - - "operator": "Equal" - "effect": "NoSchedule" - "key": "node2" - "value": "clients2"`, - //{ - // "operator": "Equal" - // "effect": "NoSchedule" - // "key": "node" - // "value": "clients" - //}, - //{ - // "operator": "Equal" - // "effect": "NoSchedule" - // "key": "node2" - // "value": "clients2" - //}`, - //- "operator": "Equal" - // "effect": "NoSchedule" - // "key": "node" - // "value": "clients" - //- "operator": "Equal" - // "effect": "NoSchedule" - // "key": "node2" - // "value": "clients2"`, - //- / - //| / - //- \"operator\": \"Equal\" - //\"effect\": \"NoSchedule\" - //\"key\": \"node\" - //\"value\": \"clients\", - //- \"operator\": \"Equal\" - //\"effect\": \"NoSchedule\" - //\"key\": \"node2\" - //\"value\": \"clients2\""`, }) require.Equal(t, 0, code) From 50cae96a0c0804f4db1d19e373151e3915162795 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Thu, 19 Sep 2024 14:18:50 -0400 Subject: [PATCH 11/14] bats --- charts/consul/test/unit/gateway-resources-job.bats | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 8028780ec3..d06faff0a0 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -152,6 +152,8 @@ target=templates/gateway-resources-job.yaml "key": "node2" \ "value": "clients2"' \ . | tee /dev/stderr | - yq '.spec.template.spec.containers[0].args.[13] | contains("operator")' | tee /dev/stderr) - [ "${tolerations}" = "true" ] + yq '.spec.template.spec.containers[0].args' | tee /dev/stderr) + + echo "TOLERATIONS: ${tolerations}" + local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\"" ])') } \ No newline at end of file From a89016d6a244926cc48c222a491cf904523b21b4 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Fri, 20 Sep 2024 09:42:55 -0400 Subject: [PATCH 12/14] bats --- charts/consul/test/unit/gateway-resources-job.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index d06faff0a0..211ba3c699 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -142,7 +142,7 @@ target=templates/gateway-resources-job.yaml @test "apiGateway/GatewayClassConfig: tolerations" { cd `chart_dir` local tolerations=$(helm template \ - -s templates/gateway-resources-job.yaml \ + -s $target \ --set 'connectInject.apiGateway.managedGatewayClass.tolerations=- "operator": "Equal" \ "effect": "NoSchedule" \ "key": "node" \ @@ -155,5 +155,5 @@ target=templates/gateway-resources-job.yaml yq '.spec.template.spec.containers[0].args' | tee /dev/stderr) echo "TOLERATIONS: ${tolerations}" - local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\"" ])') + local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" - \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"" ])') } \ No newline at end of file From 59fdd83caa672d23bdadd8121f66afef64324332 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 23 Sep 2024 09:36:31 -0400 Subject: [PATCH 13/14] bats --- .../test/unit/gateway-resources-job.bats | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index 211ba3c699..fbb7231eff 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -66,7 +66,7 @@ target=templates/gateway-resources-job.yaml @test "apiGateway/GatewayClassConfig: custom configuration blah" { cd `chart_dir` local spec=$(helm template \ - -s $target \ + -s templates/gateway-resources-job.yaml \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.defaultInstances=2' \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.minInstances=1' \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.maxInstances=3' \ @@ -89,20 +89,11 @@ target=templates/gateway-resources-job.yaml local actual=$(echo "$spec" | jq 'any(index("-service-type=Foo"))') [ "${actual}" = "true" ] - local actual=$(echo "$spec" | jq '.[12]') - [ "${actual}" = "\"-node-selector\"" ] - - local actual=$(echo "$spec" | jq '.[13]') - [ "${actual}" = "\"foo: bar\"" ] - - local actual=$(echo "$spec" | jq '.[14]') - [ "${actual}" = "\"-service-annotations\"" ] - - local actual=$(echo "$spec" | jq '.[15]') - [ "${actual}" = "\"- bingo\"" ] + local actual=$(echo $spec | yq 'contains(["-node-selector", "foo: bar"])') + [ "${actual}" = "true" ] - local actual=$(echo "$spec" | jq '.[16]') - [ "${actual}" = "\"-service-type=Foo\"" ] + local actual=$(echo $spec | yq 'contains(["-service-annotations", "- bingo"])') + [ "${actual}" = "true" ] } @test "apiGateway/GatewayClassConfig: custom configuration openshift enabled" { @@ -154,6 +145,6 @@ target=templates/gateway-resources-job.yaml . | tee /dev/stderr | yq '.spec.template.spec.containers[0].args' | tee /dev/stderr) - echo "TOLERATIONS: ${tolerations}" local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" - \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"" ])') + [ "${actual}" = "true" ] } \ No newline at end of file From c0c93b1d33531dc182279ea43e588030338d20a8 Mon Sep 17 00:00:00 2001 From: Melisa Griffin Date: Mon, 23 Sep 2024 10:06:27 -0400 Subject: [PATCH 14/14] bats cleanup --- charts/consul/test/unit/gateway-resources-job.bats | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/consul/test/unit/gateway-resources-job.bats b/charts/consul/test/unit/gateway-resources-job.bats index fbb7231eff..fd64acac02 100644 --- a/charts/consul/test/unit/gateway-resources-job.bats +++ b/charts/consul/test/unit/gateway-resources-job.bats @@ -63,10 +63,10 @@ target=templates/gateway-resources-job.yaml [ "${actual}" = "true" ] } -@test "apiGateway/GatewayClassConfig: custom configuration blah" { +@test "apiGateway/GatewayClassConfig: custom configuration" { cd `chart_dir` local spec=$(helm template \ - -s templates/gateway-resources-job.yaml \ + -s $target \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.defaultInstances=2' \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.minInstances=1' \ --set 'connectInject.apiGateway.managedGatewayClass.deployment.maxInstances=3' \ @@ -145,6 +145,6 @@ target=templates/gateway-resources-job.yaml . | tee /dev/stderr | yq '.spec.template.spec.containers[0].args' | tee /dev/stderr) - local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" - \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"" ])') + local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" \n- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"" ])') [ "${actual}" = "true" ] } \ No newline at end of file