1
1
name : run-e2e
2
2
on :
3
- push :
4
- branches : [ "master" ]
5
3
pull_request :
6
4
branches : [ "master" ]
7
- jobs :
5
+ jobs :
6
+ start-runner :
7
+ name : Start self-hosted YC runner
8
+ runs-on : ubuntu-latest
9
+ outputs :
10
+ label : ${{ steps.start-yc-runner.outputs.label }}
11
+ instance-id : ${{ steps.start-yc-runner.outputs.instance-id }}
12
+ steps :
13
+ - name : Start YC runner
14
+ id : start-yc-runner
15
+ uses : yc-actions/yc-github-runner@v1
16
+ with :
17
+ mode : start
18
+ yc-sa-json-credentials : ${{ secrets.CI_RUNNER_CREATOR_KEY }}
19
+ github-token : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
20
+ folder-id : b1gmgbhccra2qca8v5g6
21
+ image-id : fd80o2eikcn22b229tsa
22
+ cores : 16
23
+ disk-type : network-ssd-nonreplicated
24
+ disk-size : 465GB
25
+ memory : 32GB
26
+ core-fraction : 100
27
+ subnet-id : e9bm73bk6gh9ag8clm2o
8
28
run-e2e-job :
9
29
name : run-e2e-job
10
- runs-on : self-hosted
30
+ needs : start-runner
31
+ runs-on : ${{ needs.start-runner.outputs.label }}
11
32
steps :
12
33
- uses : actions/checkout@v2
13
34
- uses : actions/setup-go@v3
14
35
with :
15
36
go-version : ' 1.19'
16
37
- name : install-dependencies
17
38
run : |
39
+ sudo apt-get update
40
+ sudo apt-get install -y build-essential
41
+ echo $(which gcc)
42
+
43
+ export HOME=/actions-runner
44
+ echo "HOME=/actions-runner" >> $GITHUB_ENV
45
+
18
46
go install sigs.k8s.io/kind@v0.17.0
19
47
20
48
curl -LO https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl
@@ -25,10 +53,18 @@ jobs:
25
53
tar -zxvf "${HELM_PKG}"
26
54
mv ./linux-amd64/helm .
27
55
28
- echo "$(pwd)"
56
+ curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash
57
+
29
58
echo "$(pwd)" >> $GITHUB_PATH
59
+ echo "$HOME/ydb/bin" >> $GITHUB_PATH
60
+ echo "$HOME/go/bin" >> $GITHUB_PATH
61
+ - name : configure-system
62
+ run : |
63
+ sudo sysctl fs.inotify.max_user_instances=1280
64
+ sudo sysctl fs.inotify.max_user_watches=655360
30
65
- name : check-dependencies
31
66
run : |
67
+ gcc --version
32
68
go version
33
69
kind version
34
70
kubectl version --short --client=true
@@ -50,47 +86,31 @@ jobs:
50
86
- name : load-and-deploy-operator
51
87
run : |
52
88
docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
53
- kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
54
89
kind load docker-image kind/ydb-operator:current
55
- helm -n ydb-operator install --create-namespace ydb-operator ./deploy/ydb-operator \
56
- -f ./e2e/operator-values.yaml \
57
- --set image.repository=kind/ydb-operator \
58
- --set image.tag=current \
59
- --set image.pullPolicy=Never || sleep 100000
60
- # while true; do OPERATOR_POD_NAME=$(kubectl get pods -n ydb-operator | awk '{if ($1 ~ "ydb-operator") print $1}'); kubectl logs -n ydb-operator $OPERATOR_POD_NAME || true; kubectl describe pod -n ydb-operator $OPERATOR_POD_NAME; sleep 30; done
61
- OPERATOR_POD_NAME=$(kubectl get pods -n ydb-operator | awk '{if ($1 ~ "ydb-operator") print $1}')
62
- kubectl wait --timeout=5m --for=condition=ready pod -n ydb-operator $OPERATOR_POD_NAME
63
90
- name : pull-and-load-ydb-image
64
91
run : |
65
92
# TODO would be cool to parse YDB image from manifests to avoid duplicating information
66
93
docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44
67
94
kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44
68
- - name : apply-resources
95
+ - name : run-tests
69
96
run : |
70
- # TODO NOW, THIS COULD BE FULLY REPLACED WITH TESTS IN GOLANG! I WAIT FOR DATABASE PODS AS AN EXAMPLE ONLY!
71
- # REAL TESTS WILL BE WRITTEN IN GOLANG AND WILL USE THE INFRASTRUCTURE CREATED ABOVE!
72
- kubectl create namespace ydb
73
-
74
- kubectl apply -f ./e2e/manifests/storage.yaml
75
- kubectl apply -f ./e2e/manifests/database.yaml
76
-
77
- # TODO namespace and labels are hardcoded in the next command, that is duplication.
78
- # We should get the label and its value from ./e2e/manifests/*.yaml
79
- kubectl wait --timeout=15m --for=condition=storageinitialized=true storage -n ydb ycydb
80
- kubectl wait --timeout=10m --for=condition=ready pod -n ydb -l ydb-cluster=kind-storage
81
-
82
- kubectl wait --timeout=10m --for=condition=tenantinitialized=true database -n ydb database
83
- kubectl wait --timeout=10m --for=condition=ready pod -n ydb -l ydb-cluster=kind-database
84
-
85
- # Something as a reference for a more complicated check later. Be careful with the yaml indentation!
86
- # while true; do
87
- # LST=$(kubectl get pods -n ydb -l ydb-cluster=kind-storage -o=jsonpath="{.items[*].status.phase}")
88
- # for arg in "$(LST)"; do [[ $arg != "Running" ]] && exit 1; done; exit 0
89
- # done
90
-
91
- # TODO create a pod that will execute `select 1` against the cluster
92
- # FIRST_DATABASE_POD_NAME=$(kubectl get pods -n ydb | awk '{if ($1 ~ "database") print $1}')
93
- # kubectl exec "$FIRST_DATABASE_POD_NAME" -n ydb -- bash
97
+ go test -p 1 ./...
94
98
- name : teardown-k8s-cluster
95
99
run : |
96
100
kind delete cluster
101
+ stop-runner :
102
+ name : Stop self-hosted YC runner
103
+ needs :
104
+ - start-runner
105
+ - run-e2e-job
106
+ runs-on : ubuntu-latest
107
+ if : ${{ always() }}
108
+ steps :
109
+ - name : Stop YC runner
110
+ uses : yc-actions/yc-github-runner@v1
111
+ with :
112
+ mode : stop
113
+ yc-sa-json-credentials : ${{ secrets.CI_RUNNER_CREATOR_KEY }}
114
+ github-token : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
115
+ label : ${{ needs.start-runner.outputs.label }}
116
+ instance-id : ${{ needs.start-runner.outputs.instance-id }}
0 commit comments