Skip to content

Add ServiceMonitor resources for both HiveMQ Platform Operator Helm charts and HiveMQ Platform Helm charts #1031

Add ServiceMonitor resources for both HiveMQ Platform Operator Helm charts and HiveMQ Platform Helm charts

Add ServiceMonitor resources for both HiveMQ Platform Operator Helm charts and HiveMQ Platform Helm charts #1031

Workflow file for this run

name: Smoke Test
on:
pull_request:
branches:
- "**"
workflow_dispatch:
concurrency:
group: smoke-test-${{ github.ref }}
cancel-in-progress: true
env:
RELEASE_NAME: "smoke-test-release"
jobs:
smoke-test-platform:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
permissions:
contents: read
packages: write
steps:
- name: Get binaries
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Login to Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Platform Operator on the default branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: hivemq/hivemq-platform-operator
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
path: hivemq-platform-operator
- name: Checkout HiveMQ Platform Operator on the same or target branch
working-directory: ${{ github.workspace }}/hivemq-platform-operator
run: |
echo "Checking if branch \"${GITHUB_HEAD_REF}\" exists on hivemq-platform-operator"
BRANCH=$(git ls-remote origin ${GITHUB_HEAD_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out branch with the same name"
git fetch --all
git checkout origin/${GITHUB_HEAD_REF}
exit
fi
if [[ "${GITHUB_BASE_REF}" == "master" ]]; then
exit
fi
echo "Checking if branch \"${GITHUB_BASE_REF}\" exists on hivemq-platform-operator"
BRANCH=$(git ls-remote origin ${GITHUB_BASE_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out target branch"
git fetch --all
git checkout origin/${GITHUB_BASE_REF}
fi
- name: Set up JDK 21
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4
with:
gradle-home-cache-includes: |
caches
notifications
jdks
- name: Build HiveMQ Platform Operator and HiveMQ Platform Operator Init images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-platform-operator:build :tests-hivemq-platform-operator:saveDockerImages
- name: Start up KinD cluster with local images
working-directory: ${{ github.workspace }}/helm-charts
run: |
kind create cluster
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform-operator-init.tar
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform-operator.tar
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform.tar
- name: Install HiveMQ Platform Operator
working-directory: ${{ github.workspace }}/helm-charts
run: helm install operator-test --set image.name=hivemq-platform-operator-test --set image.initImageName=hivemq-platform-operator-init-test --set image.tag=snapshot ./charts/hivemq-platform-operator --wait
- name: Install HiveMQ Platform
working-directory: ${{ github.workspace }}/helm-charts
run: helm install $RELEASE_NAME --set nodes.replicaCount=1,nodes.resources.cpu=512m ./charts/hivemq-platform --wait --create-namespace -n test
- name: Test HiveMQ Platform
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME -n test
- name: Capture HiveMQ Platform Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/operator-pod.log
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n test > ${{ runner.temp }}/logs/platform-pod.log
- name: Upload HiveMQ Platform Pods logs on failure
if: failure()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Platform charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait -n test
helm uninstall operator-test --wait
kubectl get pods -A
smoke-test-legacy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
permissions:
contents: read
packages: write
steps:
- name: Get binaries
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Login to Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Operator (legacy) on the default branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: hivemq/hivemq-operator
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
path: hivemq-operator
- name: Checkout HiveMQ Operator (legacy) on the same or target branch
working-directory: ${{ github.workspace }}/hivemq-operator
run: |
echo "Checking if branch \"${GITHUB_HEAD_REF}\" exists on hivemq-operator"
BRANCH=$(git ls-remote origin ${GITHUB_HEAD_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out branch with the same name"
git fetch --all
git checkout origin/${GITHUB_HEAD_REF}
exit
fi
if [[ "${GITHUB_BASE_REF}" == "master" ]]; then
exit
fi
echo "Checking if branch \"${GITHUB_BASE_REF}\" exists on hivemq-operator"
BRANCH=$(git ls-remote origin ${GITHUB_BASE_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out target branch"
git fetch --all
git checkout origin/${GITHUB_BASE_REF}
fi
- name: Set up JDK 21
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4
with:
gradle-home-cache-includes: |
caches
notifications
jdks
- name: Build HiveMQ Operator (legacy) images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-operator:build :tests-hivemq-operator:saveDockerImages
- name: Start up KinD cluster with local images
working-directory: ${{ github.workspace }}/helm-charts
run: |
kind create cluster
kind load image-archive ./tests-hivemq-operator/build/hivemq-dns-init-wait.tar
kind load image-archive ./tests-hivemq-operator/build/hivemq-k8s.tar
kind load image-archive ./tests-hivemq-operator/build/hivemq-operator.tar
- name: Install HiveMQ Operator (legacy)
working-directory: ${{ github.workspace }}/helm-charts
run: |
helm repo add prometheus https://prometheus-community.github.io/helm-charts
helm dependency build ./charts/hivemq-operator
helm install $RELEASE_NAME ./charts/hivemq-operator -f ./examples/hivemq-operator/localStatefulTest.yml --wait --create-namespace -n test
- name: Test HiveMQ Cluster
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l hivemq-cluster=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME -n test
- name: Capture HiveMQ Operator (legacy) Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/operator-pod.log
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n test > ${{ runner.temp }}/logs/platform-pod.log
- name: Upload HiveMQ Operator (legacy) Pods logs on failure
if: failure()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Operator (legacy) charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait -n test
kubectl get pods -A