Skip to content

(E2E) Phone Home Tests #112

(E2E) Phone Home Tests

(E2E) Phone Home Tests #112

name: (E2E) Phone Home Tests
on:
workflow_dispatch:
schedule:
- cron: "0 9 * * *"
env:
GCP_PROJECT_ID: hazelcast-33
GKE_ZONE: us-east1-b
BIG_QUERY_TABLE: hazelcast-33.callHome.operator_info
GAR_REGION: us-east1
GAR_PROJECT: hazelcast-33
GAR_REPO: hazelcast-platform-operator
AWS_REGION: us-east-1
jobs:
create-gke-cluster:
name: Create GKE cluster
runs-on: ubuntu-latest
outputs:
CLUSTER_NAME: ${{ steps.set-cluster-name.outputs.CLUSTER_NAME }}
env:
GCP_NETWORK: operator-test-network
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
GKE_SA_KEY,CN/GKE_SA_KEY
- name: Authenticate to GCP
uses: 'google-github-actions/auth@v2.1.2'
with:
credentials_json: ${{ env.GKE_SA_KEY }}
- name: Create GKE cluster
id: set-cluster-name
run: |-
CLUSTER_NAME="operator-ph-test-${GITHUB_SHA::8}-${{ github.run_number }}"
echo "CLUSTER_NAME=${CLUSTER_NAME}" >> $GITHUB_OUTPUT
gcloud container clusters create ${CLUSTER_NAME} \
--zone=${{ env.GKE_ZONE }} \
--project=${{ env.GCP_PROJECT_ID }} \
--network=${{ env.GCP_NETWORK }} \
--machine-type=n1-standard-2 \
--workload-pool=${{ env.GCP_PROJECT_ID }}.svc.id.goog \
--num-nodes=3
sleep 30
grafana-setup:
needs: [ create-gke-cluster ]
uses: ./.github/workflows/grafana-agent.yaml
secrets: inherit
with:
cluster_name: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
cluster_type: gke-phone-home
gh_run_id: ${{ github.run_id }}
gh_run_number: ${{ github.run_number }}
gh_sha: ${{ github.sha }}
namespaces: test-operator-ph-nightly-ee
get-image:
name: Get Image
runs-on: ubuntu-latest
outputs:
IMG: ${{ steps.get-image-tag.outputs.IMG }}
VERSION: ${{ steps.get-image-tag.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set Up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.3.0
with:
install: true
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
GKE_SA_KEY,CN/GKE_SA_KEY
- name: Authenticate to GAR
uses: docker/login-action@v3
with:
registry: us-east1-docker.pkg.dev
username: _json_key
password: ${{ env.GKE_SA_KEY }}
- name: Generate Image Name
id: get-image-tag
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
echo "IMG=${{ env.GAR_REGION }}-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REPO }}/$(uuidgen):5d" >> $GITHUB_OUTPUT
echo "VERSION=${{github.sha}}" >> $GITHUB_OUTPUT
else
IMG=hazelcast/hazelcast-platform-operator:latest-snapshot
echo "IMG=${IMG}" >> $GITHUB_OUTPUT
echo "VERSION=latest-snapshot" >> $GITHUB_OUTPUT
fi
- name: Build Image
if: github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v5.3.0
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
build-args: |
version=${{github.sha}}
pardotID=dockerhub
file: Dockerfile
push: true
tags: ${{ steps.get-image-tag.outputs.IMG }}
cache-from: type=registry,ref=${{ env.GAR_REGION }}-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REPO }}/${{ hashFiles('Dockerfile','main.go','api/**','controllers/**','internal/**','licenses/**','**/go.mod','**/go.sum') }}:14d
cache-to: type=registry,ref=${{ env.GAR_REGION }}-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REPO }}/${{ hashFiles('Dockerfile','main.go','api/**','controllers/**','internal/**','licenses/**','**/go.mod','**/go.sum') }}:14d
gke-ph-tests:
name: Run PhoneHome tests
runs-on: ubuntu-latest
needs: [create-gke-cluster, grafana-setup, get-image]
env:
IMG: ${{ needs.get-image.outputs.IMG }}
VERSION: ${{ needs.get-image.outputs.VERSION }}
NAMESPACE: test-operator-ph-nightly-ee
PHONE_HOME_ENABLED: true
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
RELEASE_NAME: hp-ee-${{ github.run_id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.0"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
GKE_SA_KEY,CN/GKE_SA_KEY
HZ_LICENSE_KEY,CN/HZ_LICENSE_KEY
- name: Authenticate to GCP
uses: "google-github-actions/auth@v2.1.2"
with:
credentials_json: ${{ env.GKE_SA_KEY }}
- name: Connect to the GKE cluster
uses: 'google-github-actions/get-gke-credentials@v2'
with:
cluster_name: ${{ env.CLUSTER_NAME }}
project_id: ${{ env.GCP_PROJECT_ID }}
location: ${{ env.GKE_ZONE }}
- name: Authenticate to GAR
uses: docker/login-action@v3
with:
registry: us-east1-docker.pkg.dev
username: _json_key
password: ${{ env.GKE_SA_KEY }}
- name: Deploy Operator to GKE
run: |
kubectl create namespace ${{ env.NAMESPACE }}
kubectl config set-context --current --namespace=$NAMESPACE
DEPLOY_NAME=${RELEASE_NAME}-hazelcast-platform-operator
echo "DEPLOY_NAME=${DEPLOY_NAME}" >> $GITHUB_ENV
make deploy IMG=$IMG NAMESPACE=$NAMESPACE RELEASE_NAME=$RELEASE_NAME PHONE_HOME_ENABLED=${{ env.PHONE_HOME_ENABLED }}
kubectl rollout status deployment $DEPLOY_NAME
- name: Create secrets
run: |
kubectl create secret generic hazelcast-license-key \
--namespace ${{ env.NAMESPACE }} --from-literal=license-key=${{ env.HZ_LICENSE_KEY }}
- name: Run Hazelcast Phone Home tests at GKE
id: ph-test
run: |
make test-ph GO_TEST_FLAGS=${GO_TEST_FLAGS} NAMESPACE=$NAMESPACE RELEASE_NAME=$RELEASE_NAME REPORT_SUFFIX=ee_01 WORKFLOW_ID=ph
- name: Clean up after Tests
if: always()
run: |
make clean-up-namespace NAMESPACE=${NAMESPACE}
- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report-ph
path: allure-results/ph/
report-generation:
needs: ["create-gke-cluster", "gke-ph-tests"]
if: always() && (needs.gke-ph-tests.result == 'success' || needs.gke-ph-tests.result == 'failure')
uses: ./.github/workflows/generate-test-report.yaml
secrets: inherit
with:
WORKFLOW_ID: ph
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
cleanup-namespaces:
if: always()
needs: ["create-gke-cluster", "gke-ph-tests"]
uses: ./.github/workflows/cleanup-namespace.yaml
secrets: inherit
with:
cluster_name: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
cluster_type: gke-phone-home
namespaces: "test-operator-ph-nightly-ee,grafana"
delete-cluster:
name: Delete PhoneHome cluster
runs-on: ubuntu-latest
if: always()
needs: [create-gke-cluster, gke-ph-tests, cleanup-namespaces]
env:
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
GKE_SA_KEY,CN/GKE_SA_KEY
- name: Authenticate to GCP
uses: "google-github-actions/auth@v2.1.2"
with:
credentials_json: ${{ env.GKE_SA_KEY }}
- name: Delete GKE cluster
run: |-
gcloud container clusters delete ${{ env.CLUSTER_NAME }} --zone ${{ env.GKE_ZONE }} --quiet
slack_notify:
name: Slack Notify
needs: ["gke-ph-tests", "delete-cluster"]
if: always() && ( needs.gke-ph-tests.result != 'success' || needs.delete-cluster.result != 'success')
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
SLACK_WEBHOOK_URL,CN/SLACK_WEBHOOK_URL
- uses: 8398a7/action-slack@v3
with:
fields: repo,commit,author,action,eventName,workflow
status: failure
channel: "#github-actions-log"
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}