Skip to content

Add E2E tests for MySQL integration & JUnit test reports #896

Add E2E tests for MySQL integration & JUnit test reports

Add E2E tests for MySQL integration & JUnit test reports #896

Workflow file for this run

name: E2E Test
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
- labeled
workflow_dispatch:
inputs:
gcr-registry:
required: false
type: string
intents-operator-tag:
required: false
type: string
credentials-operator-tag:
required: false
type: string
workflow_call:
inputs:
github_ref:
required: false
type: string
gcr-registry:
required: false
type: string
intents-operator-tag:
required: false
type: string
credentials-operator-tag:
required: false
type: string
secrets:
AZURE_CREDENTIALS:
required: true
B64_GCLOUD_SERVICE_ACCOUNT_JSON:
required: false
jobs:
test-chart-deployment:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Set up Helm
uses: azure/[email protected]
- name: Start minikube
uses: medyagh/setup-minikube@master
with:
start-args: "--network-plugin=cni --cni=calico"
- name: Wait for Calico startup
run: |-
kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
kubectl wait pods -n kube-system -l k8s-app=calico-node --for condition=Ready --timeout=90s
kubectl wait pods -n kube-system -l k8s-app=calico-kube-controllers --for condition=Ready --timeout=90s
- name: Login to GCR
if: "${{ inputs.gcr-registry != '' }}"
uses: docker/login-action@v2
with:
registry: ${{ inputs.gcr-registry }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON}}
- name: Load intents-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
- name: Load credentials-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
- name: Deploy Otterize
run: |-
helm dep up ./otterize-kubernetes
# schema validation using kubectl dry run
OPERATOR_FLAGS=""
if [ -n "${{ inputs.intents-operator-tag }}" ]; then
OPERATOR_FLAGS="$OPERATOR_FLAGS --set-string intentsOperator.operator.repository=${{ inputs.gcr-registry }} --set-string intentsOperator.operator.image=intents-operator --set-string intentsOperator.operator.tag=${{ inputs.intents-operator-tag }} --set-string intentsOperator.operator.pullPolicy=Never"
fi
if [ -n "${{ inputs.credentials-operator-tag }}" ]; then
OPERATOR_FLAGS="$OPERATOR_FLAGS --set-string credentialsOperator.operator.repository=${{ inputs.gcr-registry }} --set-string credentialsOperator.operator.image=credentials-operator --set-string credentialsOperator.operator.tag=${{ inputs.credentials-operator-tag }} --set-string credentialsOperator.operator.pullPolicy=Never"
fi
TELEMETRY_FLAG="--set global.telemetry.enabled=false"
kubectl create namespace otterize-system # required for dry-run
helm template otterize ./otterize-kubernetes -n otterize-system $OPERATOR_FLAGS $TELEMETRY_FLAG | kubectl apply --dry-run=server -f -
kubectl delete namespace otterize-system # clean up
# installation
helm install otterize ./otterize-kubernetes -n otterize-system --wait --create-namespace $OPERATOR_FLAGS $TELEMETRY_FLAG
test-postgresql-integration:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Start minikube
uses: medyagh/setup-minikube@master
- name: Set up Helm
uses: azure/[email protected]
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
cache-dependency-path: tests/go.sum
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Helm dependency update
run: helm dep up ./otterize-kubernetes
- name: Login to GCR
if: "${{ inputs.gcr-registry != '' }}"
uses: docker/login-action@v2
with:
registry: ${{ inputs.gcr-registry }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON}}
- name: Load intents-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
- name: Load credentials-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
- name: Preload Postgres docker image
run: |
docker pull postgres:16.3
minikube image load postgres:16.3
- name: Run E2E tests - PostgreSQL integrations
run: |
cd tests
if [ -n "${{ inputs.intents-operator-tag }}" ]; then
export INTENTS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export INTENTS_OPERATOR_TAG=${{ inputs.intents-operator-tag }}
export INTENTS_OPERATOR_IMAGE=intents-operator
fi
if [ -n "${{ inputs.credentials-operator-tag }}" ]; then
export CREDENTIALS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export CREDENTIALS_OPERATOR_TAG=${{ inputs.credentials-operator-tag }}
export CREDENTIALS_OPERATOR_IMAGE=credentials-operator
fi
go test -v -json ./databases/postgresql/... | tee gotest.log | gotestfmt
test-mysql-integration:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Start minikube
uses: medyagh/setup-minikube@master
with:
cpus: 4
memory: 4096
- name: Set up Helm
uses: azure/[email protected]
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
cache-dependency-path: tests/go.sum
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Helm dependency update
run: helm dep up ./otterize-kubernetes
- name: Login to GCR
if: "${{ inputs.gcr-registry != '' }}"
uses: docker/login-action@v2
with:
registry: ${{ inputs.gcr-registry }}
username: _json_key_base64
password: ${{ secrets.B64_GCLOUD_SERVICE_ACCOUNT_JSON}}
- name: Load intents-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.intents-operator-tag }}
- name: Load credentials-operator docker image from GCR
if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}"
run: |-
docker pull ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
minikube image load ${{ inputs.gcr-registry }}/credentials-operator:${{ inputs.credentials-operator-tag }}
- name: Preload MySQL docker image
run: |
docker pull mysql:8.0
minikube image load mysql:8.0
- name: Setup upterm session
uses: lhotari/action-upterm@v1
with:
limit-access-to-actor: true
- name: Run E2E tests - MySQL integrations
run: |
cd tests
if [ -n "${{ inputs.intents-operator-tag }}" ]; then
export INTENTS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export INTENTS_OPERATOR_TAG=${{ inputs.intents-operator-tag }}
export INTENTS_OPERATOR_IMAGE=intents-operator
fi
if [ -n "${{ inputs.credentials-operator-tag }}" ]; then
export CREDENTIALS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}
export CREDENTIALS_OPERATOR_TAG=${{ inputs.credentials-operator-tag }}
export CREDENTIALS_OPERATOR_IMAGE=credentials-operator
fi
go test -v -json ./databases/mysql/... | tee gotest.log | gotestfmt
test-azure-integration:
if: contains(github.event.pull_request.labels.*.name, 'run-azure-e2e-tests') || (github.event_name == 'push' && github.repository == 'otterize/helm-charts' && startsWith(github.ref, 'refs/tags/'))
timeout-minutes: 5
runs-on: ubuntu-latest
concurrency:
group: azure-e2e-tests # do not allow concurrent runs of this job
cancel-in-progress: false
steps:
- name: Fail on custom registry
if: "${{ inputs.gcr-registry != '' }}"
run: |
echo "This job does not support custom docker registry"
exit 1
- name: Checkout repository
uses: actions/checkout@v4
with:
# explicitly checkout helm-charts repository since this is a reusable workflow that's called from other repositories
repository: 'otterize/helm-charts'
ref: ${{ inputs.github_ref }}
- name: Log in with Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure CLI script
uses: azure/CLI@v2
with:
inlineScript: |
az account show
- name: Set AKS context
uses: azure/aks-set-context@v4
with:
resource-group: 'otterizeGitHubActionsResourceGroup'
cluster-name: 'otterizeAzureIAME2EAKSCluster'
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Set up Helm
uses: azure/[email protected]
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
cache-dependency-path: tests/go.sum
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Helm dependency update
run: helm dep up ./otterize-kubernetes
- name: Cleanup test namespaces
run: |
kubectl delete namespace otterize-tutorial-azure-iam --ignore-not-found=true --wait
kubectl delete namespace otterize-system --ignore-not-found=true --wait
- name: Run E2E tests - Azure integrations
run: |
cd tests
go test -v -json ./azureiam/... | tee gotest.log | gotestfmt
e2e-test:
needs:
- test-chart-deployment
- test-postgresql-integration
- test-mysql-integration
runs-on: ubuntu-latest
steps:
- run: |-
echo Success! This step is only here to depend on the tests.