- swaps out `django-push-notifications` for [`fcm-django`](https://github.com/grafana/fcm-django). Again.. this is a fork of the parent repo for exactly the same reason.. the migrations point to `auth_user` without letting us use our own user model, this has been patched in the `grafana` fork. The reason why we are using `fcm-django` vs `django-push-notifications` is that the latter does not support the new FCM API, only the "legacy" API. The legacy FCM API does not support certain push notification settings that we would like to use. - modifies the iOS/Android specific push notification settings - adds a `flower` pod in the `docker-compose-developer.yml`, useful for debugging tasks locally - sets the mobile app verification token TTL to 5 minutes when developing locally. The default of 1 minute makes working with device emulators really tricky.. This PR also swaps out the base image in `engine/Dockerfile` from `python:3.9-alpine3.16` to `python:3.9-slim-buster`. As to why.. in short, with the introduction of the `fcm-django` library there is now a peer-dependency on [`grpcio`](https://github.com/grpc/grpc) (which is used by `firebase_admin`.. which I am using in this PR to interact directly with Firebase Cloud Messaging (FCM)). `grpcio` does not publish wheels (read: compiled binaries) for the Alpine distro. It does publish wheels for Debian and hence `pip install -r requirements.txt` does not need to build this library from the source distribution. This is a [known "issue"](https://github.com/grpc/grpc/issues/22815#issuecomment-1107874367) and the recommended solution in the community is to.. not use alpine. These were the numbers, when building the image locally, in terms of image size and build time: | | Local image size (uncompressed | Build time (may differ based on your network speed) | | ------------------------- | -------------------------------------- | ---------- | | `python:3.9-alpine3.16` | 785MB | 320s | | `python:3.9-slim-buster` | 1.05GB | 90s | Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com>
90 lines
3.5 KiB
YAML
90 lines
3.5 KiB
YAML
name: Helm End to End Testing
|
|
|
|
on:
|
|
- pull_request
|
|
|
|
jobs:
|
|
create-cluster:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Docker Buildx # We need this step for docker caching
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Build docker image locally # using github actions docker cache
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./engine
|
|
file: ./engine/Dockerfile
|
|
push: false
|
|
load: true
|
|
tags: oncall/engine:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Create k8s Kind Cluster
|
|
uses: helm/kind-action@v1.3.0
|
|
with:
|
|
config: ./helm/kind.yml
|
|
|
|
- name: Load image on the nodes of the cluster
|
|
run: kind load docker-image --name=chart-testing oncall/engine:latest
|
|
|
|
- name: Install helm chart
|
|
run: helm install test-release helm/oncall --values helm/simple.yml --values helm/values-local-image.yml
|
|
|
|
- name: Await k8s pods and other resources up
|
|
uses: jupyterhub/action-k8s-await-workloads@v1
|
|
with:
|
|
workloads: "" # all
|
|
namespace: "" # default
|
|
timeout: 300
|
|
max-restarts: 0
|
|
|
|
- name: Bootstrap organization and integration
|
|
run: |
|
|
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=oncall,app.kubernetes.io/instance=test-release,app.kubernetes.io/component=engine" -o jsonpath="{.items[0].metadata.name}")
|
|
export ONCALL_INTEGRATION_URL=http://localhost:30001$(kubectl exec -it $POD_NAME -- bash -c "python manage.py setup_end_to_end_test --bootstrap_integration")
|
|
echo "ONCALL_INTEGRATION_URL=$ONCALL_INTEGRATION_URL" >> $GITHUB_ENV
|
|
|
|
- name: Send an alert to the integration
|
|
run: |
|
|
echo $ONCALL_INTEGRATION_URL
|
|
export TEST_ID=test-0
|
|
echo "TEST_ID=$TEST_ID" >> $GITHUB_ENV
|
|
curl -X POST "$ONCALL_INTEGRATION_URL" \
|
|
-H 'Content-Type: Application/json' \
|
|
-d '{
|
|
"alert_uid": "08d6891a-835c-e661-39fa-96b6a9e26552",
|
|
"title": "'"$TEST_ID"'",
|
|
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ee/Grumpy_Cat_by_Gage_Skidmore.jpg",
|
|
"state": "alerting",
|
|
"link_to_upstream_details": "https://en.wikipedia.org/wiki/Downtime",
|
|
"message": "Smth happened. Oh no!"
|
|
}'
|
|
|
|
# GitHub Action reference: https://github.com/jupyterhub/action-k8s-namespace-report
|
|
- name: Kubernetes namespace report
|
|
uses: jupyterhub/action-k8s-namespace-report@v1
|
|
if: always()
|
|
|
|
- name: Await 1 alert group and 1 alert created during the test (timeout 30 seconds)
|
|
run: |
|
|
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=oncall,app.kubernetes.io/instance=test-release,app.kubernetes.io/component=engine" -o jsonpath="{.items[0].metadata.name}")
|
|
tries=30
|
|
while [ "$tries" -gt 0 ]; do
|
|
if kubectl exec -it $POD_NAME -c oncall -- bash -c "python manage.py setup_end_to_end_test --return_results_for_test_id $TEST_ID" | grep -q '1, 1'
|
|
then
|
|
break
|
|
fi
|
|
|
|
tries=$(( tries - 1 ))
|
|
sleep 1
|
|
done
|
|
|
|
if [ "$tries" -eq 0 ]; then
|
|
echo 'Expected "1, 1" (alert groups, alerts). They were not created in 30 seconds during this integration test. Something is broken' >&2
|
|
exit 1
|
|
fi
|