Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 04ff9ee

Browse files
authored
test(e2e): Add AWS e2e tests (nutanix-cloud-native#408)
1 parent 2035047 commit 04ff9ee

25 files changed

+495
-193
lines changed
File renamed without changes.

.github/workflows/checks.yml

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -55,46 +55,17 @@ jobs:
5555
test-results: test.json
5656

5757
e2e-test:
58-
runs-on: ubuntu-22.04
59-
permissions:
60-
checks: write
6158
strategy:
6259
matrix:
63-
PROVIDER:
60+
provider:
6461
- Docker
65-
steps:
66-
- name: Check out code
67-
uses: actions/checkout@v4
68-
with:
69-
fetch-depth: 0
70-
71-
- name: Install devbox
72-
uses: jetpack-io/[email protected]
73-
with:
74-
enable-cache: true
75-
76-
- name: Go cache
77-
uses: actions/cache@v4
78-
with:
79-
path: |
80-
~/.cache/go-build
81-
~/go/pkg/mod
82-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
83-
restore-keys: |
84-
${{ runner.os }}-go-
85-
86-
- name: Run e2e tests
87-
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ matrix.PROVIDER }}'
88-
env:
89-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90-
91-
- if: success() || failure() # always run even if the previous step fails
92-
name: Publish e2e test report
93-
uses: mikepenz/action-junit-report@v4
94-
with:
95-
report_paths: 'junit-e2e.xml'
96-
check_name: 'e2e test report'
97-
detailed_summary: true
62+
uses: ./.github/workflows/e2e.yml
63+
with:
64+
provider: ${{ matrix.provider }}
65+
secrets: inherit
66+
permissions:
67+
contents: read
68+
checks: write
9869

9970
lint-go:
10071
runs-on: ubuntu-22.04

.github/workflows/e2e.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2024 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
provider:
8+
description: Infrastructure provider to run e2e tests with
9+
type: string
10+
required: true
11+
12+
jobs:
13+
e2e-test:
14+
runs-on: ubuntu-22.04
15+
permissions:
16+
contents: read
17+
checks: write
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Install devbox
25+
uses: jetpack-io/[email protected]
26+
with:
27+
enable-cache: true
28+
29+
- name: Go cache
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
~/.cache/go-build
34+
~/go/pkg/mod
35+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
36+
restore-keys: |
37+
${{ runner.os }}-go-
38+
39+
- name: Run e2e tests
40+
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}'
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- if: success() || failure() # always run even if the previous step fails
45+
name: Publish e2e test report
46+
uses: mikepenz/action-junit-report@v4
47+
with:
48+
report_paths: 'junit-e2e.xml'
49+
check_name: 'e2e test report'
50+
detailed_summary: true
51+
require_passed_tests: true

charts/capi-runtime-extensions/defaultclusterclasses/aws-cluster-class.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ spec:
3333
- jsonPatches:
3434
- op: add
3535
path: /spec/template/spec/identityRef
36-
valueFrom:
37-
template: |
38-
kind: AWSClusterStaticIdentity
39-
name: {{ .builtin.cluster.name }}
36+
value:
37+
kind: AWSClusterControllerIdentity
38+
name: default
4039
selector:
4140
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
4241
kind: AWSClusterTemplate

devbox.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"shfmt@latest",
3232
"yamale@latest",
3333
"yamllint@latest",
34+
"path:./hack/flakes#clusterawsadm",
3435
"path:./hack/flakes#goprintconst",
3536
"path:./hack/flakes#go-mod-upgrade",
3637
"path:./hack/flakes#golangci-lint",

docs/content/contributing/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
title = "Contributing"
3+
weight = 99
4+
icon = "fa-solid fa-gift"
5+
+++
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
+++
2+
title = "End-to-end tests"
3+
+++
4+
5+
This project uses [Ginkgo] to run end-to-end tests. Tests are labelled to make running targeted or specific tests
6+
easier.
7+
8+
To determine what labels are available, run:
9+
10+
```shell
11+
ginkgo --dry-run -v -tags e2e ./test/e2e
12+
```
13+
14+
Tests are currently labelled via infrastructure provider, CNI provider, and addon strategy. Here are some examples to
15+
specify what tests to run.
16+
17+
Run all AWS tests:
18+
19+
```shell
20+
make e2e-test E2E_LABEL='provider:AWS'
21+
```
22+
23+
Run all Cilium tests:
24+
25+
```shell
26+
make e2e-test E2E_LABEL='cni:Cilium'
27+
```
28+
29+
Labels can also be combined.
30+
31+
Run Cilium tests on AWS:
32+
33+
```shell
34+
make e2e-test E2E_LABEL='provider:AWS && cni:Cilium'
35+
```
36+
37+
To make debugging easier, you can retain the e2e test environment, which by default is cleaned up after tests run:
38+
39+
```shell
40+
make e2e-test E2E_LABEL='provider:AWS && cni:Cilium' E2E_SKIP_CLEANUP=true
41+
```
42+
43+
To speed up the development process, if you have only change e2e tests then you can skip rebuilding the whole project:
44+
45+
```shell
46+
make e2e-test E2E_LABEL='provider:AWS && cni:Cilium' SKIP_BUILD=true
47+
```
48+
49+
[Ginkgo]: https://onsi.github.io/ginkgo/

examples/capi-quick-start/aws-cluster-calico-crs.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ spec:
3232
strategy: ClusterResourceSet
3333
aws:
3434
region: us-west-2
35+
controlPlane:
36+
aws:
37+
ami:
38+
lookup:
39+
baseOS: ${AMI_LOOKUP_BASEOS}
40+
format: ${AMI_LOOKUP_FORMAT}
41+
org: "${AMI_LOOKUP_ORG}"
42+
- name: workerConfig
43+
value:
44+
aws:
45+
ami:
46+
lookup:
47+
baseOS: ${AMI_LOOKUP_BASEOS}
48+
format: ${AMI_LOOKUP_FORMAT}
49+
org: "${AMI_LOOKUP_ORG}"
3550
version: ${KUBERNETES_VERSION}
3651
workers:
3752
machineDeployments:

examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ spec:
3232
strategy: HelmAddon
3333
aws:
3434
region: us-west-2
35+
controlPlane:
36+
aws:
37+
ami:
38+
lookup:
39+
baseOS: ${AMI_LOOKUP_BASEOS}
40+
format: ${AMI_LOOKUP_FORMAT}
41+
org: "${AMI_LOOKUP_ORG}"
42+
- name: workerConfig
43+
value:
44+
aws:
45+
ami:
46+
lookup:
47+
baseOS: ${AMI_LOOKUP_BASEOS}
48+
format: ${AMI_LOOKUP_FORMAT}
49+
org: "${AMI_LOOKUP_ORG}"
3550
version: ${KUBERNETES_VERSION}
3651
workers:
3752
machineDeployments:

examples/capi-quick-start/aws-cluster-cilium-crs.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ spec:
3232
strategy: ClusterResourceSet
3333
aws:
3434
region: us-west-2
35+
controlPlane:
36+
aws:
37+
ami:
38+
lookup:
39+
baseOS: ${AMI_LOOKUP_BASEOS}
40+
format: ${AMI_LOOKUP_FORMAT}
41+
org: "${AMI_LOOKUP_ORG}"
42+
- name: workerConfig
43+
value:
44+
aws:
45+
ami:
46+
lookup:
47+
baseOS: ${AMI_LOOKUP_BASEOS}
48+
format: ${AMI_LOOKUP_FORMAT}
49+
org: "${AMI_LOOKUP_ORG}"
3550
version: ${KUBERNETES_VERSION}
3651
workers:
3752
machineDeployments:

examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ spec:
3232
strategy: HelmAddon
3333
aws:
3434
region: us-west-2
35+
controlPlane:
36+
aws:
37+
ami:
38+
lookup:
39+
baseOS: ${AMI_LOOKUP_BASEOS}
40+
format: ${AMI_LOOKUP_FORMAT}
41+
org: "${AMI_LOOKUP_ORG}"
42+
- name: workerConfig
43+
value:
44+
aws:
45+
ami:
46+
lookup:
47+
baseOS: ${AMI_LOOKUP_BASEOS}
48+
format: ${AMI_LOOKUP_FORMAT}
49+
org: "${AMI_LOOKUP_ORG}"
3550
version: ${KUBERNETES_VERSION}
3651
workers:
3752
machineDeployments:

hack/examples/bases/aws/kustomization.yaml.tmpl

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ patches:
3232
path: "/spec/topology/variables/0/value/aws"
3333
value:
3434
region: us-west-2
35+
- op: "add"
36+
path: "/spec/topology/variables/0/value/controlPlane"
37+
value:
38+
aws:
39+
ami:
40+
lookup:
41+
format: "$${AMI_LOOKUP_FORMAT}"
42+
org: "$${AMI_LOOKUP_ORG}"
43+
baseOS: "$${AMI_LOOKUP_BASEOS}"
44+
- op: "add"
45+
path: "/spec/topology/variables/-"
46+
value:
47+
name: "workerConfig"
48+
value:
49+
aws:
50+
ami:
51+
lookup:
52+
format: "$${AMI_LOOKUP_FORMAT}"
53+
org: "$${AMI_LOOKUP_ORG}"
54+
baseOS: "$${AMI_LOOKUP_BASEOS}"
3555
- op: "add"
3656
path: "/spec/topology/variables/0/value/addons/cpi"
3757
value: {}
@@ -62,35 +82,28 @@ patches:
6282
- op: "add"
6383
path: "/spec/patches"
6484
value:
85+
- name: "cluster-config"
86+
external:
87+
generateExtension: "awsclusterconfigpatch.capi-runtime-extensions"
88+
discoverVariablesExtension: "awsclusterconfigvars.capi-runtime-extensions"
89+
- name: "worker-config"
90+
external:
91+
generateExtension: "awsworkerconfigpatch.capi-runtime-extensions"
92+
discoverVariablesExtension: "awsworkerconfigvars.capi-runtime-extensions"
6593
- name: identityRef
6694
definitions:
6795
- jsonPatches:
6896
- op: add
6997
path: /spec/template/spec/identityRef
70-
valueFrom:
71-
template: |
72-
kind: AWSClusterStaticIdentity
73-
name: {{ .builtin.cluster.name }}
98+
value:
99+
kind: AWSClusterControllerIdentity
100+
name: default
74101
selector:
75102
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
76103
kind: AWSClusterTemplate
77104
matchResources:
78105
infrastructureCluster: true
79106
description: AWSClusterStaticIdentity identityRef to use when creating the cluster
80-
- op: "add"
81-
path: "/spec/patches/0"
82-
value:
83-
name: "cluster-config"
84-
external:
85-
generateExtension: "awsclusterconfigpatch.capi-runtime-extensions"
86-
discoverVariablesExtension: "awsclusterconfigvars.capi-runtime-extensions"
87-
- op: "add"
88-
path: "/spec/patches/1"
89-
value:
90-
name: "worker-config"
91-
external:
92-
generateExtension: "awsworkerconfigpatch.capi-runtime-extensions"
93-
discoverVariablesExtension: "awsworkerconfigvars.capi-runtime-extensions"
94107
- op: "remove"
95108
path: "/spec/variables"
96109
- target:

hack/examples/sync.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ kustomize build ./hack/examples |
102102
) \
103103
>/dev/null
104104

105-
sed -i'' "s/^ name: .\+$/ name: \${CLUSTER_NAME}/" "${EXAMPLE_CLUSTERS_DIR}"/*.yaml
105+
#shellcheck disable=SC2016
106+
sed -i'' 's/^ name: .\+$/ name: ${CLUSTER_NAME}/' "${EXAMPLE_CLUSTERS_DIR}"/*.yaml
107+
108+
# TODO Remove once kustomize supports retaining quotes in what will be numeric values.
109+
#shellcheck disable=SC2016
110+
sed -i'' 's/${AMI_LOOKUP_ORG}/"${AMI_LOOKUP_ORG}"/' "${EXAMPLE_CLUSTERS_DIR}"/*.yaml
106111

107112
# TODO Remove once CAPA templates default to using external cloud provider.
108113
sed -i'' 's/cloud-provider:\ aws/cloud-provider:\ external/g' "${EXAMPLE_CLUSTERCLASSES_DIR}/aws-cluster-class.yaml"

hack/flakes/flake.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@
5656
vendorHash = null;
5757
ldflags = [ "-s" "-w" ];
5858
};
59+
60+
clusterawsadm = buildGo120Module rec {
61+
name = "clusterawsadm";
62+
version = "2.3.1";
63+
src = fetchFromGitHub {
64+
owner = "kubernetes-sigs";
65+
repo = "cluster-api-provider-aws";
66+
rev = "v${version}";
67+
hash = "sha256-5SWi23h7Wvkbha2RTE8gMec7sKnHVTrbtTwF646Mml0=";
68+
};
69+
doCheck = false;
70+
subPackages = [ "cmd/clusterawsadm" ];
71+
vendorHash = "sha256-1osn61l9f6lGiDSnvFZJbFXD4dxWKB6qH2ETop9hQRU=";
72+
ldflags = [ "-s" "-w" ];
73+
};
5974
};
6075

6176
formatter = alejandra;

make/clusterctl.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ clusterctl.init:
77
EXP_RUNTIME_SDK=true \
88
EXP_CLUSTER_RESOURCE_SET=true \
99
EXP_MACHINE_POOL=true \
10-
AWS_B64ENCODED_CREDENTIALS= \
10+
AWS_B64ENCODED_CREDENTIALS=$$(clusterawsadm bootstrap credentials encode-as-profile) \
1111
clusterctl init \
1212
--kubeconfig=$(KIND_KUBECONFIG) \
1313
--infrastructure docker,aws \

0 commit comments

Comments
 (0)