-
Notifications
You must be signed in to change notification settings - Fork 51
130 lines (111 loc) · 4.75 KB
/
e2e.yml
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
130
name: E2E Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
e2e-k8s-cluster:
#
# E2E tests run against a Kubernetes cluster.
# These tests setup microk8s and run NucliaDB standalone with PostgreSQL.
# Chart configuration: e2e/conf/chart.values.yaml
#
name: E2E Kubernetes Cluster Tests
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ubuntu
# see if this is affecting microk8s
run: |
sudo ufw disable
sudo iptables -P FORWARD ACCEPT
- uses: balchua/[email protected]
with:
channel: "1.27/stable"
devMode: "true"
addons: '["dns", "rbac", "hostpath-storage", "registry", "helm", "storage"]'
- name: "Set up Helm"
uses: azure/setup-helm@v4
- name: Install PostgreSQL with Helm
run: |
helm install my-postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --version 12.9.0
- name: Wait for PostgreSQL to be ready
run: |
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=postgresql,app.kubernetes.io/instance=my-postgresql
- name: Install Minio with Helm
run: |
helm install my-minio oci://registry-1.docker.io/bitnamicharts/minio
- name: Wait for Minio to be ready
run: |
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=minio,app.kubernetes.io/instance=my-minio
kubectl exec deploy/my-minio -- mkdir /bitnami/minio/data/nidx
- name: Credentials
id: envs
run: |-
PGPASSWORD=`kubectl get secret --namespace default my-postgresql -o jsonpath="{.data.postgres-password}" | base64 -d`
echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_OUTPUT
MINIO_USER=`kubectl get secret --namespace default my-minio -o jsonpath="{.data.root-user}" | base64 -d`
echo "MINIO_USER=$MINIO_USER" >> $GITHUB_OUTPUT
MINIO_PASSWORD=`kubectl get secret --namespace default my-minio -o jsonpath="{.data.root-password}" | base64 -d`
echo "MINIO_PASSWORD=$MINIO_PASSWORD" >> $GITHUB_OUTPUT
- name: Build and push images
run: |
docker build -t localhost:32000/nucliadb:test . -f Dockerfile
docker push localhost:32000/nucliadb:test
docker build -t localhost:32000/nidx:test . -f Dockerfile.nidx
docker push localhost:32000/nidx:test
- name: Install NucliaDB with Helm
run: |
kubectl create namespace nucliadb
helm install nucliadb charts/nucliadb \
--timeout 5m \
--namespace nucliadb \
--values e2e/conf/chart.values.yaml \
--set "env.NUA_API_KEY=${{ secrets.NUA_API_KEY }}" \
--set "pg_url=postgresql://postgres:${{ steps.envs.outputs.PGPASSWORD }}@my-postgresql.default.svc.cluster.local:5432/postgres" \
--set "minio_user=${{ steps.envs.outputs.MINIO_USER }}" \
--set "minio_password=${{ steps.envs.outputs.MINIO_PASSWORD }}" \
--set "image=localhost:32000/nucliadb" \
--set "imageVersion=test" \
--set "nidx.image=localhost:32000/nidx" \
--set "nidx.imageVersion=test"
sleep 10
kubectl -n nucliadb wait --timeout=2m --for=condition=Available deploy/nucliadb || (
kubectl get all --all-namespaces
microk8s inspect &&
kubectl logs -n nucliadb deploy/nucliadb &&
kubectl logs -n nucliadb deploy/nidx &&
kubectl logs -n nucliadb deploy/nucliadb-worker &&
exit 1)
kubectl -n nucliadb wait --timeout=1m --for=condition=Available deploy/nidx || (
kubectl get all --all-namespaces
microk8s inspect &&
kubectl logs -n nucliadb deploy/nucliadb &&
kubectl logs -n nucliadb deploy/nidx &&
kubectl logs -n nucliadb deploy/nucliadb-worker &&
exit 1)
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12.5
cache: "pip"
- name: Install test deps
run: pip install -r e2e/requirements.txt
- name: Run tests
run: |
kubectl port-forward -n nucliadb service/nucliadb 8080:8080 > /dev/null 2>&1 &
sleep 10
pytest -s -vv --tb=native e2e/test_e2e.py ||
(kubectl get all --all-namespaces &&
microk8s inspect &&
kubectl logs -n nucliadb deploy/nucliadb &&
kubectl logs -n nucliadb deploy/nidx &&
kubectl logs -n nucliadb deploy/nucliadb-worker &&
exit 1)