-
Notifications
You must be signed in to change notification settings - Fork 51
159 lines (138 loc) · 5.13 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: E2E Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
e2e-k8s-cluster:
#
# E2E tests run against a Kubernetes cluster.
# These tests setup microk8s and run NucliaDB with PostgreSQL.
# Chart configuration: e2e/conf/chart.values.yaml
#
name: E2E Kubernetes Cluster Tests
runs-on: ubuntu-latest
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@v3
- name: Install PostgreSQL with Helm
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-postgresql bitnami/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: PG Password
id: envs
run: |-
PGPASSWORD=`kubectl get secret --namespace default my-postgresql -o jsonpath="{.data.postgres-password}" | base64 -d`
echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_OUTPUT
- name: Build and push image
run: |
docker build -t localhost:32000/nucliadb:test .
docker push localhost:32000/nucliadb: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.DRIVER_PG_URL=postgresql://postgres:${{ steps.envs.outputs.PGPASSWORD }}@my-postgresql.default.svc.cluster.local:5432/postgres" \
--set "env.NUA_API_KEY=${{ secrets.NUA_API_KEY }}" \
--set "image=localhost:32000/nucliadb" \
--set "imageVersion=test"
sleep 10
kubectl -n nucliadb wait --timeout=2m --for=condition=Ready pod -l statefulset.kubernetes.io/pod-name=nucliadb-0 || (
kubectl get all --all-namespaces
microk8s inspect &&
kubectl logs -n nucliadb pod/nucliadb-0 &&
kubectl logs -n nucliadb pod/nucliadb-1 &&
exit 1)
kubectl -n nucliadb wait --timeout=1m --for=condition=Ready pod -l statefulset.kubernetes.io/pod-name=nucliadb-1
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
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 &
sleep 10
pytest -s --tb=native e2e/test_e2e.py ||
(kubectl get all --all-namespaces &&
microk8s inspect &&
kubectl logs -n nucliadb pod/nucliadb-0 &&
kubectl logs -n nucliadb pod/nucliadb-1 &&
exit 1)
e2e-vm-cluster:
runs-on: ubuntu-latest
name: E2E VM Cluster Tests
strategy:
matrix:
ostypes: ["debian:bookworm-slim", "fedora:38"]
container:
image: ${{ matrix.ostypes }}
volumes:
- /opt/
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install NucliaDB
# tests that installation script works
run: |
./scripts/install-vm.sh
- name: Install local nucliadb
# Now, let's install the current version of nucliadb to
# run the tests against.
# Unfortunately, we're not testing against the released version
# of NucliaDB; however, it seems more important to test against
# the current branch.
run: |
bash -c 'source /opt/nucliadb/bin/activate && make -C nucliadb install-dev'
- name: Run Cluster and tests
env:
DRIVER: PG
FILE_BACKEND: PG
DRIVER_PG_URL: postgresql://postgres:postgres@postgres:5432/postgres
NUCLIA_PUBLIC_URL: https://{zone}.stashify.cloud
cluster_discovery_mode: manual
cluster_discovery_manual_addresses: '["localhost:10009","localhost:10010"]'
DEBUG: "1"
NUA_API_KEY: ${{ secrets.NUA_API_KEY }}
NUCLIADB_DISABLE_ANALYTICS: "True"
run: bash e2e/run-e2e-tests.sh