Skip to content

Commit 4a30e00

Browse files
authored
chore(ci): v3 e2e test headless online (#3258)
* chore(ci): v3 e2e test headless * f * f * f * f * f * f * f * f * f * f * f * f * f * f * f * f * enable v3 * debug * f * f * f * f * f * f * f * f * no airgap * f
1 parent f76601b commit 4a30e00

File tree

34 files changed

+2293
-534
lines changed

34 files changed

+2293
-534
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ jobs:
290290
uses: actions/cache@v4
291291
with:
292292
path: |
293-
./dev/.gocache
294-
./dev/.gomodcache
293+
./dev/build/.gocache
294+
./dev/build/.gomodcache
295295
key: dryrun-tests-go-cache-${{ hashFiles('**/go.sum') }}
296296
restore-keys: |
297297
dryrun-tests-go-cache-

.github/workflows/v3-e2e.yaml

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
name: V3 E2E
2+
3+
on:
4+
pull_request:
5+
paths: &paths
6+
- .github/workflows/v3-e2e.yaml
7+
- api/**
8+
- cmd/**
9+
- dagger/**
10+
- e2e/kots-release-install-v3/**
11+
- e2e/licenses/ci-v3.yaml
12+
- kinds/**
13+
- local-artifact-mirror/**
14+
- operator/**
15+
- pkg/**
16+
- pkg-new/**
17+
- scripts/**
18+
- utils/**
19+
- web/**
20+
- common.mk
21+
- dagger.json
22+
- go.mod
23+
- go.sum
24+
- Makefile
25+
- versions.mk
26+
27+
push:
28+
branches:
29+
- main
30+
paths: *paths
31+
32+
concurrency:
33+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
34+
cancel-in-progress: true
35+
36+
permissions:
37+
contents: write
38+
39+
jobs:
40+
output-vars:
41+
name: Output variables
42+
runs-on: ubuntu-latest
43+
outputs:
44+
git_version: ${{ steps.output_vars.outputs.git_version }}
45+
k0s_minor_version: ${{ steps.output_vars.outputs.k0s_minor_version }}
46+
ec_version: ${{ steps.output_vars.outputs.ec_version }}
47+
app_version: ${{ steps.output_vars.outputs.app_version }}
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v6
51+
with:
52+
fetch-depth: 0 # necessary for getting the last tag
53+
54+
- name: Get git sha
55+
id: git_sha
56+
uses: ./.github/actions/git-sha
57+
58+
- name: Output variables
59+
id: output_vars
60+
run: |
61+
GIT_VERSION=$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')
62+
echo "GIT_VERSION=\"$GIT_VERSION\""
63+
echo "git_version=$GIT_VERSION" >> $GITHUB_OUTPUT
64+
65+
K0S_MINOR_VERSION=$(make print-K0S_MINOR_VERSION)
66+
echo "K0S_MINOR_VERSION=\"$K0S_MINOR_VERSION\""
67+
echo "k0s_minor_version=$K0S_MINOR_VERSION" >> $GITHUB_OUTPUT
68+
69+
EC_VERSION="$(./scripts/print-ec-version.sh "$GIT_VERSION" "$K0S_MINOR_VERSION")-v3"
70+
echo "EC_VERSION=\"$EC_VERSION\""
71+
echo "ec_version=$EC_VERSION" >> $GITHUB_OUTPUT
72+
73+
APP_VERSION="appver-dev-v3-${{ steps.git_sha.outputs.git_sha }}"
74+
echo "APP_VERSION=\"$APP_VERSION\""
75+
echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
76+
77+
build-release:
78+
name: Build release
79+
needs:
80+
- output-vars
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v6
85+
86+
- name: Cache embedded bins
87+
uses: actions/cache@v4
88+
with:
89+
path: |
90+
output/bins
91+
key: bins-cache-${{ hashFiles('Makefile', 'versions.mk') }}
92+
restore-keys: |
93+
bins-cache-
94+
95+
- name: Setup go
96+
uses: actions/setup-go@v6
97+
with:
98+
go-version-file: go.mod
99+
cache-dependency-path: "**/*.sum"
100+
101+
- name: Setup node
102+
uses: actions/setup-node@v6
103+
with:
104+
node-version-file: ./web/.nvmrc
105+
106+
- name: Setup oras
107+
uses: oras-project/setup-oras@v1
108+
109+
- name: Setup crane
110+
uses: imjasonh/setup-crane@v0.4
111+
112+
- name: Setup dagger
113+
run: |
114+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
115+
sudo mv ./bin/dagger /usr/local/bin/dagger
116+
117+
- name: Setup replicated cli
118+
env:
119+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
run: |
121+
gh release download --repo replicatedhq/replicated --pattern '*linux_amd64.tar.gz' --output replicated.tar.gz
122+
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
123+
mv replicated /usr/local/bin/replicated
124+
125+
- name: Free up runner disk space # this is much faster than .github/actions/free-disk-space
126+
run: |
127+
df -h
128+
sudo rm -rf \
129+
/usr/share/swift \
130+
/usr/share/dotnet \
131+
/usr/lib/jvm \
132+
/usr/local/share/boost \
133+
/usr/local/lib/heroku \
134+
/usr/local/julia* \
135+
/usr/local/.ghcup \
136+
/usr/local/share/powershell \
137+
/usr/local/bin/aliyun \
138+
/usr/local/bin/azcopy \
139+
/usr/local/bin/bicep \
140+
/usr/local/bin/cpack \
141+
/usr/local/bin/hub \
142+
/usr/local/bin/minikube \
143+
/usr/local/bin/packer \
144+
/usr/local/bin/pulumi* \
145+
/usr/local/bin/sam \
146+
/usr/local/bin/stack \
147+
/usr/local/bin/terraform \
148+
/usr/local/bin/oc
149+
df -h
150+
151+
- name: Build release
152+
env:
153+
K0S_MINOR_VERSION: "${{ needs.output-vars.outputs.k0s_minor_version }}"
154+
VERSION: "${{ needs.output-vars.outputs.git_version }}"
155+
EC_VERSION: ${{ needs.output-vars.outputs.ec_version }}
156+
APP_VERSION: ${{ needs.output-vars.outputs.app_version }}
157+
APP_CHANNEL: CI-V3
158+
APP_CHANNEL_ID: 36LoGcOOLvEPFXQXCUsFub28Abi
159+
APP_CHANNEL_SLUG: ci-v3
160+
AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_KEY_ID }}
161+
AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }}
162+
AWS_REGION: "us-east-1"
163+
S3_BUCKET: tf-staging-embedded-cluster-bin
164+
REPLICATED_API_TOKEN: ${{ secrets.STAGING_REPLICATED_API_TOKEN }}
165+
USE_CHAINGUARD: "1"
166+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167+
run: |
168+
make e2e-v3-initial-release
169+
170+
e2e-headless-online:
171+
name: E2E headless online
172+
needs:
173+
- output-vars
174+
- build-release
175+
runs-on: ubuntu-latest
176+
steps:
177+
- name: Checkout
178+
uses: actions/checkout@v6
179+
180+
- name: Setup dagger
181+
run: |
182+
curl -fsSL https://dl.dagger.io/dagger/install.sh | sh
183+
sudo mv ./bin/dagger /usr/local/bin/dagger
184+
185+
- name: Run test
186+
id: test
187+
env:
188+
APP_VERSION: ${{ needs.output-vars.outputs.app_version }}
189+
KUBE_VERSION: "1.${{ needs.output-vars.outputs.k0s_minor_version }}"
190+
CMX_REPLICATED_API_TOKEN: ${{ secrets.CMX_REPLICATED_API_TOKEN }}
191+
CMX_SSH_PRIVATE_KEY: ${{ secrets.CMX_SSH_PRIVATE_KEY }}
192+
run: |
193+
# Run test and export results directory
194+
dagger call e-2-e-run-headless \
195+
--scenario=online \
196+
--app-version=$APP_VERSION \
197+
--kube-version=$KUBE_VERSION \
198+
--license-file ./e2e/licenses/ci-v3.yaml \
199+
--cmx-token=env://CMX_REPLICATED_API_TOKEN \
200+
--ssh-key=env://CMX_SSH_PRIVATE_KEY \
201+
export --path=./e2e-results
202+
203+
# Read result.json to extract test result
204+
if [ -f ./e2e-results/result.json ]; then
205+
success=$(jq -r '.Success' ./e2e-results/result.json)
206+
echo "Test success: $success"
207+
208+
# Exit with test result
209+
if [ "$success" = "true" ]; then
210+
exit 0
211+
else
212+
error=$(jq -r '.Error' ./e2e-results/result.json)
213+
echo "::error::E2E test failed: $error"
214+
exit 1
215+
fi
216+
else
217+
echo "::error::result.json not found in e2e-results directory"
218+
exit 1
219+
fi
220+
221+
- name: Upload test results
222+
if: ${{ !cancelled() && hashFiles('./e2e-results/**') != '' }}
223+
uses: actions/upload-artifact@v4
224+
with:
225+
name: e2e-results-headless-online
226+
path: ./e2e-results/

Makefile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ cmd/installer/goods/bins/local-artifact-mirror:
132132

133133
output/bins/fio-%:
134134
mkdir -p output/bins
135-
docker build -t fio --build-arg FIO_VERSION=$(call split-hyphen,$*,1) --build-arg PLATFORM=$(OS)/$(call split-hyphen,$*,2) fio
136-
docker rm -f fio && docker run --name fio fio
137-
docker cp fio:/output/fio $@
138-
docker rm -f fio
135+
dagger call build-fio --version=$(call split-hyphen,$*,1) --arch=$(call split-hyphen,$*,2) export --path=$@
136+
chmod +x $@
139137
touch $@
140138

141139
.PHONY: cmd/installer/goods/bins/fio
@@ -184,22 +182,21 @@ output/bin/embedded-cluster-release-builder:
184182
CGO_ENABLED=0 go build -o output/bin/embedded-cluster-release-builder e2e/embedded-cluster-release-builder/main.go
185183

186184
.PHONY: e2e-v3-initial-release
187-
e2e-v3-initial-release: export ARCH = amd64
185+
e2e-v3-initial-release: export ARCH ?= amd64
188186
e2e-v3-initial-release: export UPLOAD_BINARIES = 1
189187
e2e-v3-initial-release: export ENABLE_V3 = 1
190188
e2e-v3-initial-release: initial-release
191189

192190
.PHONY: initial-release
193-
initial-release: export EC_VERSION = $(VERSION)-$(CURRENT_USER)
194-
initial-release: export APP_VERSION = appver-dev-$(call random-string)
191+
initial-release: export EC_VERSION ?= $(VERSION)-$(CURRENT_USER)
192+
initial-release: export APP_VERSION ?= appver-dev-$(call random-string)
195193
initial-release: export RELEASE_YAML_DIR = $(if $(filter 1,$(ENABLE_V3)),e2e/kots-release-install-v3,e2e/kots-release-install)
196-
initial-release: export V2_ENABLED = 0
197194
initial-release: check-env-EC_VERSION check-env-APP_VERSION
198195
UPLOAD_BINARIES=$(if $(UPLOAD_BINARIES),$(UPLOAD_BINARIES),0) \
199196
./scripts/build-and-release.sh
200197

201198
.PHONY: rebuild-release
202-
rebuild-release: export EC_VERSION = $(VERSION)-$(CURRENT_USER)
199+
rebuild-release: export EC_VERSION ?= $(VERSION)-$(CURRENT_USER)
203200
rebuild-release: export RELEASE_YAML_DIR = $(if $(filter 1,$(ENABLE_V3)),e2e/kots-release-install-v3,e2e/kots-release-install)
204201
rebuild-release: check-env-EC_VERSION check-env-APP_VERSION
205202
UPLOAD_BINARIES=$(if $(UPLOAD_BINARIES),$(UPLOAD_BINARIES),0) \
@@ -208,10 +205,9 @@ rebuild-release: check-env-EC_VERSION check-env-APP_VERSION
208205

209206
.PHONY: upgrade-release
210207
upgrade-release: RANDOM_STRING = $(call random-string)
211-
upgrade-release: export EC_VERSION = $(VERSION)-$(CURRENT_USER)-upgrade-$(RANDOM_STRING)
212-
upgrade-release: export APP_VERSION = appver-dev-$(call random-string)-upgrade-$(RANDOM_STRING)
208+
upgrade-release: export EC_VERSION ?= $(VERSION)-$(CURRENT_USER)-upgrade-$(RANDOM_STRING)
209+
upgrade-release: export APP_VERSION ?= appver-dev-$(call random-string)-upgrade-$(RANDOM_STRING)
213210
upgrade-release: export RELEASE_YAML_DIR = $(if $(filter 1,$(ENABLE_V3)),e2e/kots-release-upgrade-v3,e2e/kots-release-upgrade)
214-
upgrade-release: export V2_ENABLED = 0
215211
upgrade-release: check-env-EC_VERSION check-env-APP_VERSION
216212
UPLOAD_BINARIES=$(if $(UPLOAD_BINARIES),$(UPLOAD_BINARIES),1) \
217213
./scripts/build-and-release.sh

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,17 @@ The V3 installer includes a Dagger-based E2E test framework that provides portab
461461
462462
**Quick Start:**
463463
```bash
464-
# Provision a test VM
464+
make e2e-v3-initial-release
465+
465466
dagger call with-one-password --service-account=env:OP_SERVICE_ACCOUNT_TOKEN \
466-
test-provision-vm string
467+
e-2-e-run-headless \
468+
--scenario=online \
469+
--app-version=<app version> \
470+
--kube-version=1.33 \
471+
--license-file=./local-dev/license.yaml
467472
```
468473
469-
**Documentation:** See [dagger/e2e/README.md](dagger/e2e/README.md) for comprehensive E2E testing guide, including:
474+
**Documentation:** See [dagger/README.md](dagger/README.md) for comprehensive E2E testing guide, including:
470475
- Setup and prerequisites
471476
- Available test scenarios
472477
- Troubleshooting

common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SHELL := /bin/bash
2+
MAKEFLAGS += --no-print-directory
23

34
ARCH ?= $(shell go env GOARCH)
45
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))

dagger.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"name": "embedded-cluster",
3-
"engineVersion": "v0.19.6",
3+
"engineVersion": "v0.19.7",
44
"sdk": {
55
"source": "go"
66
},
77
"include": [
88
"!build",
99
"!cmd/installer/goods/bins/**",
10+
"cmd/installer/goods/bins/.placeholder",
1011
"!cmd/installer/goods/internal/bins/**",
12+
"cmd/installer/goods/internal/bins/.placeholder",
1113
"!dagger/embedded-cluster",
1214
"!dev/build",
1315
"!local-artifact-mirror/bin",
@@ -39,8 +41,8 @@
3941
},
4042
{
4143
"name": "replicated",
42-
"source": "github.com/replicatedhq/daggerverse/replicated@bf96fd742cf08239442ac155de7143bb7ef8f7fd",
43-
"pin": "bf96fd742cf08239442ac155de7143bb7ef8f7fd"
44+
"source": "github.com/replicatedhq/daggerverse/replicated@41123ddba40a9594307f24cb69ef6fbafda38e44",
45+
"pin": "41123ddba40a9594307f24cb69ef6fbafda38e44"
4446
}
4547
],
4648
"source": "dagger",

0 commit comments

Comments
 (0)