Skip to content

Commit

Permalink
Fix failing unit tests after rebasing Cluster Peering (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Venkatesh authored and ishustava committed Sep 28, 2022
1 parent 3364122 commit 766bc67
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions charts/consul/test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,15 @@ load _helpers
# check that the extra-config volume is defined
local volume_name=$(helm template \
-s templates/client-daemonset.yaml \
--set 'client.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "extra-config") | .name' | tee /dev/stderr)
[ "${volume_name}" = "extra-config" ]

# check that the consul container mounts the volume at /consul/extra-config
local mount_path=$(helm template \
-s templates/client-daemonset.yaml \
--set 'client.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[] | select(.name == "consul") | .volumeMounts[] | select(.name == "extra-config") | .mountPath' | tee /dev/stderr)
[ "${mount_path}" = "/consul/extra-config" ]
Expand Down Expand Up @@ -987,6 +989,7 @@ load _helpers
cd `chart_dir`
local command=$(helm template \
-s templates/client-daemonset.yaml \
--set 'client.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.peering.enabled=true' \
--set 'connectInject.enabled=true' \
Expand All @@ -1008,6 +1011,7 @@ load _helpers
cd `chart_dir`
local command=$(helm template \
-s templates/client-daemonset.yaml \
--set 'client.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.peering.enabled=true' \
--set 'connectInject.enabled=true' \
Expand Down
6 changes: 3 additions & 3 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ load _helpers
-s templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations."consul.hashicorp.com/config-checksum"' | tee /dev/stderr)
[ "${actual}" = 04cc39bf3f56ff39a2f4ae188fc37fc54b7775a073e8f97111eb37a548d7e229 ]
[ "${actual}" = b13fbd9214f5131aaf1bc234c5e307db1e9be3f29a66f14a994c2a73175ab29c ]
}

@test "server/StatefulSet: adds config-checksum annotation when extraConfig is provided" {
Expand All @@ -688,7 +688,7 @@ load _helpers
--set 'server.extraConfig="{\"hello\": \"world\"}"' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations."consul.hashicorp.com/config-checksum"' | tee /dev/stderr)
[ "${actual}" = e8d2e9535eb6e69eedebef725a66a8b47fd8845a77772f0e19911d2273b9b804 ]
[ "${actual}" = a32421961a4d6086483ce99d496b8fc34730bc476a0245d3b7762f6d5557cef2 ]
}

@test "server/StatefulSet: adds config-checksum annotation when config is updated" {
Expand All @@ -698,7 +698,7 @@ load _helpers
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations."consul.hashicorp.com/config-checksum"' | tee /dev/stderr)
[ "${actual}" = d5f4de988e9d51ff8ae91a24a1a990dc65ce046c0494836f6d0f0eae34108235 ]
[ "${actual}" = a68b3056d1b756d09163f5104d13a201d1e577e7c08c2ea44163eb03b0ca98b8 ]
}

#--------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion control-plane/connect-inject/container_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${POD
h := tt.Webhook
pod := *tt.Pod(minimal())
container, err := h.containerInit(testNS, pod, multiPortInfo{})
require.NoError(t, err)
if tt.ErrStr == "" {
require.NoError(t, err)
} else {
require.Contains(t, err.Error(), tt.ErrStr)
}
actual := strings.Join(container.Command, " ")
require.Contains(t, actual, tt.Cmd)
if tt.CmdNot != "" {
Expand Down
2 changes: 0 additions & 2 deletions control-plane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,4 @@ require (
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace github.com/hashicorp/consul/sdk v0.10.0 => github.com/hashicorp/consul/sdk v0.4.1-0.20220801192236-988e1fd35d51

go 1.18
2 changes: 1 addition & 1 deletion control-plane/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBt
github.com/hashicorp/consul/api v1.10.1-0.20220822180451-60c82757ea35 h1:csNww5qBHaFqsX1eMEKVvmJ4dhqcXWj0sCkbccsSsHc=
github.com/hashicorp/consul/api v1.10.1-0.20220822180451-60c82757ea35/go.mod h1:bcaw5CSZ7NE9qfOfKCI1xb7ZKjzu/MyvQkCLTfqLqxQ=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/consul/sdk v0.4.1-0.20220801192236-988e1fd35d51/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw=
github.com/hashicorp/consul/sdk v0.10.0/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw=
github.com/hashicorp/consul/sdk v0.11.0 h1:HRzj8YSCln2yGgCumN5CL8lYlD3gBurnervJRJAZyC4=
github.com/hashicorp/consul/sdk v0.11.0/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
Expand Down

0 comments on commit 766bc67

Please sign in to comment.