.github/workflows/test-e2e.yml #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E tests. | |
on: | |
workflow_call: | |
inputs: | |
forked: | |
type: boolean | |
required: false | |
default: false | |
workflow_dispatch: | |
jobs: | |
prepare-e2e: | |
name: Prepare E2E configuration and image | |
runs-on: ubuntu-latest | |
env: | |
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/mongodb-atlas-kubernetes-operator-prerelease | |
steps: | |
- if: ${{ inputs.forked == false }} | |
name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- if: ${{ inputs.forked == true }} | |
name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
ref: ${{github.event.pull_request.head.sha}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
fetch-depth: 0 | |
- name: Prepare tag | |
id: prepare | |
uses: ./.github/actions/set-tag | |
- name: Log in to ghcr.io registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Build and Push to ${{ steps.prepare.outputs.tag }} | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
build-args: VERSION=${{ steps.prepare.outputs.tag }} | |
platforms: linux/amd64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
sbom: true | |
push: true | |
tags: ${{ steps.prepare.outputs.tag }} | |
prepare-e2e-bundle: | |
name: Prepare E2E Bundle configuration and image | |
runs-on: ubuntu-latest | |
env: | |
GHCR_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease | |
GHCR_BUNDLES_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease | |
steps: | |
- if: ${{ inputs.forked == false }} | |
name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- if: ${{ inputs.forked == true }} | |
name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
ref: ${{github.event.pull_request.head.sha}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
fetch-depth: 0 | |
- name: Prepare tag | |
id: prepare | |
uses: ./.github/actions/set-tag | |
- name: Generate configuration for the tests | |
uses: ./.github/actions/gen-install-scripts | |
with: | |
IMAGE_URL: ${{ env.GHCR_REPO }}:${{ steps.prepare.outputs.tag }} | |
VERSION: ${{ steps.prepare.outputs.tag }} | |
ENV: dev | |
- name: Change path for the test | |
run: | | |
awk '{gsub(/cloud.mongodb.com/, "cloud-qa.mongodb.com", $0); print}' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > tmp && mv tmp bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml | |
- name: Cache repo files | |
uses: actions/cache@v3 | |
with: | |
path: | | |
./* | |
key: ${{ github.sha }} | |
- name: Check go dependencies | |
id: cache-go | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-full-${{ hashFiles('**/go.sum') }} | |
- name: Get go dependencies if cache is missed | |
if: steps.cache-go.outputs.cache-hit != 'true' | |
run: | | |
cd cmd/manager | |
go get -d | |
- name: Prepare docker tag | |
id: prepare-docker-bundle-tag | |
run: | | |
REPOSITORY=${{ env.GHCR_BUNDLES_REPO }} | |
TAG=${{ steps.prepare.outputs.tag }} | |
TAGS="${REPOSITORY}:${TAG}" | |
echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
- name: Log in to ghcr.io registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Build and Push image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: bundle.Dockerfile | |
build-args: VERSION=${{ steps.prepare.outputs.tag }} | |
platforms: linux/amd64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
sbom: true | |
push: true | |
tags: ${{ steps.prepare.outputs.tag }} | |
e2e: | |
name: E2E tests | |
needs: [prepare-e2e, prepare-e2e-bundle] | |
runs-on: ubuntu-latest | |
env: | |
GHCR_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease | |
GHCR_BUNDLES_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease | |
strategy: | |
fail-fast: false | |
matrix: | |
# k8s: ["1.17-kind", "1.19-kind", "1.17-opeshift"] # <supported platform version>-<platform> | |
k8s: [ "v1.21.1-kind" ] # <K8sGitVersion>-<Platform> | |
test: | |
[ | |
"alert-config", | |
"auditing", | |
# "bundle-test", | |
"cloud-access-role", | |
"deployment-annotations-ns", | |
"deployment-ns", | |
"deployment-wide", | |
"encryption-at-rest", | |
"free-tier", | |
"global-deployment", | |
"helm-ns", | |
"helm-update", | |
"helm-wide", | |
"integration-ns", | |
"long-run", | |
"multinamespaced", | |
"networkpeering", | |
"privatelink", | |
"project-settings", | |
"serverless-pe", | |
"x509auth", | |
"custom-roles", | |
"teams", | |
"backup-config", | |
"data-federation", | |
"deletion-protection" | |
] | |
steps: | |
- name: Get repo files from cache | |
id: get-repo-files-from-cache | |
uses: actions/cache@v3 | |
with: | |
path: ./* | |
key: ${{ github.sha }} | |
- name: Checkout if cache repo files missed | |
if: steps.get-repo-files-from-cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Get all go dependencies | |
id: get-go-deps | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-full-${{ hashFiles('**/go.sum') }} | |
- name: Get go dependencies if cache is missed | |
if: steps.get-go-deps.outputs.cache-hit != 'true' | |
run: | | |
cd cmd/manager | |
go get -d | |
- name: Prepare tag | |
id: prepare | |
uses: ./.github/actions/set-tag | |
- name: Set properties | |
id: properties | |
run: | | |
version=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $1}') | |
platform=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $2}') | |
echo "k8s_version=$version" >> $GITHUB_OUTPUT | |
echo "k8s_platform=$platform" >> $GITHUB_OUTPUT | |
- name: Generate configuration for the tests | |
uses: ./.github/actions/gen-install-scripts | |
with: | |
IMAGE_URL: ${{ env.GHCR_REPO }}:${{ steps.prepare.outputs.tag }} | |
VERSION: ${{ steps.prepare.outputs.tag }} | |
ENV: dev | |
- name: Change path for the test | |
run: | | |
awk '{gsub(/cloud.mongodb.com/, "cloud-qa.mongodb.com", $0); print}' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > tmp && mv tmp bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml | |
- name: Create k8s Kind Cluster | |
if: ${{ steps.properties.outputs.k8s_platform == 'kind' && !env.ACT }} | |
uses: helm/kind-action@v1.8.0 | |
with: | |
version: v0.11.1 | |
config: test/e2e/config/kind.yaml | |
node_image: kindest/node:${{ steps.properties.outputs.k8s_version }} | |
cluster_name: ${{ matrix.test }} | |
wait: 180s | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: "${{ github.workspace }}/go.mod" | |
- name: Install operator-sdk-v1.22.0 | |
run: | | |
wget https://github.com/operator-framework/operator-sdk/releases/download/v1.22.0/operator-sdk_linux_amd64 -q | |
chmod +x operator-sdk_linux_amd64 && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk | |
operator-sdk version | |
- name: Print kubectl version | |
run: | | |
kubectl version | |
- name: Install CRDs if needed | |
if: ${{ !( matrix.test == 'helm-update' || matrix.test == 'helm-wide' || matrix.test == 'helm-ns' || matrix.test == 'bundle-test' ) }} | |
run: | | |
kubectl apply -f deploy/crds | |
- name: Run e2e test | |
env: | |
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }} | |
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }} | |
MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}} | |
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/" | |
IMAGE_URL: "${{ env.GHCR_REPO }}:${{ steps.prepare.outputs.tag }}" | |
BUNDLE_IMAGE: "${{ env.GHCR_BUNDLES_REPO}}:${{ steps.prepare.outputs.tag }}" | |
K8S_PLATFORM: "${{ steps.properties.outputs.k8s_platform }}" | |
K8S_VERSION: "${{ steps.properties.outputs.k8s_version }}" | |
TEST_NAME: "${{ matrix.test }}" | |
OPENSHIFT_USER: ${{ secrets.OPENSHIFT_USER }} | |
OPENSHIFT_PASS: ${{ secrets.OPENSHIFT_PASS }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID_NEW_TEST }} | |
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET_NEW_TEST }} | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
GCP_SA_CRED: ${{ secrets.GCP_SA_CRED_NEW_TEST }} | |
DATADOG_KEY: ${{ secrets.DATADOG_KEY }} | |
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }} | |
run: | | |
helm version | |
go version | |
GOWORK=off go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo && \ | |
go install github.com/onsi/gomega/... | |
cd test/e2e | |
# no `long-run`, no `broken` tests. `Long-run` tests run as a separate job | |
[[ $TEST_NAME == 'long-run' ]] && filter='long-run && !broken' || filter="$TEST_NAME"' && !long-run && !broken' && \ | |
echo 'Running: AKO_E2E_TEST=1 ginkgo --label-filter="${filter}" --timeout 120m --nodes=10 --cover --v' && \ | |
AKO_E2E_TEST=1 ginkgo --label-filter="${filter}" --timeout 120m --nodes=10 --flake-attempts=1 --cover --v --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/pkg/... | |
- name: Upload operator logs | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: logs | |
path: test/e2e/output/** | |
- name: Upload test results to codecov.io | |
if: ${{ success() }} | |
uses: codecov/codecov-action@v3 | |
with: | |
files: test/e2e/coverprofile.out | |
name: ${{ matrix.test }} | |
verbose: true |