Skip to content

Commit a5bd8dd

Browse files
committed
ci: e2e test
1 parent 5a1aae6 commit a5bd8dd

File tree

4 files changed

+73
-76
lines changed

4 files changed

+73
-76
lines changed

.github/workflows/ci.yaml

Lines changed: 69 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -56,75 +56,79 @@ jobs:
5656
run: make lint
5757
- name: Integration test
5858
run: make integration-test coverage
59-
- name: Generate
60-
uses: irongut/CodeCoverageSummary@v1.3.0
61-
with:
62-
filename: build/coverage.xml,build/coverage.e2e.xml
63-
badge: true
64-
format: markdown
65-
output: both
6659
- name: Archive coverage report
6760
uses: actions/upload-artifact@v4
6861
with:
6962
name: coverage
7063
path: ${{ env.CODECOV_FILE }}
7164

72-
# e2e:
73-
# name: E2E Test
74-
# needs:
75-
# - verify
76-
# - image-build
77-
# runs-on: ubuntu-latest
78-
# env:
79-
# CODECOV_FILE: build/coverage.e2e.xml
80-
# SKAFFOLD_NAMESPACE: sandbox
81-
# SKAFFOLD_RUN_ID: e2e-test
82-
# steps:
83-
# - name: Checkout
84-
# uses: actions/checkout@v4
85-
# - name: Setup Skaffold
86-
# uses: heypigeonhq/setup-skaffold@v1.0.0
87-
# with:
88-
# version: 2.14.1
89-
# - name: Create Kind cluster
90-
# uses: helm/kind-action@v1
91-
# with:
92-
# cluster_name: kind-etcd
93-
# - name: Bootstrap
94-
# run: |
95-
# kustomize build --enable-helm config/bootstrap | kubectl apply -f -
96-
# kubectl --namespace cert-manager wait --for=condition=Available deployment/cert-manager-webhook
97-
# kubectl get namespace sandbox 2>/dev/null || kubectl create namespace sandbox
98-
# - name: Build images
99-
# run: |
100-
# mkdir build
101-
# skaffold build --file-output=build/images.json
102-
# - name: Deploy
103-
# run: skaffold deploy --profile e2e --build-artifacts=build/images.json
104-
# - name: Run E2E tests
105-
# run: skaffold verify --namespace sandbox --build-artifacts=build/images.json
106-
# - name: Fetch coverage
107-
# run: make fetch-coverage
108-
# - name: Archive coverage report
109-
# uses: actions/upload-artifact@v4
110-
# with:
111-
# name: coverage-e2e
112-
# path: ${{ env.CODECOV_FILE }}
65+
e2e:
66+
name: E2E Test
67+
needs:
68+
- verify
69+
- image-build
70+
runs-on: ubuntu-latest
71+
env:
72+
CODECOV_FILE: build/coverage.e2e.xml
73+
SKAFFOLD_NAMESPACE: sandbox
74+
SKAFFOLD_RUN_ID: e2e-test
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
- name: Login to GitHub Container Registry
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ghcr.io
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
- name: Setup Skaffold
85+
uses: heypigeonhq/setup-skaffold@v1.0.0
86+
with:
87+
version: 2.14.1
88+
- name: Create Kind cluster
89+
uses: helm/kind-action@v1
90+
- name: Bootstrap
91+
run: |
92+
kustomize build --enable-helm config/bootstrap | kubectl apply -f -
93+
kubectl --namespace cert-manager wait --for=condition=Available deployment/cert-manager-webhook
94+
kubectl get namespace sandbox 2>/dev/null || kubectl create namespace sandbox
95+
mkdir build/
96+
- name: Download image tags
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: images
100+
path: build
101+
- name: Deploy
102+
run: skaffold deploy --profile e2e --build-artifacts=build/images.json
103+
- name: Run E2E tests
104+
run: skaffold verify --namespace sandbox --build-artifacts=build/images.json
105+
- name: Fetch coverage
106+
run: make fetch-coverage
107+
- name: Archive coverage report
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: coverage-e2e
111+
path: ${{ env.CODECOV_FILE }}
113112

114-
# coverage:
115-
# name: Coverage Report
116-
# needs:
117-
# - verify
118-
# - e2e
119-
# runs-on: ubuntu-latest
120-
# steps:
121-
# - name: Download coverage report
122-
# uses: actions/download-artifact@v4
123-
# with:
124-
# name: coverage
125-
# path: build
126-
# - name: Download E2E coverage report
127-
# uses: actions/download-artifact@v4
128-
# with:
129-
# name: coverage-e2e
130-
# path: build
113+
coverage:
114+
name: Coverage Report
115+
needs:
116+
- verify
117+
- e2e
118+
runs-on: ubuntu-latest
119+
steps:
120+
- name: Download coverage report
121+
uses: actions/download-artifact@v4
122+
with:
123+
name: coverage
124+
path: build
125+
- name: Download E2E coverage report
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: coverage-e2e
129+
path: build
130+
- name: Upload coverage reports to Codecov
131+
uses: codecov/codecov-action@v5
132+
with:
133+
token: ${{ secrets.CODECOV_TOKEN }}
134+
files: build/coverage.xml,build/coverage.e2e.xml

config/e2e/role-binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: etcd-operator
55
roleRef:
66
apiGroup: rbac.authorization.k8s.io
7-
kind: ClusterRole
7+
kind: Role
88
name: etcd-operator
99
subjects:
1010
- kind: ServiceAccount

e2e/backup_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package e2e
22

33
import (
4-
"context"
54
"fmt"
65
"testing"
76
"time"
@@ -14,7 +13,7 @@ import (
1413
)
1514

1615
func TestBackup(t *testing.T) {
17-
ctx := context.Background()
16+
ctx := t.Context()
1817
kcl := kubeClient(t, client.Options{})
1918

2019
key := client.ObjectKey{
@@ -54,11 +53,6 @@ func TestBackup(t *testing.T) {
5453
}
5554
triggerCronJob(t, ctx, kcl, key, 5*time.Minute)
5655

57-
// delete data
58-
if _, err := ecl.Delete(ctx, k); err != nil {
59-
t.Fatal("failed to delete key:", err)
60-
}
61-
6256
// restore from backup
6357
cluster = createCluster(t, ctx, kcl, 3*time.Minute, apiv1.EtcdClusterSpec{
6458
Version: "v3.5.14",
@@ -70,9 +64,9 @@ func TestBackup(t *testing.T) {
7064
},
7165
})
7266

67+
// check if value is restored from backup
7368
ecl = etcdClient(t, ctx, kcl, cluster)
7469

75-
// check if value is restored from backup
7670
resp, err := ecl.Get(ctx, k)
7771
if err != nil {
7872
t.Fatalf("get %q: %v", k, err)

e2e/cluster_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package e2e
22

33
import (
4-
"context"
54
"slices"
65
"strings"
76
"testing"
@@ -17,7 +16,7 @@ import (
1716
)
1817

1918
func TestCluster(t *testing.T) {
20-
ctx := context.Background()
19+
ctx := t.Context()
2120
kcl := kubeClient(t, client.Options{})
2221

2322
cluster := createCluster(t, ctx, kcl, 3*time.Minute, apiv1.EtcdClusterSpec{

0 commit comments

Comments
 (0)