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

CNI Accptance test on Kind #1445

Merged
merged 10 commits into from
Aug 25, 2022
Merged

CNI Accptance test on Kind #1445

merged 10 commits into from
Aug 25, 2022

Conversation

curtbushko
Copy link
Contributor

Background: In order to run acceptance tests on kind there needs to be some extra setup. Kind needs the Calico CNI plugin to be installed first and Kind needs its network to match what Calico expects.

Some tests have been disabled as running them with CNI is redundant to other acceptance tests.

There is no magic here. Helm install the CNI plugin and the tests are run. Everything should work the same as normal.

Changes proposed in this PR:

  • Added a new make target for installing Calico in Kind
  • Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
  • Added a kind.config for setting up the Kind cluster
  • Added a new -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
  • Added a new nightly circleci job for running the CNI kind tests
  • I had missed a bats test for the connect-inject template that I merged in a previous PR

Note to Iryna, I added connect-inject-init user uid to the redirect PR last night so not to muddle this PR.

How I've tested this PR:

  • "nightly" circle CI and local runs

How I expect reviewers to test this PR:

👀

Checklist:

  • Tests added
  • CHANGELOG entry added

    HashiCorp engineers only, community PRs should not add a changelog entry.
    Entries should use present tense (e.g. Add support for...)

- store_artifacts:
path: /tmp/test-results
- slack/status:
# temporarily sending to #cni-acceptance-tests channel
Copy link
Contributor Author

@curtbushko curtbushko Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove before merge.

- schedule:
cron: "0 0 * * *"
filters:
branches:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix before merge.

@@ -1027,29 +1076,33 @@ workflows:
- dev-upload-docker:
requires:
- build-distros-linux
- cleanup-gcp-resources
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix before merge.

- cleanup-azure-resources
- dev-upload-docker
- acceptance-kind-1-23:
# - acceptance-gke-1-20:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix before merge.

@@ -135,7 +135,7 @@ rollingUpdate:
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -rc '.spec.template.spec.containers[0].resources' | tee /dev/stderr)
[ "${actual}" = '{"limits":{"cpu":"75m","memory":"75Mi"},"requests":{"cpu":"50m","memory":"50Mi"}}' ]
[ "${actual}" = '{"limits":{"cpu":"100m","memory":"100Mi"},"requests":{"cpu":"75m","memory":"75Mi"}}' ]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed to be increased because the CNI installer was getting OOMKilled on Kind.

@@ -51,6 +51,9 @@ load _helpers
local actual=$(echo $object | yq -r '.resources[| index("namespaces")' | tee /dev/stderr)
[ "${actual}" != null ]

local actual=$(echo $object | yq -r '.resources[| index("nodes")' | tee /dev/stderr)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added 'node' back to the connect inject cluster role in a previous PR (yesterday) and I missed the bats test for it.

memory: "75Mi"
cpu: "75m"
limits:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed to be increased because the CNI installer was getting OOMKilled on Kind.

@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a job for the test-and-build pipeline as well so that it runs on every PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

@curtbushko curtbushko Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

Changed.

@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dns test is not a mesh test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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),
Copy link
Contributor

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 set it here? wouldn't it be set by the framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have been removed.

…connectInject.cni.enabled from several files as the framework will set this when the flag is passed in
@curtbushko curtbushko requested a review from ishustava August 24, 2022 21:49
@curtbushko curtbushko self-assigned this Aug 25, 2022
This was referenced Aug 25, 2022
@@ -1007,18 +1054,22 @@ workflows:
context: consul-ci
requires:
- dev-upload-docker
- acceptance-kind-cni-1-23:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should use the same kind version as other acceptance tests in this pipeline

Suggested change
- acceptance-kind-cni-1-23:
- acceptance-tproxy-cni:

Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Curt! Approving, but I left one small comment

@curtbushko curtbushko mentioned this pull request Aug 25, 2022
2 tasks
@curtbushko curtbushko merged commit ff76ee9 into cni Aug 25, 2022
@curtbushko curtbushko deleted the curtbushko/cni-acceptance-kind branch August 25, 2022 19:23
@curtbushko curtbushko restored the curtbushko/cni-acceptance-kind branch August 25, 2022 19:28
curtbushko added a commit that referenced this pull request Aug 25, 2022
-  Added a new make target for installing Calico CNI in Kind. The target installs Calico CNI using config files located under /acceptance tests
- Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
- Added a kind.config for setting up the Kind cluster
- Added an -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
-  Added a nightly circleci job for running the CNI kind tests
-  I had missed a bats test for the connect-inject template that I merged in a previous PR
curtbushko added a commit that referenced this pull request Aug 25, 2022
-  Added a new make target for installing Calico CNI in Kind. The target installs Calico CNI using config files located under /acceptance tests
- Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
- Added a kind.config for setting up the Kind cluster
- Added an -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
-  Added a nightly circleci job for running the CNI kind tests
-  I had missed a bats test for the connect-inject template that I merged in a previous PR
curtbushko added a commit that referenced this pull request Aug 25, 2022
-  Added a new make target for installing Calico CNI in Kind. The target installs Calico CNI using config files located under /acceptance tests
- Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
- Added a kind.config for setting up the Kind cluster
- Added an -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
-  Added a nightly circleci job for running the CNI kind tests
-  I had missed a bats test for the connect-inject template that I merged in a previous PR
curtbushko added a commit that referenced this pull request Aug 25, 2022
-  Added a new make target for installing Calico CNI in Kind. The target installs Calico CNI using config files located under /acceptance tests
- Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
- Added a kind.config for setting up the Kind cluster
- Added an -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
-  Added a nightly circleci job for running the CNI kind tests
-  I had missed a bats test for the connect-inject template that I merged in a previous PR
curtbushko added a commit that referenced this pull request Aug 25, 2022
-  Added a new make target for installing Calico CNI in Kind. The target installs Calico CNI using config files located under /acceptance tests
- Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
- Added a kind.config for setting up the Kind cluster
- Added an -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
-  Added a nightly circleci job for running the CNI kind tests
-  I had missed a bats test for the connect-inject template that I merged in a previous PR
@curtbushko curtbushko deleted the curtbushko/cni-acceptance-kind branch August 26, 2022 02:25
curtbushko added a commit that referenced this pull request Aug 26, 2022
-  Added a new make target for installing Calico CNI in Kind. The target installs Calico CNI using config files located under /acceptance tests
- Added a helper make target for setting up local Kind with Calico just in case anyone wants to run it.
- Added a kind.config for setting up the Kind cluster
- Added an -enable-cni flag to the acceptance test config so that it can be passed through from CircleCI
-  Added a nightly circleci job for running the CNI kind tests
-  I had missed a bats test for the connect-inject template that I merged in a previous PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants