Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 23 additions & 28 deletions .github/workflows/helm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
# - helm versions at https://github.com/helm/helm/tags
k3s-channel: latest
helm-version: v3.8.2
metrics-enabled: false
docker-enabled: true

- name: last commit sha if PR
Expand All @@ -61,42 +62,35 @@ jobs:
SALT=$(echo "${RANDOM}${RANDOM}${RANDOM}" | cut -c1-3)
echo "RELEASE_NAME=eoapi$COMMITSHA$SALT" >> $GITHUB_ENV

- name: helm install crunchydata postgres operator
run: |
helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo

- name: helm render/install eoapi templates
run: |
export PGUSER=username
export POSTGRES_USER=username
export PGPASSWORD=password
export POSTGRES_PASSWORD=password
export GITSHA='${{github.sha}}'

cd helm-chart

helm install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo

helm install $RELEASE_NAME \
--namespace eoapitest \
--create-namespace \
--set db.settings.secrets.POSTGRES_HOST=pgstac-$RELEASE_NAME \
--set db.settings.secrets.POSTGRES_HOST_READER=pgstac-$RELEASE_NAME \
--set db.settings.secrets.POSTGRES_HOST_WRITER=pgstac-$RELEASE_NAME \
--set db.settings.secrets.PGUSER=$PGUSER \
--set db.settings.secrets.POSTGRES_USER=$POSTGRES_USER \
--set db.settings.secrets.PGPASSWORD=$PGPASSWORD \
--set db.settings.secrets.POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
--namespace default \
-f ./eoapi/values.yaml \
-f ./eoapi/test-unittest-values.yaml \
-f ./eoapi/test-k3s-unittest-values.yaml \
./eoapi

- name: sleep for 10s seconds while services boot
shell: bash
run: sleep 10s

# - name: Setup upterm session
# uses: lhotari/action-upterm@v1

- id: watchservices
name: watch services boot
timeout-minutes: 10
continue-on-error: true
run: |
kubectl config set-context --current --namespace=eoapitest
kubectl config set-context --current --namespace=default
while [[ -z "$(kubectl get pod | grep "^raster-$RELEASE_NAME-.*$" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} | grep "GET /.*/healthz" | head -n 1)" ]]; do
echo "still waiting for raster service to start..."
sleep 1
Expand Down Expand Up @@ -124,9 +118,6 @@ jobs:
run: |
python -m pip install pytest httpx

# - name: Setup upterm session
# uses: lhotari/action-upterm@v1

- name: run the tests
id: testrunner
continue-on-error: true
Expand All @@ -135,7 +126,7 @@ jobs:
kubectl get ingress --all-namespaces -o jsonpath='{range .items[0]}kubectl describe ingress {.metadata.name} -n {.metadata.namespace}{end}' | sh
kubectl get middleware.traefik.io --all-namespaces -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' --no-headers | while read -r namespace name; do kubectl describe middleware.traefik.io "$name" -n "$namespace"; done

kubectl config set-context --current --namespace=eoapitest
kubectl config set-context --current --namespace=default
PUBLICIP='http://'$(kubectl -n kube-system get svc traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo '#################################'
echo vector=$PUBLICIP/vector$RELEASE_NAME
Expand All @@ -151,9 +142,9 @@ jobs:
head -n 5 .github/workflows/tests/test_stac.py
pytest .github/workflows/tests/test_stac.py

sed -i "s|raster_endpoint\=.*$|raster_endpoint\='$PUBLICIP/raster$RELEASE_NAME'|g" .github/workflows/tests/test_raster.py
head -n 5 .github/workflows/tests/test_raster.py
pytest .github/workflows/tests/test_raster.py
# sed -i "s|raster_endpoint\=.*$|raster_endpoint\='$PUBLICIP/raster$RELEASE_NAME'|g" .github/workflows/tests/test_raster.py
# head -n 5 .github/workflows/tests/test_raster.py
# pytest .github/workflows/tests/test_raster.py

- name: error if tests failed
if: steps.testrunner.outcome == 'failure'
Expand Down Expand Up @@ -222,6 +213,10 @@ jobs:
gcloud components install gke-gcloud-auth-plugin
gcloud container clusters get-credentials k8seed-labs-cluster --zone us-central1-f

- name: helm install crunchydata postgres operator
run: |
helm upgrade --install --set disable_check_for_upgrades=true pgo oci://registry.developers.crunchydata.com/crunchydata/pgo

- name: helm render/install eoapi templates
run: |
export GITSHA='${{github.sha}}'
Expand All @@ -232,13 +227,16 @@ jobs:
--namespace $RELEASE_NAME \
--create-namespace \
-f ./eoapi/values.yaml \
-f ./eoapi/test-unittest-values.yaml \
-f ./eoapi/test-gcp-unittest-values.yaml \
./eoapi

- name: sleep for 10s seconds while services boot
shell: bash
run: sleep 10s

# - name: Setup upterm session
# uses: lhotari/action-upterm@v1

- id: watchservices
name: watch services boot
timeout-minutes: 10
Expand Down Expand Up @@ -276,9 +274,6 @@ jobs:
run: |
python -m pip install pytest httpx

# - name: Setup upterm session
# uses: lhotari/action-upterm@v1

- name: run the tests
id: testrunner
continue-on-error: true
Expand Down
10 changes: 10 additions & 0 deletions helm-chart/eoapi/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,13 @@ validate:

{{- end -}}

{{/*
validate:
that you can only use traefik as ingress when `testing=true`
*/}}
{{- define "eoapi.validateTraefik" -}}
{{- if and (not .Values.testing) (eq .Values.ingress.className "traefik") $ -}}
{{- fail "you cannot use traefik yet outside of testing" -}}
{{- end -}}

{{- end -}}
7 changes: 4 additions & 3 deletions helm-chart/eoapi/templates/services/ingress-traefik.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- include "eoapi.validateTraefik" . -}}
{{- if and .Values.ingress.enabled (eq .Values.ingress.className "traefik") }}
apiVersion: traefik.io/v1alpha1
kind: Middleware
Expand All @@ -7,7 +8,7 @@ metadata:
spec:
replacePathRegex:
regex: "^/(raster|vector|stac){{ $.Release.Name }}(/|$)(.*)"
replacement: "/$3"
replacement: "$1{{ $.Release.Name }}/$3"
{{- end }}
---
{{- if (and (.Values.ingress.enabled) (eq .Values.ingress.className "traefik")) }}
Expand Down Expand Up @@ -43,15 +44,15 @@ spec:
{{- if (or (eq $serviceName "raster") (eq $serviceName "stac") (eq $serviceName "vector")) }}
{{- if (and (index $v "enabled") (not $.Values.testing)) }}
- pathType: Prefix
path: "/{{ $serviceName }}(/|$)(.*)"
path: "/{{ $serviceName }}"
backend:
service:
name: {{ $serviceName }}
port:
number: {{ $.Values.service.port }}
{{- else if (and (index $v "enabled") ($.Values.testing)) }}
- pathType: Prefix
path: "/{{ $serviceName }}{{ $.Release.Name }}(/|$)(.*)"
path: "/{{ $serviceName }}{{ $.Release.Name }}"
backend:
service:
name: {{ $serviceName }}-{{ $.Release.Name }}
Expand Down
48 changes: 48 additions & 0 deletions helm-chart/eoapi/test-gcp-unittest-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# used in GH Actions `.github/workflows/helm-tests.yml.jobs.integration-tests`
testing: true
ingress:
enabled: true
className: "nginx"
pgstacBootstrap:
enabled: true
settings:
resources:
requests:
cpu: "256m"
memory: "1024Mi"
limits:
cpu: "512m"
memory: "1024Mi"
raster:
enabled: true
settings:
resources:
limits:
cpu: "768m"
memory: "4096Mi"
requests:
cpu: "256m"
memory: "1024Mi"
stac:
enabled: true
settings:
resources:
limits:
cpu: "1280m"
memory: "1536Mi"
requests:
cpu: "512m"
memory: "1024Mi"
vector:
enabled: true
settings:
resources:
limits:
cpu: "768m"
memory: "1536Mi"
requests:
cpu: "256m"
memory: "1024Mi"
envVars:
# needs to on so we can call /refresh for integration tests
TIPG_DEBUG: "True"