Skip to content

Commit 7be2cc4

Browse files
authored
Tests in golang (#100)
1 parent d6587fa commit 7be2cc4

File tree

13 files changed

+836
-758
lines changed

13 files changed

+836
-758
lines changed

.github/workflows/e2e.yml

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,48 @@
11
name: run-e2e
22
on:
3-
push:
4-
branches: [ "master" ]
53
pull_request:
64
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
828
run-e2e-job:
929
name: run-e2e-job
10-
runs-on: self-hosted
30+
needs: start-runner
31+
runs-on: ${{ needs.start-runner.outputs.label }}
1132
steps:
1233
- uses: actions/checkout@v2
1334
- uses: actions/setup-go@v3
1435
with:
1536
go-version: '1.19'
1637
- name: install-dependencies
1738
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+
1846
go install sigs.k8s.io/kind@v0.17.0
1947
2048
curl -LO https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl
@@ -25,10 +53,18 @@ jobs:
2553
tar -zxvf "${HELM_PKG}"
2654
mv ./linux-amd64/helm .
2755
28-
echo "$(pwd)"
56+
curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash
57+
2958
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
3065
- name: check-dependencies
3166
run: |
67+
gcc --version
3268
go version
3369
kind version
3470
kubectl version --short --client=true
@@ -50,47 +86,31 @@ jobs:
5086
- name: load-and-deploy-operator
5187
run: |
5288
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
5489
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
6390
- name: pull-and-load-ydb-image
6491
run: |
6592
# TODO would be cool to parse YDB image from manifests to avoid duplicating information
6693
docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44
6794
kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44
68-
- name: apply-resources
95+
- name: run-tests
6996
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 ./...
9498
- name: teardown-k8s-cluster
9599
run: |
96100
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 }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.17 as builder
1+
FROM golang:1.19 as builder
22

33
WORKDIR /workspace
44
COPY go.mod go.mod

e2e/manifests/database.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

e2e/manifests/storage.yaml

Lines changed: 0 additions & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)