|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Install the primary site helm chart into a fresh minikube instance and validate that all the pods were created correctly. |
| 4 | +# |
| 5 | +# The host environment needs to have the following variables set: |
| 6 | +# - FOXGLOVE_API_URL: the URL to the API version being used |
| 7 | +# - FOXGLOVE_SITE_TOKEN: a site token for a primary site created with the above API |
| 8 | +# |
| 9 | +# The host also needs to have minio with an index-in-place bucket created. It can be started with the following: |
| 10 | +# ``` |
| 11 | +# docker compose up -d |
| 12 | +# ``` |
| 13 | +# |
| 14 | +# When everything is ready, run the tests with `./test-index-in-place-primary-site-chart.sh ./charts/primary-site`. |
| 15 | + |
| 16 | +set -euo pipefail |
| 17 | + |
| 18 | +chart="${1:-""}" |
| 19 | + |
| 20 | +if [ -z "$chart" ]; then |
| 21 | + echo "usage: ./test-index-in-place-primary-site-chart.sh <path to primary site chart>" |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +context="$(kubectl config current-context)"; |
| 26 | + |
| 27 | +if [ "$context" != "minikube" ]; then |
| 28 | + echo "Tests can only be run against minikube. Tried to run against: $context." |
| 29 | + exit 1 |
| 30 | +fi |
| 31 | + |
| 32 | +api_url="${FOXGLOVE_API_URL}" |
| 33 | +site_token="${FOXGLOVE_SITE_TOKEN}" |
| 34 | + |
| 35 | +cloud_credentials_file="$(mktemp --suffix .yaml)" |
| 36 | + |
| 37 | +cat >>"$cloud_credentials_file" <<EOF |
| 38 | +apiVersion: v1 |
| 39 | +kind: Secret |
| 40 | +metadata: |
| 41 | + name: cloud-credentials |
| 42 | +type: Opaque |
| 43 | +stringData: |
| 44 | + S3_COMPATIBLE_ACCESS_KEY_ID: root |
| 45 | + S3_COMPATIBLE_SECRET_ACCESS_KEY: password |
| 46 | + S3_COMPATIBLE_SERVICE_REGION: default |
| 47 | + S3_COMPATIBLE_SERVICE_URL: http://host.minikube.internal:9000 |
| 48 | +EOF |
| 49 | + |
| 50 | +trap "rm $cloud_credentials_file" EXIT |
| 51 | + |
| 52 | +set -x |
| 53 | + |
| 54 | +kubectl create namespace foxglove |
| 55 | + |
| 56 | +kubectl create secret generic foxglove-site-token \ |
| 57 | + --from-literal="FOXGLOVE_SITE_TOKEN=$site_token" \ |
| 58 | + --namespace foxglove |
| 59 | + |
| 60 | +kubectl apply -f "$cloud_credentials_file" --namespace foxglove |
| 61 | + |
| 62 | +helm upgrade --install foxglove-primary-site "$chart" \ |
| 63 | + --namespace foxglove \ |
| 64 | + --set globals.foxgloveApiUrl="$api_url" \ |
| 65 | + --set globals.indexingStrategy="index-in-place" \ |
| 66 | + --set globals.indexInPlace.storageProvider="s3_compatible" |
| 67 | + |
| 68 | +log_and_exit() { |
| 69 | + kubectl get pods -n foxglove |
| 70 | + kubectl get events -n foxglove |
| 71 | + kubectl logs -n foxglove deployment/indexer |
| 72 | + kubectl logs -n foxglove deployment/query-service |
| 73 | + kubectl logs -n foxglove deployment/site-controller |
| 74 | + exit 1 |
| 75 | +} |
| 76 | + |
| 77 | +wait_for_deployment() { |
| 78 | + kubectl wait --for=condition=available deployment "$1" --namespace foxglove --timeout=90s || log_and_exit |
| 79 | +} |
| 80 | + |
| 81 | +wait_for_pod() { |
| 82 | + kubectl wait --for=condition=ready pod -l "app=$1" --namespace foxglove --timeout=90s || log_and_exit |
| 83 | +} |
| 84 | + |
| 85 | +# Wait for each of the deployments to complete to make sure pods are created |
| 86 | +wait_for_deployment site-controller |
| 87 | +wait_for_deployment indexer |
| 88 | +wait_for_deployment query-service |
| 89 | + |
| 90 | +# Wait for each of the pods to complete to make sure they didn't fail |
| 91 | +wait_for_pod site-controller |
| 92 | +wait_for_pod indexer |
| 93 | +wait_for_pod query-service |
0 commit comments