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

CAPI e2e tests #13

Merged
merged 68 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
cab18de
fix e2e tests and bugs
bschimke95 Jun 24, 2024
ea8a78f
fixup linter issues and missing flags
bschimke95 Jun 26, 2024
9e05e15
fix remaining tests
bschimke95 Jun 27, 2024
38c72a9
fixup docker build
bschimke95 Jun 28, 2024
493631d
ci fixup
bschimke95 Jun 28, 2024
a45894e
ci fixup
bschimke95 Jun 28, 2024
8c21eca
cleanup temlate todos
bschimke95 Jun 28, 2024
c3a7b27
another ci try
bschimke95 Jul 1, 2024
3338b2a
put skip into beforeall
bschimke95 Jul 1, 2024
1feb590
fix tests
bschimke95 Jul 1, 2024
98ad5e8
try to get some disk space back
bschimke95 Jul 2, 2024
306be85
another ci attempt
bschimke95 Jul 2, 2024
601d9fd
replace image tags for e2e
bschimke95 Jul 3, 2024
0bdd3c5
add no-arch make targets
bschimke95 Jul 3, 2024
263c445
rename no-arch to e2e
bschimke95 Jul 3, 2024
4f530bc
split GH workflow into build and test jobs
bschimke95 Jul 3, 2024
9b398a8
cleanup docker to not run into ooo
bschimke95 Jul 3, 2024
c6e0fa4
artifact permissions
bschimke95 Jul 3, 2024
c0a4b69
fix permissions
bschimke95 Jul 3, 2024
f95ab29
fix provider image artifacts
bschimke95 Jul 3, 2024
eca2cd6
still no space left ...
bschimke95 Jul 3, 2024
1e7861e
another no space left try...
bschimke95 Jul 3, 2024
f4716c0
try
bschimke95 Jul 3, 2024
8964362
still no space...
bschimke95 Jul 3, 2024
12ae2a2
merge steps again
bschimke95 Jul 3, 2024
fb0bd54
checkout repo
bschimke95 Jul 3, 2024
55374ac
remove unnecessary files
bschimke95 Jul 3, 2024
cdceb3f
use self hosted runners
bschimke95 Jul 3, 2024
10890ac
broaden self-hosted tags
bschimke95 Jul 3, 2024
1ab8070
try other tags
bschimke95 Jul 3, 2024
24a330c
another self-hosted runner config
bschimke95 Jul 4, 2024
4083966
use smaller machine
bschimke95 Jul 4, 2024
99e7b9e
install docker
bschimke95 Jul 4, 2024
c2eee34
install docker via apt
bschimke95 Jul 4, 2024
2ea4633
missing apt update
bschimke95 Jul 4, 2024
2128e97
convenience script
bschimke95 Jul 4, 2024
a739a33
update
bschimke95 Jul 4, 2024
df33e37
update
bschimke95 Jul 4, 2024
709c1c2
more docker buildx trickery
bschimke95 Jul 4, 2024
73e5866
getting there
bschimke95 Jul 4, 2024
3cc0f72
docker
bschimke95 Jul 4, 2024
9626058
remove maximize build space
bschimke95 Jul 4, 2024
34d4e6d
remove double checkout
bschimke95 Jul 4, 2024
3636278
provide kubectl
bschimke95 Jul 4, 2024
5d70501
add tmate session
bschimke95 Jul 4, 2024
bf13e22
fix tmate session
bschimke95 Jul 4, 2024
1281d5d
another fix
bschimke95 Jul 4, 2024
84766d4
fix make target
bschimke95 Jul 4, 2024
3022b79
more debugging
bschimke95 Jul 4, 2024
5aea859
gci
bschimke95 Jul 4, 2024
571edcf
docker
bschimke95 Jul 4, 2024
421c482
increase inotifier
bschimke95 Jul 4, 2024
b009865
limit test space
bschimke95 Jul 5, 2024
1f12d2d
sudo for inotifier
bschimke95 Jul 5, 2024
4a465d2
Run all tests
bschimke95 Jul 5, 2024
ff91102
another round
bschimke95 Jul 5, 2024
8b1911f
add remediation tests
bschimke95 Jul 8, 2024
e5840b6
address PR comments
bschimke95 Jul 10, 2024
f27d850
remove Go action
bschimke95 Jul 10, 2024
387dd31
remove extra assignment
bschimke95 Jul 11, 2024
8ed3b7c
update docker e2e
bschimke95 Jul 16, 2024
10393d4
docker-buildx
bschimke95 Jul 16, 2024
c309d9c
docker-buildx
bschimke95 Jul 16, 2024
fdfb365
address comments
bschimke95 Jul 16, 2024
dd1abfa
update readme and cleanup outdated sections
bschimke95 Jul 16, 2024
5e2952c
use semver package
bschimke95 Jul 17, 2024
e34ce80
update go mod
bschimke95 Jul 17, 2024
e10ebb9
remove docker
bschimke95 Jul 17, 2024
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
88 changes: 88 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: E2E Tests

on:
pull_request:

permissions:
contents: read

jobs:
build-e2e-images:
name: Build & Run E2E Images
runs-on: [self-hosted, linux, X64, jammy, xlarge]
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Install requirements
run: |
sudo apt install make
sudo snap install go --classic
bschimke95 marked this conversation as resolved.
Show resolved Hide resolved
sudo apt install docker-buildx
sudo snap install kubectl --classic
bschimke95 marked this conversation as resolved.
Show resolved Hide resolved
- name: Build provider images
run: sudo make docker-build-e2e
- name: Build k8s-snap image
run: |
cd templates/docker
sudo docker build . -t k8s-snap:dev
- name: Save provider image
run: |
sudo docker save -o provider-images.tar ghcr.io/canonical/cluster-api-k8s/controlplane-controller:dev ghcr.io/canonical/cluster-api-k8s/bootstrap-controller:dev
sudo chmod 775 provider-images.tar
- name: Save k8s-snap image
run: |
sudo docker save -o k8s-snap-image.tar k8s-snap:dev
sudo chmod 775 k8s-snap-image.tar
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: e2e-images
path: |
provider-images.tar
k8s-snap-image.tar

run-e2e-tests:
name: Run E2E Tests
runs-on: [self-hosted, linux, X64, jammy, xlarge]
needs: build-e2e-images
strategy:
matrix:
ginkgo_focus: [
"KCP remediation",
"MachineDeployment remediation",
"Workload cluster creation",
"Workload cluster scaling",
"Workload cluster upgrade",
]
bschimke95 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Install requirements
run: |
sudo apt install make
sudo snap install go --classic
bschimke95 marked this conversation as resolved.
Show resolved Hide resolved
sudo apt install docker-buildx
sudo snap install kubectl --classic
bschimke95 marked this conversation as resolved.
Show resolved Hide resolved
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: e2e-images
path: .
- name: Load provider image
run: sudo docker load -i provider-images.tar
- name: Load k8s-snap image
run: sudo docker load -i k8s-snap-image.tar
- name: Create docker network
run: |
sudo docker network create kind --driver=bridge -o com.docker.network.bridge.enable_ip_masquerade=true
- name: Increase inotify watches
run: |
# Prevents https://cluster-api.sigs.k8s.io/user/troubleshooting#cluster-api-with-docker----too-many-open-files
sudo sysctl fs.inotify.max_user_watches=1048576
sudo sysctl fs.inotify.max_user_instances=8192
- name: Run e2e tests
run: |
sudo GINKGO_FOCUS="${{ matrix.ginkgo_focus }}" SKIP_RESOURCE_CLEANUP=true make test-e2e
- name: Setup tmate session
if: ${{ failure() }}
uses: canonical/action-tmate@main
bschimke95 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ linters-settings:

- github.com/google/uuid
- github.com/pkg/errors
- sigs.k8s.io/kind/pkg/errors
gci:
sections:
- standard
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ docker-build-bootstrap-%:
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$* --build-arg package=./bootstrap/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${BOOTSTRAP_IMG}:${BOOTSTRAP_IMG_TAG}-$*
docker-build-bootstrap: manager-bootstrap docker-build-bootstrap-amd64 docker-build-bootstrap-arm64

docker-build-bootstrap-e2e: manager-bootstrap
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg package=./bootstrap/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${BOOTSTRAP_IMG}:${BOOTSTRAP_IMG_TAG}

# Push the bootstrap multiarch image
.PHONY: docker-push-bootstrap
docker-push-bootstrap-%: docker-build-bootstrap-%
Expand All @@ -266,8 +269,8 @@ test-controlplane: envtest generate-controlplane generate-controlplane-conversio
docker-build-e2e: ## Run docker-build-* targets for all the images with settings to be used for the e2e tests
# please ensure the generated image name matches image names used in the E2E_CONF_FILE
# and it also match the image tags in bootstrap/config/default and controlplane/config/default
$(MAKE) BOOTSTRAP_IMG_TAG=dev docker-build-bootstrap
$(MAKE) CONTROLPLANE_IMG_TAG=dev docker-build-controlplane
$(MAKE) BOOTSTRAP_IMG_TAG=dev docker-build-bootstrap-e2e
$(MAKE) CONTROLPLANE_IMG_TAG=dev docker-build-controlplane-e2e

.PHONY: test-e2e
test-e2e: $(GINKGO) $(KUSTOMIZE) ## Run the end-to-end tests
Expand Down Expand Up @@ -326,6 +329,9 @@ docker-build-controlplane-%:
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$* --build-arg package=./controlplane/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${CONTROLPLANE_IMG}:${CONTROLPLANE_IMG_TAG}-$*
docker-build-controlplane: manager-controlplane docker-build-controlplane-amd64 docker-build-controlplane-arm64

docker-build-controlplane-e2e: manager-controlplane
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=${ARCH} --build-arg package=./controlplane/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${CONTROLPLANE_IMG}:${CONTROLPLANE_IMG_TAG}

# Push the controlplane multiarch image
.PHONY: docker-push-controlplane
docker-push-controlplane-%: docker-build-controlplane-%
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: CK8sConfig
metadata:
name: ck8sconfig-sample
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: CK8sConfigTemplate
metadata:
name: ck8sconfigtemplate-sample
Expand Down
2 changes: 1 addition & 1 deletion controlplane/config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ patchesStrategicMerge:
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- manager_auth_proxy_patch.yaml
#- manager_auth_proxy_patch.yaml
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enabling this caused the e2e tests to fail.


# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: CK8sControlPlane
metadata:
name: ck8scontrolplane-sample
Expand Down
4 changes: 2 additions & 2 deletions docs/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The default behaviour is to `snap install k8s` using the matching track (e.g. in
You can override this behaviour by changing the default installation script by setting the following fields on the config template:

```yaml
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: CK8sControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
Expand Down Expand Up @@ -47,7 +47,7 @@ For airgap deployments, or environment you can specify `airGapped: true` to prev
Any extra yaml files placed in `/capi/manifests` will be applied once on the cluster after bootstrapping. Files are applied in alphabetical order, so you can use this in case of dependencies. Example:

```yaml
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: CK8sControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
Expand Down
Loading