-
Notifications
You must be signed in to change notification settings - Fork 325
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
CNI Accptance test on Kind #1445
Changes from 5 commits
8ef2c28
e49970c
be0ad22
e9d029e
691f10a
b95c83c
bce75ed
a3814e2
92ab438
d3feb5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,6 @@ commands: | |
wget https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz | ||
tar -zxvf helm-v3.7.0-linux-amd64.tar.gz | ||
sudo mv linux-amd64/helm /usr/local/bin/helm | ||
|
||
create-kind-clusters: | ||
parameters: | ||
version: | ||
|
@@ -59,6 +58,19 @@ commands: | |
command: | | ||
kind create cluster --name dc1 --image kindest/node:<< parameters.version >> | ||
kind create cluster --name dc2 --image kindest/node:<< parameters.version >> | ||
create-kind-cni-clusters: | ||
parameters: | ||
version: | ||
type: string | ||
steps: | ||
- run: | ||
name: Create CNI kind clusters | ||
command: | | ||
kind create cluster --config=acceptance/framework/environment/cni-kind/kind.config --name dc1 --image kindest/node:<< parameters.version >> | ||
make kind-cni-calico | ||
sleep 2 | ||
kind create cluster --config=acceptance/framework/environment/cni-kind/kind.config --name dc2 --image kindest/node:<< parameters.version >> | ||
make kind-cni-calico | ||
run-acceptance-tests: | ||
parameters: | ||
failfast: | ||
|
@@ -878,6 +890,42 @@ jobs: | |
fail_only: true | ||
failure_message: "Acceptance tests against Kind with Kubernetes v1.23 failed. Check the logs at: ${CIRCLE_BUILD_URL}" | ||
|
||
acceptance-kind-cni-1-23: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we add a job for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
parallelism: 6 | ||
environment: | ||
- TEST_RESULTS: /tmp/test-results | ||
machine: | ||
image: ubuntu-2004:202010-01 | ||
resource_class: xlarge | ||
steps: | ||
- checkout | ||
- install-prereqs | ||
- create-kind-cni-clusters: | ||
version: "v1.23.0" | ||
- restore_cache: | ||
keys: | ||
- consul-helm-modcache-v2-{{ checksum "acceptance/go.mod" }} | ||
- run: | ||
name: go mod download | ||
working_directory: *acceptance-mod-path | ||
command: go mod download | ||
- save_cache: | ||
key: consul-helm-modcache-v2-{{ checksum "acceptance/go.mod" }} | ||
paths: | ||
- ~/.go_workspace/pkg/mod | ||
- run: mkdir -p $TEST_RESULTS | ||
- run-acceptance-tests: | ||
additional-flags: -use-kind -kubecontext="kind-dc1" -secondary-kubecontext="kind-dc2" -enable-transparent-proxy -enable-cni | ||
- store_test_results: | ||
path: /tmp/test-results | ||
- store_artifacts: | ||
path: /tmp/test-results | ||
- slack/status: | ||
# temporarily sending to #cni-acceptance-tests channel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove before merge. |
||
channel: C03V3K0040G | ||
fail_only: true | ||
failure_message: "Acceptance tests for CNI against Kind with Kubernetes v1.23 failed. Check the logs at: ${CIRCLE_BUILD_URL}" | ||
|
||
acceptance-kind-1-23-consul-nightly-1-11: | ||
environment: | ||
- TEST_RESULTS: /tmp/test-results | ||
|
@@ -1012,13 +1060,13 @@ workflows: | |
requires: | ||
- dev-upload-docker | ||
nightly-acceptance-tests: | ||
triggers: | ||
- schedule: | ||
cron: "0 0 * * *" | ||
filters: | ||
branches: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix before merge. |
||
only: | ||
- main | ||
# triggers: | ||
# - schedule: | ||
# cron: "0 0 * * *" | ||
# filters: | ||
# branches: | ||
# only: | ||
# - main | ||
jobs: | ||
- build-distro: | ||
OS: "linux" | ||
|
@@ -1027,29 +1075,33 @@ workflows: | |
- dev-upload-docker: | ||
requires: | ||
- build-distros-linux | ||
- cleanup-gcp-resources | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix before merge. |
||
- cleanup-azure-resources | ||
- cleanup-eks-resources | ||
# - cleanup-gcp-resources | ||
# - cleanup-azure-resources | ||
# - cleanup-eks-resources | ||
# Disable until we can use UBI images. | ||
# - acceptance-openshift: | ||
# requires: | ||
# - cleanup-azure-resources | ||
- acceptance-gke-1-20: | ||
requires: | ||
- cleanup-gcp-resources | ||
- dev-upload-docker | ||
- acceptance-eks-1-19: | ||
requires: | ||
- cleanup-eks-resources | ||
- dev-upload-docker | ||
- acceptance-aks-1-21: | ||
requires: | ||
- cleanup-azure-resources | ||
- dev-upload-docker | ||
- acceptance-kind-1-23: | ||
# - acceptance-gke-1-20: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix before merge. |
||
# requires: | ||
# - cleanup-gcp-resources | ||
# - dev-upload-docker | ||
# - acceptance-eks-1-19: | ||
# requires: | ||
# - cleanup-eks-resources | ||
# - dev-upload-docker | ||
# - acceptance-aks-1-21: | ||
# requires: | ||
# - cleanup-azure-resources | ||
# - dev-upload-docker | ||
# - acceptance-kind-1-23: | ||
# requires: | ||
# - dev-upload-docker | ||
- acceptance-kind-cni-1-23: | ||
requires: | ||
- dev-upload-docker | ||
|
||
|
||
# nightly-acceptance-tests-consul: | ||
# triggers: | ||
# - schedule: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ type TestConfig struct { | |
|
||
EnablePodSecurityPolicies bool | ||
|
||
EnableCNI bool | ||
|
||
EnableTransparentProxy bool | ||
|
||
DisablePeering bool | ||
|
@@ -83,6 +85,11 @@ func (t *TestConfig) HelmValuesFromConfig() (map[string]string, error) { | |
setIfNotEmpty(helmValues, "global.enablePodSecurityPolicies", "true") | ||
} | ||
|
||
if t.EnableCNI { | ||
setIfNotEmpty(helmValues, "connectInject.enabled", "true") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should set connectInject. For tproxy we're only setting the tproxy value so that for tests that don't use connect inject you don't end up running it because of the global flag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. Changed. |
||
setIfNotEmpty(helmValues, "connectInject.cni.enabled", "true") | ||
} | ||
|
||
setIfNotEmpty(helmValues, "connectInject.transparentProxy.defaultEnabled", strconv.FormatBool(t.EnableTransparentProxy)) | ||
|
||
setIfNotEmpty(helmValues, "global.image", t.ConsulImage) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
networking: | ||
# Calicos default subnet. Needed for Calico to run on kind | ||
podSubnet: 192.168.0.0/16 | ||
serviceSubnet: 10.110.0.0/16 | ||
# The default kind.net CNI plugin will not be installed | ||
disableDefaultCNI: true | ||
nodes: | ||
- role: control-plane |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ type TestFlags struct { | |
|
||
flagEnablePodSecurityPolicies bool | ||
|
||
flagEnableCNI bool | ||
|
||
flagEnableTransparentProxy bool | ||
|
||
flagConsulImage string | ||
|
@@ -85,6 +87,10 @@ func (t *TestFlags) init() { | |
flag.BoolVar(&t.flagEnablePodSecurityPolicies, "enable-pod-security-policies", false, | ||
"If true, the test suite will run tests with pod security policies enabled.") | ||
|
||
flag.BoolVar(&t.flagEnableCNI, "enable-cni", false, | ||
"If true, the test suite will run tests with consul-cni plugin enabled. "+ | ||
"In general, this will only run against tests that are mesh related (connect, dns, mesh-gateway, peering, etc") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
flag.BoolVar(&t.flagEnableTransparentProxy, "enable-transparent-proxy", false, | ||
"If true, the test suite will run tests with transparent proxy enabled. "+ | ||
"This applies only to tests that enable connectInject.") | ||
|
@@ -142,6 +148,8 @@ func (t *TestFlags) TestConfigFromFlags() *config.TestConfig { | |
|
||
EnablePodSecurityPolicies: t.flagEnablePodSecurityPolicies, | ||
|
||
EnableCNI: t.flagEnableCNI, | ||
|
||
EnableTransparentProxy: t.flagEnableTransparentProxy, | ||
|
||
DisablePeering: t.flagDisablePeering, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,10 @@ import ( | |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const staticServerNamespace = "ns1" | ||
const StaticClientNamespace = "ns2" | ||
const ( | ||
staticServerNamespace = "ns1" | ||
StaticClientNamespace = "ns2" | ||
) | ||
|
||
// Test that Connect works with Consul Enterprise namespaces. | ||
// These tests currently only test non-secure and secure without auto-encrypt installations | ||
|
@@ -71,6 +73,7 @@ func TestConnectInjectNamespaces(t *testing.T) { | |
helmValues := map[string]string{ | ||
"global.enableConsulNamespaces": "true", | ||
"connectInject.enabled": "true", | ||
"connectInject.cni.enabled": strconv.FormatBool(cfg.EnableCNI), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to set it here? wouldn't it be set by the framework? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct. I am setting this all over the place and there is no need. I only discovered my mistake after I started the GKE acceptance tests. I will remove and shrink this PR by quite a bit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These have been removed. |
||
// When mirroringK8S is set, this setting is ignored. | ||
"connectInject.consulNamespaces.consulDestinationNamespace": c.destinationNamespace, | ||
"connectInject.consulNamespaces.mirroringK8S": strconv.FormatBool(c.mirrorK8S), | ||
|
@@ -226,7 +229,15 @@ func TestConnectInjectNamespaces(t *testing.T) { | |
// from server, which is the case when a connection is unsuccessful due to intentions in other tests. | ||
logger.Log(t, "checking that connection is unsuccessful") | ||
if cfg.EnableTransparentProxy { | ||
k8s.CheckStaticServerConnectionMultipleFailureMessages(t, staticClientOpts, StaticClientName, false, []string{"curl: (56) Recv failure: Connection reset by peer", "curl: (52) Empty reply from server", "curl: (7) Failed to connect to static-server.ns1 port 80: Connection refused"}, "", fmt.Sprintf("http://static-server.%s", staticServerNamespace)) | ||
k8s.CheckStaticServerConnectionMultipleFailureMessages( | ||
t, | ||
staticClientOpts, | ||
StaticClientName, | ||
false, | ||
[]string{"curl: (56) Recv failure: Connection reset by peer", "curl: (52) Empty reply from server", "curl: (7) Failed to connect to static-server.ns1 port 80: Connection refused"}, | ||
"", | ||
fmt.Sprintf("http://static-server.%s", staticServerNamespace), | ||
) | ||
} else { | ||
k8s.CheckStaticServerConnectionMultipleFailureMessages(t, staticClientOpts, StaticClientName, false, []string{"curl: (56) Recv failure: Connection reset by peer", "curl: (52) Empty reply from server"}, "", "http://localhost:1234") | ||
} | ||
|
@@ -285,6 +296,7 @@ func TestConnectInjectNamespaces_CleanupController(t *testing.T) { | |
helmValues := map[string]string{ | ||
"global.enableConsulNamespaces": "true", | ||
"connectInject.enabled": "true", | ||
"connectInject.cni.enabled": strconv.FormatBool(cfg.EnableCNI), | ||
// When mirroringK8S is set, this setting is ignored. | ||
"connectInject.consulNamespaces.consulDestinationNamespace": c.destinationNamespace, | ||
"connectInject.consulNamespaces.mirroringK8S": strconv.FormatBool(c.mirrorK8S), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to sleep here? wouldn't finish setup while the other kind cluster is being created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.