chore: autopublish 2024-11-11T15:50:59Z #6495
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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 . -f Dockerfile.withbinding | |
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 && | |
kubectl get pods -n nucliadb -l app=nucliadb-worker -o name | while read pod; do kubectl logs -n nucliadb $pod; done && | |
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@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 pod/nucliadb-0 && | |
kubectl logs -n nucliadb pod/nucliadb-1 && | |
kubectl get pods -n nucliadb -l app=nucliadb-worker -o name | while read pod; do kubectl logs -n nucliadb $pod; done && | |
exit 1) |