Skip to content

Commit 3352876

Browse files
add e2e tests for multigroup testdata layout and rename sample
We need to rename the name of the sample because of: ```shell The Service "project-v4-multigroup-with-plugins-controller-manager-metrics-service" is invalid: metadata.name: Invalid value: "project-v4-multigroup-with-plugins-controller-manager-metrics-service": must be no more than 63 characters ``` Therefore, in this we are: - Creating jobs to run the e2e tests for all testdata samples in parallel - Renaming the sample project-v4-multigroup-with-plugins to project-v4-multigroup to generate manifests names that can be accepted in k8s
1 parent 29a22d1 commit 3352876

File tree

184 files changed

+318
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+318
-254
lines changed

.github/workflows/test-e2e-samples.yml

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
name: Testing E2E Sample
1+
name: E2E Testdata Sample
22

33
on:
44
push:
5-
paths-ignore:
6-
- '**/*.md'
5+
paths:
6+
- 'testdata/**'
7+
- '.github/workflows/test-e2e-samples.yml'
78
pull_request:
8-
paths-ignore:
9-
- '**/*.md'
9+
paths:
10+
- 'testdata/**'
11+
- '.github/workflows/test-e2e-samples.yml'
1012

1113
jobs:
12-
e2e-tests:
14+
e2e-tests-project-v4:
1315
runs-on: ubuntu-latest
14-
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
16+
strategy:
17+
fail-fast: true
1518
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
1619
steps:
1720
- name: Checkout repository
@@ -48,8 +51,28 @@ jobs:
4851
run: |
4952
make test-e2e
5053
51-
- name: Teardown kind cluster
52-
run: kind delete cluster
54+
e2e-tests-project-v4-with-plugins:
55+
runs-on: ubuntu-latest
56+
strategy:
57+
fail-fast: true
58+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
63+
- name: Setup Go
64+
uses: actions/setup-go@v5
65+
with:
66+
go-version: '~1.22'
67+
68+
- name: Install the latest version of kind
69+
run: |
70+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
71+
chmod +x ./kind
72+
sudo mv ./kind /usr/local/bin/kind
73+
74+
- name: Verify kind installation
75+
run: kind version
5376

5477
- name: Create kind cluster
5578
run: kind create cluster
@@ -62,7 +85,6 @@ jobs:
6285
# Uncomment only ValidatingWebhookConfiguration
6386
# from cert-manager replaces
6487
sed -i '55,70s/^#//' $KUSTOMIZATION_FILE_PATH
65-
sed -i '55,70s/^#//' $KUSTOMIZATION_FILE_PATH
6688
sed -i '79,101s/^#//' $KUSTOMIZATION_FILE_PATH
6789
sed -i '110,151s/^#//' $KUSTOMIZATION_FILE_PATH
6890
# Comment the injection for MutatingWebhookConfiguration
@@ -74,6 +96,46 @@ jobs:
7496
go mod tidy
7597
7698
- name: Testing make test-e2e for project-v4-with-plugins
77-
working-directory: testdata/project-v4-with-plugins
99+
working-directory: testdata/project-v4-with-plugins/
78100
run: |
79101
make test-e2e
102+
103+
e2e-tests-project-v4-multigroup:
104+
runs-on: ubuntu-latest
105+
strategy:
106+
fail-fast: true
107+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
108+
steps:
109+
- name: Checkout repository
110+
uses: actions/checkout@v4
111+
112+
- name: Setup Go
113+
uses: actions/setup-go@v5
114+
with:
115+
go-version: '~1.22'
116+
117+
- name: Install the latest version of kind
118+
run: |
119+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
120+
chmod +x ./kind
121+
sudo mv ./kind /usr/local/bin/kind
122+
123+
- name: Verify kind installation
124+
run: kind version
125+
126+
- name: Create kind cluster
127+
run: kind create cluster
128+
129+
- name: Prepare project-v4-multigroup
130+
run: |
131+
KUSTOMIZATION_FILE_PATH="testdata/project-v4-multigroup/config/default/kustomization.yaml"
132+
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
133+
sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH
134+
sed -i '55,151s/^#//' $KUSTOMIZATION_FILE_PATH
135+
cd testdata/project-v4-multigroup
136+
go mod tidy
137+
138+
- name: Testing make test-e2e for project-v4-multigroup
139+
working-directory: testdata/project-v4-multigroup/
140+
run: |
141+
make test-e2e

test/testdata/generate.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ function scaffold_test_project {
8080
$kb edit --plugins=grafana.kubebuilder.io/v1-alpha
8181
fi
8282

83+
make all
8384
make build-installer
85+
# To avoid conflicts
8486
rm -f go.sum
8587
go mod tidy
8688
popd
@@ -89,5 +91,5 @@ function scaffold_test_project {
8991
build_kb
9092

9193
scaffold_test_project project-v4 --plugins="go/v4"
92-
scaffold_test_project project-v4-multigroup-with-plugins --plugins="go/v4"
94+
scaffold_test_project project-v4-multigroup --plugins="go/v4"
9395
scaffold_test_project project-v4-with-plugins --plugins="go/v4"

test/testdata/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ build_kb
3232

3333
# Project version v4-alpha
3434
test_project project-v4
35-
test_project project-v4-multigroup-with-plugins
35+
test_project project-v4-multigroup
3636
test_project project-v4-with-plugins

testdata/project-v4-multigroup-with-plugins/Makefile renamed to testdata/project-v4-multigroup/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
120120
docker-buildx: ## Build and push docker image for the manager for cross-platform support
121121
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
122122
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
123-
- $(CONTAINER_TOOL) buildx create --name project-v4-multigroup-with-plugins-builder
124-
$(CONTAINER_TOOL) buildx use project-v4-multigroup-with-plugins-builder
123+
- $(CONTAINER_TOOL) buildx create --name project-v4-multigroup-builder
124+
$(CONTAINER_TOOL) buildx use project-v4-multigroup-builder
125125
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
126-
- $(CONTAINER_TOOL) buildx rm project-v4-multigroup-with-plugins-builder
126+
- $(CONTAINER_TOOL) buildx rm project-v4-multigroup-builder
127127
rm Dockerfile.cross
128128

129129
.PHONY: build-installer

0 commit comments

Comments
 (0)