Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acceptance: use 1.13 image in all acceptance tests #1391

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
10f5795
peering: set peering server config only when peering Helm value is true
ishustava Aug 1, 2022
6c1413d
acceptance: use 1.13 image in all acceptance tests
ishustava Aug 1, 2022
51181dd
try running OSS only tests
ishustava Aug 2, 2022
648c031
Revert "try running OSS only tests"
ishustava Aug 2, 2022
49cfe8a
only run peering test
ishustava Aug 2, 2022
9e10072
add timeout and print out peering token
ishustava Aug 2, 2022
26b4f84
add more debug output
ishustava Aug 2, 2022
80e60ee
Update logging image
ishustava Aug 2, 2022
295928b
use image with potential deletion fix
ishustava Aug 2, 2022
8d0f251
try another deletion fix image
ishustava Aug 2, 2022
8837f96
attempt to fix peering establish error
ishustava Aug 3, 2022
4356669
attempt2 to fix peering establish error
ishustava Aug 3, 2022
4c8365f
run all tests
ishustava Aug 3, 2022
691a790
rebase ent against main
ishustava Aug 3, 2022
ab80703
Revert "run all tests"
ishustava Aug 3, 2022
5411390
try another peering fix
ishustava Aug 3, 2022
8307e7e
comment out all except for one test case
ishustava Aug 3, 2022
966b8a6
add logging to the controller
ishustava Aug 3, 2022
6c6be1f
add more logging
ishustava Aug 3, 2022
972ca58
don't regenerate token if secret version changed and get the object b…
ishustava Aug 6, 2022
eca23be
more descriptive error message
ishustava Aug 6, 2022
fe2742e
add more logs
ishustava Aug 6, 2022
e760abc
add more logs
ishustava Aug 6, 2022
1accb3a
run all peering tests
ishustava Aug 6, 2022
1811557
add more jobs
ishustava Aug 6, 2022
fccd495
don't generate token if secret in the spec already exists
ishustava Aug 6, 2022
568108a
allow secret to exist from the spec w/o status being updated
ishustava Aug 6, 2022
7940d18
don't generate token twice
ishustava Aug 7, 2022
2391721
use latest consul 1.13 dev image
ishustava Aug 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ commands:
<< parameters.additional-flags >> \
${ENABLE_ENTERPRISE:+-enable-enterprise} \
-enable-multi-cluster \
-run TestPeering_* \
-debug-directory="$TEST_RESULTS/debug" \
-consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.13-dev \
-consul-k8s-image=<< parameters.consul-k8s-image >>
then
echo "Tests in ${pkg} failed, aborting early"
Expand Down Expand Up @@ -132,6 +134,7 @@ commands:
-enable-multi-cluster \
${ENABLE_ENTERPRISE:+-enable-enterprise} \
-debug-directory="$TEST_RESULTS/debug" \
-consul-image=docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.13-dev \
-consul-k8s-image=<< parameters.consul-k8s-image >>

jobs:
Expand Down Expand Up @@ -997,10 +1000,52 @@ workflows:
- build-distros-linux
# Run acceptance tests using the docker image built for the control plane
- acceptance:
name: acceptance1
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy:
name: acceptance2
context: consul-ci
requires:
- dev-upload-docker
- acceptance:
name: acceptance3
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy:
name: acceptance4
context: consul-ci
requires:
- dev-upload-docker
- acceptance:
name: acceptance5
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy:
name: acceptance6
context: consul-ci
requires:
- dev-upload-docker
- acceptance:
name: acceptance7
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy:
name: acceptance8
context: consul-ci
requires:
- dev-upload-docker
- acceptance:
name: acceptance9
context: consul-ci
requires:
- dev-upload-docker
- acceptance-tproxy:
name: acceptance10
context: consul-ci
requires:
- dev-upload-docker
Expand Down
10 changes: 10 additions & 0 deletions acceptance/framework/k8s/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package k8s

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"testing"
Expand Down Expand Up @@ -136,6 +138,14 @@ func CopySecret(t *testing.T, sourceContext, destContext environment.TestContext
secret.ResourceVersion = ""
require.NoError(r, err)
})
secretData := secret.Data["data"]

var token map[string]interface{}
// Decode the token to extract the ServerName and PeerID from the token. CA is always NULL.
decodeBytes, err := base64.StdEncoding.DecodeString(string(secretData))
require.NoError(t, err)
err = json.Unmarshal(decodeBytes, &token)
logger.Log(t, "peering token", token)
_, err = destContext.KubernetesClient(t).CoreV1().Secrets(destContext.KubectlOptions(t).Namespace).Create(context.Background(), secret, metav1.CreateOptions{})
require.NoError(t, err)
}
4 changes: 2 additions & 2 deletions acceptance/framework/k8s/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ func KubectlApplyK(t *testing.T, options *k8s.KubectlOptions, kustomizeDir strin
// deletes it from the cluster by running 'kubectl delete -f'.
// If there's an error deleting the file, fail the test.
func KubectlDelete(t *testing.T, options *k8s.KubectlOptions, configPath string) {
_, err := RunKubectlAndGetOutputE(t, options, "delete", "-f", configPath)
_, err := RunKubectlAndGetOutputE(t, options, "delete", "--timeout=60s", "-f", configPath)
require.NoError(t, err)
}

// KubectlDeleteK takes a path to a kustomize directory and
// deletes it from the cluster by running 'kubectl delete -k'.
// If there's an error deleting the file, fail the test.
func KubectlDeleteK(t *testing.T, options *k8s.KubectlOptions, kustomizeDir string) {
_, err := RunKubectlAndGetOutputE(t, options, "delete", "-k", kustomizeDir)
_, err := RunKubectlAndGetOutputE(t, options, "delete", "--timeout=60s", "-k", kustomizeDir)
require.NoError(t, err)
}

Expand Down
62 changes: 30 additions & 32 deletions acceptance/tests/peering/peering_connect_namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,36 @@ func TestPeering_ConnectNamespaces(t *testing.T) {
false,
false,
},
{
"single destination namespace",
staticServerNamespace,
false,
false,
},
{
"mirror k8s namespaces",
staticServerNamespace,
true,
false,
},
{
"default destination namespace",
defaultNamespace,
false,
true,
},
{
"single destination namespace",
staticServerNamespace,
false,
true,
},
{
"mirror k8s namespaces",
staticServerNamespace,
true,
true,
},
//{
// "single destination namespace",
// staticServerNamespace,
// false,
// false,
//},
//{
// "mirror k8s namespaces",
// staticServerNamespace,
// true,
// false,
//},
//{
// "default destination namespace",
// defaultNamespace,
// false,
// true,
//},
//{
// "single destination namespace",
// staticServerNamespace,
// false,
// true,
//},
//{
// "mirror k8s namespaces",
// staticServerNamespace,
// true,
// true,
//},
}

for _, c := range cases {
Expand All @@ -95,8 +95,6 @@ func TestPeering_ConnectNamespaces(t *testing.T) {
"global.peering.enabled": "true",
"global.enableConsulNamespaces": "true",

"global.image": "thisisnotashwin/consul@sha256:b1d3f59406adf5fb9a3bee4ded058e619d3a186e83b2e2dc14d6da3f28a7073d",

"global.tls.enabled": "true",
"global.tls.httpsOnly": strconv.FormatBool(c.ACLsAndAutoEncryptEnabled),
"global.tls.enableAutoEncrypt": strconv.FormatBool(c.ACLsAndAutoEncryptEnabled),
Expand Down
2 changes: 0 additions & 2 deletions acceptance/tests/peering/peering_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func TestPeering_Connect(t *testing.T) {
commonHelmValues := map[string]string{
"global.peering.enabled": "true",

"global.image": "thisisnotashwin/consul@sha256:b1d3f59406adf5fb9a3bee4ded058e619d3a186e83b2e2dc14d6da3f28a7073d",

"global.tls.enabled": "true",
"global.tls.httpsOnly": strconv.FormatBool(c.ACLsAndAutoEncryptEnabled),
"global.tls.enableAutoEncrypt": strconv.FormatBool(c.ACLsAndAutoEncryptEnabled),
Expand Down
5 changes: 5 additions & 0 deletions charts/consul/templates/server-config-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ data:
},
"recursors": {{ .Values.global.recursors | toJson }},
"retry_join": ["{{template "consul.fullname" . }}-server.{{ .Release.Namespace }}.svc:{{ .Values.server.ports.serflan.port }}"],
{{- if .Values.global.peering.enabled }}
"peering": {
"enabled": true
},
{{- end }}
"server": true
}
{{- $vaultConnectCAEnabled := and .Values.global.secretsBackend.vault.connectCA.address .Values.global.secretsBackend.vault.connectCA.rootPKIPath .Values.global.secretsBackend.vault.connectCA.intermediatePKIPath -}}
Expand Down
25 changes: 25 additions & 0 deletions charts/consul/test/unit/server-config-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -905,3 +905,28 @@ load _helpers

[ "${actual}" = null ]
}

#--------------------------------------------------------------------
# peering

@test "server/ConfigMap: peering configuration is unspecified by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-config-configmap.yaml \
. | tee /dev/stderr |
yq -r '.data["server.json"]' | jq -r .peering | tee /dev/stderr)

[ "${actual}" = "null" ]
}

@test "server/ConfigMap: peering configuration is set by if global.peering.enabled is true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-config-configmap.yaml \
--set 'global.peering.enabled=true' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -r '.data["server.json"]' | jq -r .peering.enabled | tee /dev/stderr)

[ "${actual}" = "true" ]
}
Loading