-
Notifications
You must be signed in to change notification settings - Fork 2
test: add live migration test suite #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tmshort
wants to merge
3
commits into
operator-framework:main
Choose a base branch
from
tmshort:migration-live-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: migration-test | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| merge_group: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| unit-coverage: | ||
| name: migration unit coverage | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-go@v7 | ||
| with: | ||
| go-version-file: go.mod | ||
| - name: Run unit tests with coverage | ||
| run: make migration/test-coverage | ||
| - name: Upload unit coverage | ||
| if: always() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: migration-unit-coverage | ||
| path: artifacts/coverage | ||
| if-no-files-found: ignore | ||
|
|
||
| coverage: | ||
| name: migration total coverage | ||
| needs: [unit-coverage, live] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-go@v7 | ||
| with: | ||
| go-version-file: go.mod | ||
| - name: Download unit coverage | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: migration-unit-coverage | ||
| path: artifacts/coverage | ||
| - name: Download live E2E coverage | ||
| uses: actions/download-artifact@v8 | ||
| with: | ||
| name: migration-live-e2e-artifacts | ||
| path: artifacts/e2e | ||
| - name: Display combined coverage | ||
| run: make migration/report-coverage-all | ||
|
|
||
| live: | ||
| name: migration live-operator E2E | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 120 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-go@v7 | ||
| with: | ||
| go-version-file: go.mod | ||
| - name: Set up live cluster | ||
| run: make migration/e2e-setup | ||
| - name: Run live-operator migration tests | ||
| run: make migration/test-e2e-live-matrix | ||
| - name: Tear down live cluster | ||
| if: always() | ||
| run: make migration/e2e-teardown | ||
| - name: Upload live diagnostics and coverage | ||
| if: always() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: migration-live-e2e-artifacts | ||
| path: artifacts/e2e | ||
| if-no-files-found: ignore | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| source "$(dirname "${BASH_SOURCE[0]}")/operators.sh" | ||
|
|
||
| operator_fields "${1:?usage: delete-v1.sh <operator>}" | ||
| # Delete CE first, then any revisions it owned. This is the explicit OLMv1 | ||
| # cleanup path; it never deletes shared CRDs or the source CatalogSource. | ||
| kubectl delete "clusterextension/$E2E_PACKAGE" --ignore-not-found --wait=true | ||
| kubectl delete clusterobjectsets -l "olm.operatorframework.io/owner-name=$E2E_PACKAGE" --ignore-not-found --wait=true | ||
| # Ref Secrets live in the OLMv1 system namespace rather than the operator's | ||
| # installation namespace and are not garbage-collected by ClusterObjectSet. | ||
| # Remove them as part of test cleanup so a repeat migration can reuse its | ||
| # deterministic revision and Secret names. | ||
| kubectl -n "${E2E_OLMV1_NAMESPACE:-olmv1-system}" delete secret \ | ||
| -l "olm.operatorframework.io/owner-name=$E2E_PACKAGE" \ | ||
| --ignore-not-found --wait=true |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| source "$(dirname "${BASH_SOURCE[0]}")/operators.sh" | ||
|
|
||
| operator_fields "${1:?usage: install-v0.sh <operator>}" | ||
| kubectl delete namespace "$E2E_NAMESPACE" --ignore-not-found --wait=true | ||
| kubectl create namespace "$E2E_NAMESPACE" --dry-run=client -o yaml | kubectl apply --validate=false -f - | ||
|
|
||
| # Some bundles require user-supplied configuration before their controller pod | ||
| # can be created. These source-controlled inputs are also applied by fixture | ||
| # replay, keeping both suites faithful to the same installed operator. | ||
| preinstall_fixture="$root_dir/test/e2e/migration/fixtures/preinstall/$E2E_PACKAGE.yaml" | ||
| if [[ -f $preinstall_fixture ]]; then | ||
| kubectl -n "$E2E_NAMESPACE" apply --validate=false -f "$preinstall_fixture" | ||
| fi | ||
|
|
||
| kubectl -n "$E2E_NAMESPACE" apply --validate=false -f - <<EOF | ||
| apiVersion: operators.coreos.com/v1 | ||
| kind: OperatorGroup | ||
| metadata: | ||
| name: migration-e2e | ||
| spec: {} | ||
| --- | ||
| apiVersion: operators.coreos.com/v1alpha1 | ||
| kind: Subscription | ||
| metadata: | ||
| name: $E2E_PACKAGE | ||
| spec: | ||
| channel: $E2E_CHANNEL | ||
| name: $E2E_PACKAGE | ||
| source: operatorhubio-catalog | ||
| sourceNamespace: olm | ||
| EOF | ||
| kubectl -n "$E2E_NAMESPACE" wait --for=jsonpath='{.status.state}'=AtLatestKnown "subscription/$E2E_PACKAGE" --timeout=15m | ||
| csv=$(kubectl -n "$E2E_NAMESPACE" get "subscription/$E2E_PACKAGE" -o jsonpath='{.status.installedCSV}') | ||
| kubectl -n "$E2E_NAMESPACE" wait --for=jsonpath='{.status.phase}'=Succeeded "csv/$csv" --timeout=15m |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| root_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd) | ||
| operators_file="$root_dir/test/e2e/migration/operators.tsv" | ||
| : "${KUBECONFIG:?KUBECONFIG must point to the Kind-generated E2E kubeconfig}" | ||
|
|
||
| operator_row() { | ||
| awk -F '\t' -v name="$1" '$1 == name { print; exit }' "$operators_file" | ||
| } | ||
|
|
||
| operator_names() { | ||
| awk -F '\t' 'NF == 3 && $1 !~ /^#/ { print $1 }' "$operators_file" | ||
| } | ||
|
|
||
| for_each_operator() { | ||
| if [[ ${1:-} == all ]]; then operator_names; else printf '%s\n' "$1"; fi | ||
| } | ||
|
|
||
| operator_fields() { | ||
| local row | ||
| row=$(operator_row "$1") | ||
| [[ -n "$row" ]] || { echo "unknown E2E operator: $1" >&2; exit 2; } | ||
| IFS=$'\t' read -r E2E_PACKAGE E2E_CHANNEL E2E_NAMESPACE <<<"$row" | ||
| export E2E_PACKAGE E2E_CHANNEL E2E_NAMESPACE | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Creates a disposable cluster for the migration E2E suites. Manifest locations are | ||
| # required inputs: CI supplies immutable, mirrored copies when it cannot access | ||
| # the public release URLs. | ||
| : "${E2E_KUBECONFIG:?E2E_KUBECONFIG is required}" | ||
| : "${OLM_V0_CRDS:?OLM_V0_CRDS is required}" | ||
| : "${OLM_V0_MANIFEST:?OLM_V0_MANIFEST is required}" | ||
| : "${OLM_V1_INSTALL:?OLM_V1_INSTALL is required}" | ||
| : "${OLM_V1_INSTALL_SHA256:?OLM_V1_INSTALL_SHA256 is required}" | ||
| : "${KIND:?KIND is required}" | ||
|
|
||
| root_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd) | ||
| cluster_name=${E2E_CLUSTER_NAME:-library-olm-e2e} | ||
| kind_config=${E2E_KIND_CONFIG:-"$root_dir/test/e2e/migration/kind-config.yaml"} | ||
|
|
||
| mkdir -p "$(dirname "$E2E_KUBECONFIG")" | ||
| if "$KIND" get clusters | grep -Fxq "$cluster_name"; then | ||
| # Keep an existing dedicated cluster for iterative fixture development, but | ||
| # always regenerate the kubeconfig from Kind rather than accepting an old or | ||
| # user-supplied file. | ||
| "$KIND" export kubeconfig --name "$cluster_name" --kubeconfig "$E2E_KUBECONFIG" | ||
| else | ||
| "$KIND" create cluster --name "$cluster_name" --config "$kind_config" --kubeconfig "$E2E_KUBECONFIG" | ||
| fi | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" wait --for=condition=Ready nodes --all --timeout=3m | ||
|
|
||
| # The v0.46 CRD bundle exceeds Kubernetes' client-side last-applied annotation | ||
| # limit for the CSV CRD. Server-side apply stores managed fields instead. | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" apply --server-side -f "$OLM_V0_CRDS" | ||
| if [[ ${E2E_INSTALL_OLMV0:-true} == true ]]; then | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" apply -f "$OLM_V0_MANIFEST" | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" -n olm wait --for=condition=Available deployment/olm-operator --timeout=5m | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" -n olm wait --for=condition=Available deployment/catalog-operator --timeout=5m | ||
| fi | ||
|
|
||
| # ClusterObjectSet is an experimental OLMv1 API and is required by the migration | ||
| # code, so use operator-controller's experimental installer rather than standard. | ||
| # Download a pinned release installer before executing it, restricting redirects | ||
| # to HTTPS and verifying its recorded SHA-256. | ||
| if ! kubectl --kubeconfig "$E2E_KUBECONFIG" get crd/clusterextensions.olm.operatorframework.io >/dev/null 2>&1; then | ||
| installer=$(mktemp) | ||
| trap 'rm -f "$installer"' EXIT | ||
| curl --fail --location --proto '=https' --proto-redir '=https' --silent --show-error "$OLM_V1_INSTALL" --output "$installer" | ||
| printf '%s %s\n' "$OLM_V1_INSTALL_SHA256" "$installer" | sha256sum --check --status | ||
| KUBECONFIG="$E2E_KUBECONFIG" bash "$installer" | ||
| fi | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" wait --for=condition=Established crd/clusterextensions.olm.operatorframework.io crd/clustercatalogs.olm.operatorframework.io --timeout=5m | ||
| kubectl --kubeconfig "$E2E_KUBECONFIG" -n olmv1-system wait --for=condition=Available deployment/operator-controller-controller-manager deployment/catalogd-controller-manager --timeout=5m |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| : "${KIND:?KIND is required}" | ||
| "$KIND" delete cluster --name "${E2E_CLUSTER_NAME:-library-olm-e2e}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.