-
Notifications
You must be signed in to change notification settings - Fork 20
129 lines (111 loc) · 5.5 KB
/
e2e.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: E2E CI
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches:
- main
paths:
- "**.go"
- "!**_test.go" # exclude test files to ignore unit test changes
- "test/**" # include test files in e2e again
- "!**.md"
- ".github/workflows/e2e.yaml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
VCLUSTER_VERSION: v0.19.0-alpha.4
VCLUSTER_SUFFIX: vcluster
VCLUSTER_NAME: vcluster
VCLUSTER_NAMESPACE: vcluster
jobs:
e2e-tests:
name: Execute test suites
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Set up kind k8s cluster
uses: engineerd/[email protected]
with:
version: "v0.20.0"
image: kindest/node:v1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31
- name: Testing kind cluster set-up
run: |
set -x
kubectl cluster-info
kubectl get pods -n kube-system
echo "kubectl config current-context:" $(kubectl config current-context)
echo "KUBECONFIG env var:" ${KUBECONFIG}
- name: Build plugin
run: |
# Build plugin
docker build . -f e2e/test_plugin/Dockerfile -t ghcr.io/loft-sh/test-plugin:v1
# Import to kind cluster
kind load docker-image ghcr.io/loft-sh/test-plugin:v1
- name: Create vcluster
id: create-vcluster
continue-on-error: true
run: |
set -x
# download vcluster cli
curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/download/${{ env.VCLUSTER_VERSION }}/vcluster-linux-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin && rm -f vcluster
# vcluster create
vcluster create ${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} \
--create-namespace \
--debug \
--connect=false \
-f ./e2e/commonValues.yaml \
-f ./e2e/test_plugin/plugin.yaml
- name: Wait until vcluster is ready
id: wait-until-vcluster-is-ready
if: steps.create-vcluster.outcome == 'success'
run: |
set -x
sleep 1
kubectl wait --for=condition=ready pod -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} --timeout=300s
continue-on-error: true
- name: Collect deployment information in case vcluster fails to start
if: steps.wait-until-vcluster-is-ready.outcome != 'success'
run: |
set -x
kubectl get pods -o yaml -n ${{ env.VCLUSTER_NAMESPACE }}
echo "======================================================================================================================"
kubectl get events -n ${{ env.VCLUSTER_NAMESPACE }} --sort-by='.lastTimestamp'
echo "======================================================================================================================"
kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c vcluster --tail=10000
echo "======================================================================================================================"
kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=10000
echo "======================================================================================================================"
kubectl describe pods -n ${{ env.VCLUSTER_NAMESPACE }}
exit 1
# Skips NetworkPolicy tests because they require network plugin with support (e.g. Calico)
- name: Execute e2e tests
id: execute-e2e-tests
working-directory: e2e
continue-on-error: true
run: |
set -x
VCLUSTER_SUFFIX=${{ env.VCLUSTER_SUFFIX }} VCLUSTER_NAME=${{ env.VCLUSTER_NAME }} VCLUSTER_NAMESPACE=${{ env.VCLUSTER_NAMESPACE }} go test -v -ginkgo.v -ginkgo.fail-fast
- name: Print logs if e2e tests fail
if: steps.execute-e2e-tests.outcome == 'failure'
run: |
set -x
kubectl get pods -o yaml -n ${{ env.VCLUSTER_NAMESPACE }}
echo "======================================================================================================================"
kubectl get events -n ${{ env.VCLUSTER_NAMESPACE }} --sort-by='.lastTimestamp'
echo "======================================================================================================================"
kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=10000
echo "======================================================================================================================"
kubectl describe pods -n ${{ env.VCLUSTER_NAMESPACE }}
echo "======================================================================================================================"
kubectl get pods -A
echo "======================================================================================================================"
kubectl get svc -A
echo "======================================================================================================================"
kubectl get ns
exit 1