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

Adding an E2E test that runs a full CAPL cluster test (default, k3s, & rke2) on merging to main #266

Merged
merged 54 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
471e7b1
Save progress
komer3 Apr 18, 2024
54b63e0
Working tests
komer3 Apr 18, 2024
5d70665
updates
komer3 Apr 22, 2024
937dcf6
Change name
komer3 Apr 22, 2024
dcce13f
Comments
komer3 Apr 22, 2024
307acb5
Merge branch 'main' into main-merge-e2e
komer3 Apr 22, 2024
9c0897b
fix
komer3 Apr 22, 2024
015839f
Saving
komer3 Apr 23, 2024
98e04b5
Merge branch 'main' into main-merge-e2e
komer3 Apr 23, 2024
eb52636
Updates
komer3 Apr 24, 2024
5a1a717
saving changes
komer3 Apr 25, 2024
6c39b25
Revert "Updates"
komer3 Apr 25, 2024
685f58d
add changes back
komer3 Apr 25, 2024
77f7adf
Save checkpoint
komer3 Apr 25, 2024
866a0cc
Adding fixes and temp changes to GHA to test e2e tests
komer3 Apr 25, 2024
a493714
Fix
komer3 Apr 25, 2024
9b07a4a
fix
komer3 Apr 25, 2024
7cde9f6
fix
komer3 Apr 25, 2024
fb3cab8
Small fix
komer3 Apr 26, 2024
7b7a831
Test
komer3 Apr 26, 2024
010a3c8
Small change
komer3 Apr 26, 2024
c0f2f86
Small change
komer3 Apr 26, 2024
4576c18
Add allowed endpoint
komer3 Apr 26, 2024
efeea5f
increase assert time
komer3 Apr 26, 2024
320d321
Test
komer3 Apr 26, 2024
f0df2a7
test
komer3 Apr 26, 2024
931f767
fix
komer3 Apr 26, 2024
db97cf0
Merge branch 'main' into main-merge-e2e
komer3 Apr 26, 2024
e5acb2e
fix
komer3 Apr 26, 2024
2496bb6
Fix
komer3 Apr 26, 2024
0e4a9ff
test
komer3 Apr 26, 2024
16efd42
Run all flavors
komer3 Apr 26, 2024
f500583
add rke2 provider to clusterctl config
komer3 Apr 26, 2024
91a0679
Fix rke2
komer3 Apr 26, 2024
02166b5
Delete VPCs
komer3 Apr 26, 2024
7743140
fix
komer3 Apr 26, 2024
c22e5f4
assert timeout 12 mins
komer3 Apr 26, 2024
b684463
Try 20mins assert timeout
komer3 Apr 26, 2024
49c4679
timeout upped to 30 mins
komer3 Apr 26, 2024
ae004f8
Add catch blocks for debugging
komer3 Apr 29, 2024
4509b88
Merge branch 'main' into main-merge-e2e
komer3 Apr 29, 2024
2d3bf4f
switch harden runner policy
komer3 Apr 29, 2024
a6133a4
Run all tests
komer3 Apr 29, 2024
dacb914
Testing default
komer3 Apr 29, 2024
8480546
Fix plus egress-block set to true
komer3 Apr 29, 2024
1f44134
merge main
komer3 Apr 29, 2024
6ee9c79
run all tests
komer3 Apr 29, 2024
369cd1d
Clean up and docs
komer3 Apr 30, 2024
4a3ef4f
Merge branch 'main' into main-merge-e2e
komer3 Apr 30, 2024
a80d4fb
Remove rke-cluster file
komer3 Apr 30, 2024
8b445b2
clean up
komer3 Apr 30, 2024
acc8b58
Add tiltfile back :)
komer3 Apr 30, 2024
009cf87
adeodhar: add try catch block
amold1 Apr 30, 2024
f6425ba
Making e2etest run all the tests by default
komer3 May 1, 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
31 changes: 27 additions & 4 deletions .github/workflows/build_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ jobs:
needs: [go-build-test, docker-build]
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
disable-sudo: true
egress-policy: block
egress-policy: audit
allowed-endpoints: >
api.linode.com:443
api.github.com:443
github.com:443
gcr.io:443
ghcr.io:443
proxy.golang.org:443
sum.golang.org:443
*.githubusercontent.com:443
Expand Down Expand Up @@ -117,11 +121,30 @@ jobs:
with:
key: docker-${{ runner.os }}-${{ hashFiles('go.sum') }}

- name: E2E test
- name: Complete E2E Test
if: github.ref == 'refs/heads/main'
run: make e2etest
env:
INSTALL_K3S_PROVIDER: true
eljohnson92 marked this conversation as resolved.
Show resolved Hide resolved
INSTALL_RKE2_PROVIDER: true
LINODE_REGION: us-sea
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
LINODE_MACHINE_TYPE: g6-standard-2
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/clusterctl-config.yaml


- name: Quick E2E Test
run: make e2etest
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
# TODO: Switch selector to quick before the PR can be merged
E2E_FLAGS: '--assert-timeout 15m0s --selector rke2'
komer3 marked this conversation as resolved.
Show resolved Hide resolved
# TODO: ALL the var below need to be deleted before the PR can be merged
INSTALL_K3S_PROVIDER: true
INSTALL_RKE2_PROVIDER: true
LINODE_REGION: us-sea
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
LINODE_MACHINE_TYPE: g6-standard-2
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/clusterctl-config.yaml

- name: Copy logs
if: ${{ always() }}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ test: generate fmt vet envtest ## Run tests.
rm cover.out.tmp

.PHONY: e2etest
e2etest: generate local-deploy chainsaw
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e
e2etest: generate local-release local-deploy chainsaw
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e $(E2E_FLAGS)

local-deploy: kind ctlptl tilt kustomize clusterctl
@echo -n "LINODE_TOKEN=$(LINODE_TOKEN)" > config/default/.env.linode
Expand Down
16 changes: 16 additions & 0 deletions e2e/clusterctl-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
providers:
- name: local-linode
url: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/infrastructure-local-linode/v0.0.0/infrastructure-components.yaml
type: InfrastructureProvider
- name: "k3s"
url: https://github.com/k3s-io/cluster-api-k3s/releases/latest/bootstrap-components.yaml
type: "BootstrapProvider"
- name: "k3s"
url: https://github.com/k3s-io/cluster-api-k3s/releases/latest/control-plane-components.yaml
type: "ControlPlaneProvider"
- name: "rke2"
eljohnson92 marked this conversation as resolved.
Show resolved Hide resolved
url: "https://github.com/rancher-sandbox/cluster-api-provider-rke2/releases/latest/bootstrap-components.yaml"
type: "BootstrapProvider"
- name: "rke2"
url: "https://github.com/rancher-sandbox/cluster-api-provider-rke2/releases/latest/control-plane-components.yaml"
type: "ControlPlaneProvider"
39 changes: 39 additions & 0 deletions e2e/default-CAPL-cluster/assert-capi-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: capi-controller-manager
namespace: capi-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: capl-controller-manager
namespace: capl-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: capi-kubeadm-bootstrap-controller-manager
namespace: kubeadm-bootstrap-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: capi-kubeadm-control-plane-controller-manager
namespace: kubeadm-control-plane-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: caaph-controller-manager
namespace: caaph-system
status:
availableReplicas: 1
94 changes: 94 additions & 0 deletions e2e/default-CAPL-cluster/assert-child-cluster-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeMachine
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
spec:
region: (env('LINODE_REGION'))
type: g6-standard-2
status:
ready: true
instanceState: running
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Machine
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
spec:
clusterName: ($cluster)
status:
bootstrapReady: true
infrastructureReady: true
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
spec:
clusterName: ($cluster)
replicas: 1
status:
readyReplicas: 1
unavailableReplicas: 0
availableReplicas: 1
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
status:
readyReplicas: 1
unavailableReplicas: 0
ready: true
---
apiVersion: addons.cluster.x-k8s.io/v1alpha1
kind: HelmReleaseProxy
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
helmreleaseproxy.addons.cluster.x-k8s.io/helmchartproxy-name: linode-cloud-controller-manager
status:
conditions:
- type: Ready
status: "True"
- type: ClusterAvailable
status: "True"
- type: HelmReleaseReady
status: "True"
status: deployed
---
apiVersion: addons.cluster.x-k8s.io/v1alpha1
kind: HelmReleaseProxy
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
helmreleaseproxy.addons.cluster.x-k8s.io/helmchartproxy-name: cilium
status:
conditions:
- type: Ready
status: "True"
- type: ClusterAvailable
status: "True"
- type: HelmReleaseReady
status: "True"
status: deployed
---
apiVersion: addons.cluster.x-k8s.io/v1alpha1
kind: HelmReleaseProxy
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
helmreleaseproxy.addons.cluster.x-k8s.io/helmchartproxy-name: csi-driver-linode
status:
conditions:
- type: Ready
status: "True"
- type: ClusterAvailable
status: "True"
- type: HelmReleaseReady
status: "True"
status: deployed
122 changes: 122 additions & 0 deletions e2e/default-CAPL-cluster/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
creationTimestamp: null
name: default-capl-cluster
# Labels to allow the test to be triggered based on selector flag
labels:
default-cluster:
flavors:
spec:
bindings:
# A short identifier for the E2E test run
- name: run
value: (join('-', ['e2e', 'default-cluster', env('GIT_REF')]))
- name: cluster
# Format the cluster name
value: (trim((truncate(($run), `32`)), '-'))
template: true
steps:
- name: Check if CAPI provider resources exist
try:
- assert:
file: assert-capi-resources.yaml
- name: Generate cluster using clusterctl
try:
- script:
env:
- name: CLUSTER
value: ($cluster)
- name: NAMESPACE
value: ($namespace)
- name: CLUSTERCTL_CONFIG
value: (env('CLUSTERCTL_CONFIG'))
content: |
set -e
clusterctl generate cluster $CLUSTER -n $NAMESPACE \
--kubernetes-version v1.29.1 \
--infrastructure local-linode:v0.0.0 \
--control-plane-machine-count 1 --worker-machine-count 1 \
--config $CLUSTERCTL_CONFIG > default-cluster.yaml
check:
($error == null): true
- name: Apply generated cluster yaml
try:
- apply:
file: default-cluster.yaml
- assert:
file: assert-child-cluster-resources.yaml
catch:
- events:
namespace: ($namespace)
- get:
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
- name: Check if the linodes are created
try:
- script:
env:
- name: TARGET_API
value: api.linode.com
- name: TARGET_API_VERSION
value: v4beta
- name: URI
value: linode/instances
- name: FILTER
value: (to_string({"tags":($cluster)}))
content: |
set -e
curl -s \
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
check:
($error): ~
(json_parse($stdout)):
results: 2
- name: Delete child cluster
try:
- delete:
ref:
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
name: ($cluster)
- delete:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeVPC
name: ($cluster)
- error:
file: check-child-cluster-and-vpc-deleted.yaml
- name: Check if the linodes are deleted
try:
- script:
env:
- name: TARGET_API
value: api.linode.com
- name: TARGET_API_VERSION
value: v4beta
- name: URI
value: linode/instances
- name: FILTER
value: (to_string({"tags":($cluster)}))
content: |
set -e
curl -s \
-H "Authorization: Bearer $LINODE_TOKEN" \
-H "X-Filter: $FILTER" \
-H "Content-Type: application/json" \
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
check:
($error): ~
(json_parse($stdout)):
results: 0
- name: Delete generated child cluster manifest yaml
try:
- script:
content: |
rm -f default-cluster.yaml
check:
($error == null): true
10 changes: 10 additions & 0 deletions e2e/default-CAPL-cluster/check-child-cluster-and-vpc-deleted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeMachine
metadata:
labels:
cluster.x-k8s.io/cluster-name: ($cluster)
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeVPC
metadata:
name: ($cluster)
31 changes: 31 additions & 0 deletions e2e/k3s-capl-cluster/assert-capi-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: capi-controller-manager
namespace: capi-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: capl-controller-manager
namespace: capl-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: capi-k3s-bootstrap-controller-manager
namespace: capi-k3s-bootstrap-system
status:
availableReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: capi-k3s-control-plane-controller-manager
namespace: capi-k3s-control-plane-system
status:
availableReplicas: 1
Loading
Loading