From e4280eaf3037c8b9b412263c0ab6d61759667dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20No=C3=ABl?= Date: Sat, 7 Sep 2024 10:22:15 -0400 Subject: [PATCH] Add test --- .DS_Store | Bin 0 -> 6148 bytes .github/.DS_Store | Bin 0 -> 6148 bytes .github/workflows/test-helm-chart.yml | 320 ++++++++++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 .DS_Store create mode 100644 .github/.DS_Store create mode 100644 .github/workflows/test-helm-chart.yml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e019e1534ffe6af15b6a9129dd0e34a18ce4c29 GIT binary patch literal 6148 zcmeHK%Wl&^6upy%#z{qq5J=r1Sz;SX+CmXx6OtHIsiaaJ=mJoP8%kIraJUdH?D zpS``wXrR9h-@HK>jN)qbJIk%*Z>$%rg0*42chC65jl1!9RPPSoie8)Z&|9>--kZRm zbjo)cJc_$PUGQyomTGnI$oN%cR}ZxPZ@SWHh*Rhf&C*K4t`~bfr)LMI+)g zBtNYay9d9ds_S$LJ-hIXX_WC55tF{RsX<57B!?aVU!WHK7Dis9)kgFS>SfmWky)d3 zwZ;*hfa}mPxoJ*L{gVEhG=O%TF2RVvjG(74e}@6})3KP)Gs!I?9|zCdL`-K{E=;JG zWRxW1P_mHAGLBR)$-xpUX?mYq8!P#A=An!NMuC5+fcQSxC<1F5=L+Sg1C_i20P`4@ zhPM3c546Pqu%>aY5F;?As6a(!`ijBy&4DR8=4;x2u29j5$;enoM`rql!t}+1+0va@ zO`)lc0!D$f0&A*U7U#e7`}=>IWO_ycqriWq0LwSsW*sT%v-MhX;;gk%KA;E_eshJA lf=VC9vLTM*Efi^(vqb|~(>Pa%5t#WSAZ0L>QQ)sC@CyON?9u=L literal 0 HcmV?d00001 diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7729569e08bb4c0030c943ba1790303b38438e28 GIT binary patch literal 6148 zcmeHKO>fgc5S>j!V^e{00I3(GmAFPBZD}jS#SP`a6(cwR3U(8~bhBI8POU16u9t||a5ml{>Jm`^*VqctTw}Ul`--((W)sNF zJrqeQo(Xl5ij``g_!||_&#prWolr>`{qp=&iXQ!19KriPj3FYrNmEoxQ{ATvaHk~f zGr#0~y~4RoIZeP(bdLHGai2a>VaD5E=CXTNxFJ=j%juNflR#88Z&))L`|^86S`}xh zFpO{MnaGNAF!;_|8|@pLouCtJ1#jbzs*1~`oE5_)f32@xC?(P+PSTgzq#AYaJW;Yt zGC9c&AsbIn^5#`0$Eq5tnH(2}8{3W`48l=&dp_Si-0$(dgPlc>&mZj$di>$u!D0~x zcke%V{CspOrc!;zEMN>@lCfJ38_=`7MvL<}mqN)8=xvw{!=qQgE8rDar+`~8f~|E0 zKJOLq3jDVU==FiaHAW6=i)QISV~zm8Hqyor>z_u=;SM8*wMF#6n568aJA5!VGIJ*sW=6;TxhW?WS@f+}z$>tiz%e`t$!X$zOQ|yaNA} z0<3);9}h7lx3{iLPVcoG{tm89*VPs;DG1C~j9R@FZ^Mlt&vgKd9M%?*f%zW+BZF_e I0)JG2pPNU97ytkO literal 0 HcmV?d00001 diff --git a/.github/workflows/test-helm-chart.yml b/.github/workflows/test-helm-chart.yml new file mode 100644 index 000000000..d6e936908 --- /dev/null +++ b/.github/workflows/test-helm-chart.yml @@ -0,0 +1,320 @@ +# workflows/test-helm-chart.yml +# +# Test Helm Chart +# Test the ParadeDB Helm chart against a local Minikube cluster and a local AWS EKS cluster. + +name: Test Helm Chart + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "charts/paradedb/*" + - ".github/workflows/test-helm-chart.yml" + workflow_dispatch: + +concurrency: + group: test-helm-chart-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + test-helm-minikube: + name: Test Helm Chart on Minikube + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + + steps: + - name: Checkout Git Repository + uses: actions/checkout@v4 + + - name: Set up Kubectl + uses: azure/setup-kubectl@v4 + + - name: Set up Helm + uses: azure/setup-helm@v4 + + # Enables the default-storageclass and storage-provisioner addons by default + - name: Set up & Start Minikube + uses: medyagh/setup-minikube@latest + + - name: Install the CloudNativePG Operator + run: | + helm repo add cnpg https://cloudnative-pg.github.io/charts + helm upgrade --install cnpg --namespace cnpg-system --create-namespace cnpg/cloudnative-pg + + - name: Wait for CNPG Webhook Service to be Ready + run: | + kubectl wait --namespace cnpg-system --for=condition=available --timeout=120s deployment/cnpg-cloudnative-pg + kubectl get svc -n cnpg-system cnpg-webhook-service + + - name: Test Helm Dependency Update + working-directory: charts/paradedb/ + run: helm dependency update . --debug + + - name: Update appVersion to Latest paradedb/paradedb Tag + working-directory: charts/paradedb/ + run: | + # Fetch the latest release tag and strip the 'v' prefix + LATEST_TAG=$(curl -s https://api.github.com/repos/paradedb/paradedb/releases/latest | jq -r '.tag_name') + CLEANED_TAG=${LATEST_TAG#v} + + # Update the appVersion in the Chart.yaml file + sed -i "s/^appVersion: .*/appVersion: $CLEANED_TAG/" Chart.yaml + cat Chart.yaml + + - name: Test Helm Template + working-directory: charts/paradedb/ + run: helm template paradedb . --debug + + - name: Test Helm Install + working-directory: charts/paradedb/ + run: helm install paradedb . --namespace paradedb --create-namespace --debug + + - name: Test Helm Upgrade + working-directory: charts/paradedb/ + run: helm upgrade paradedb . --namespace paradedb --debug + + # TODO: This fails + - name: Test PostgreSQL Connection + run: | + # Get the ParadeDB K8s cluster secrets + kubectl -n paradedb get secrets paradedb-app -o yaml + + # Decode the ParadeDB K8s cluster secrets + export PG_USERNAME=$(kubectl -n paradedb get secrets paradedb-app -o jsonpath="{.data.username}" | base64 --decode) + export PG_PASSWORD=$(kubectl -n paradedb get secrets paradedb-app -o jsonpath="{.data.password}" | base64 --decode) + export PG_DATABASE=$(kubectl -n paradedb get secrets paradedb-app -o jsonpath="{.data.dbname}" | base64 --decode) + + # Wait for PostgreSQL to be ready + sleep 30 + + # Check if any pods were found + POD_NAMES=$(kubectl -n paradedb get pods --no-headers | grep 'paradedb-1-initdb-' | awk '{print $1}') + if [ -n "$POD_NAMES" ]; then + for POD_NAME in $POD_NAMES; do + echo "Fetching details for pod $POD_NAME..." + kubectl -n paradedb describe pod $POD_NAME + + echo "Fetching logs for pod $POD_NAME..." + kubectl -n paradedb logs $POD_NAME || echo "No current logs available for $POD_NAME." + echo "--------------------------------------" + done + else + echo "No pods matching the pattern found." + fi + + echo "Fetching details for all resources in the paradedb namespace..." + kubectl -n paradedb get all + + echo "Waiting for the paradedb-rw service to be ready..." + while [[ $(kubectl -n paradedb get pods -l app=paradedb -o jsonpath="{.items[*].status.containerStatuses[*].ready}") != "true" ]]; do + echo "Waiting for pod(s) to be ready..." + sleep 5 + done + + echo "Starting port-forward..." + kubectl port-forward svc/paradedb-rw 5432:5432 & + + echo "Connecting to ParadeDB via psql..." + psql -h localhost -p 5432 -U $PG_USERNAME -d $PG_DATABASE -c "SELECT * FROM pg_extension;" + + - name: Test Helm Uninstall + run: helm uninstall paradedb --namespace paradedb --debug + + test-helm-eks: + name: Test Helm Chart on AWS EKS via LocalStack + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + + steps: + - name: Checkout Git Repository + uses: actions/checkout@v4 + + - name: Set up Kubectl + uses: azure/setup-kubectl@v4 + + - name: Set up Helm + uses: azure/setup-helm@v4 + + - name: Start LocalStack + uses: LocalStack/setup-localstack@v0.2.2 + with: + image-tag: "latest" + install-awslocal: "true" + configuration: DEBUG=1 + use-pro: "true" + env: + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + + - name: Configure AWS CLI for LocalStack + run: | + awslocal configure set aws_secret_access_key test + awslocal configure set aws_access_key_id test + awslocal configure set region us-east-1 + + # As of writing, the latest Kubernetes version available on LocalStack EKS + # is 1.29. CloudNativePG requires version 1.25+ + - name: Create the LocalStack AWS EKS Cluster + run: | + awslocal --endpoint-url=http://localhost:4566 eks create-cluster \ + --name paradedb-eks \ + --role-arn arn:aws:iam::000000000000:role/eks-service-role \ + --resources-vpc-config subnetIds=subnet-12345 \ + --kubernetes-version 1.29 + + - name: Wait for LocalStack AWS EKS Cluster to be Active + run: | + for i in {1..10}; do + STATUS=$(awslocal --endpoint-url=http://localhost:4566 --region us-east-1 eks describe-cluster --name paradedb-eks --query 'cluster.status' --output text) + if [ "$STATUS" == "ACTIVE" ]; then + echo "Cluster is ACTIVE" + break + else + echo "Cluster status is $STATUS. Waiting..." + sleep 10 + fi + done + + - name: Update Kubeconfig to Use the LocalStack AWS EKS Cluster + run: awslocal --endpoint-url=http://localhost:4566 eks update-kubeconfig --name paradedb-eks + + - name: Wait for the LocalStack AWS EKS Cluster to be Ready + run: | + nodes=$(kubectl get nodes --no-headers -o custom-columns=NAME:.metadata.name) + for node in $nodes; do + kubectl wait --for=condition=ready node/$node --timeout=120s + done + + # This is required to mock the AWS EKS storage class + - name: Create StorageClass + run: | + cat <