Skip to content

Commit

Permalink
Setup new test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyharisch committed Oct 17, 2024
1 parent 0b930ea commit 4add134
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 151 deletions.
165 changes: 86 additions & 79 deletions .github/actions/deploy-lifecycle-manager-e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,82 +10,89 @@ inputs:
runs:
using: composite
steps:
- name: Patch purge finalizer flags
if: ${{ matrix.e2e-test == 'purge-controller' || matrix.e2e-test == 'purge-metrics'}}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --enable-purge-finalizer=true
- op: add
path: /spec/template/spec/containers/0/args/-
value: --purge-finalizer-timeout=5s" >> purge_finalizer.yaml
cat purge_finalizer.yaml
kustomize edit add patch --path purge_finalizer.yaml --kind Deployment
popd
- name: Patch metrics cleanup interval
if : ${{ matrix.e2e-test == 'kyma-metrics' }}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --metrics-cleanup-interval=1" >> metrics_cleanup.yaml
cat metrics_cleanup.yaml
kustomize edit add patch --path metrics_cleanup.yaml --kind Deployment
popd
- name: Patch self signed certificate lifetime
if: ${{matrix.e2e-test == 'self-signed-certificate-rotation'}}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --self-signed-cert-duration=1h
- op: add
path: /spec/template/spec/containers/0/args/-
value: --self-signed-cert-renew-before=59m
- op: add
path: /spec/template/spec/containers/0/args/-
value: --self-signed-cert-renew-buffer=1m" >> self-signed-cert.yaml
cat self-signed-cert.yaml
kustomize edit add patch --path self-signed-cert.yaml --kind Deployment
popd
- name: Patch CA certificate renewBefore
if: ${{matrix.e2e-test == 'ca-certificate-rotation'}}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: replace
path: /spec/renewBefore
value: 59m
- op: replace
path: /spec/duration
value: 1h">> certificate_renewal.yaml
cat certificate_renewal.yaml
kustomize edit add patch --path certificate_renewal.yaml --kind Certificate --group cert-manager.io --version v1 --name watcher-serving
popd
- name: Deploy LM local testing kustomize
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager
with:
klm_version_tag: ${{ inputs.klm_version_tag }}
klm_image_repo: ${{ inputs.klm_image_repo }}
- name: Expose Metrics Endpoint
working-directory: lifecycle-manager
if: ${{ matrix.e2e-test == 'kyma-metrics' ||
matrix.e2e-test == 'purge-metrics' ||
matrix.e2e-test == 'self-signed-certificate-rotation' ||
matrix.e2e-test == 'mandatory-module-metrics'
}}
shell: bash
run: |
kubectl patch svc klm-controller-manager-metrics -p '{"spec": {"type": "LoadBalancer"}}' -n kcp-system
- name: Patch purge finalizer flags
if: ${{ matrix.e2e-test == 'purge-controller' || matrix.e2e-test == 'purge-metrics'}}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --enable-purge-finalizer=true
- op: add
path: /spec/template/spec/containers/0/args/-
value: --purge-finalizer-timeout=5s" >> purge_finalizer.yaml
cat purge_finalizer.yaml
kustomize edit add patch --path purge_finalizer.yaml --kind Deployment
popd
- name: Patch metrics cleanup interval
if: ${{ matrix.e2e-test == 'kyma-metrics' }}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --metrics-cleanup-interval=1" >> metrics_cleanup.yaml
cat metrics_cleanup.yaml
kustomize edit add patch --path metrics_cleanup.yaml --kind Deployment
popd
- name: Patch self signed certificate lifetime
if: ${{matrix.e2e-test == 'self-signed-certificate-rotation'}}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --self-signed-cert-duration=1h
- op: add
path: /spec/template/spec/containers/0/args/-
value: --self-signed-cert-renew-before=59m
- op: add
path: /spec/template/spec/containers/0/args/-
value: --self-signed-cert-renew-buffer=1m" >> self-signed-cert.yaml
cat self-signed-cert.yaml
kustomize edit add patch --path self-signed-cert.yaml --kind Deployment
popd
- name: Patch requeue intervals
if: ${{ matrix.e2e-test == 'modulereleasemeta-watch-trigger'}}
working-directory: lifecycle-manager
shell: bash
run: |
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --kyma-requeue-error-interval=1h
- op: add
path: /spec/template/spec/containers/0/args/-
value: --kyma-requeue-warning-interval=1h
- op: add
path: /spec/template/spec/containers/0/args/-
value: --kyma-requeue-success-interval=1h
- op: add
path: /spec/template/spec/containers/0/args/-
value: --kyma-requeue-busy-interval=1h" >> requeue-interval-patch.yaml
cat requeue-interval-patch.yaml
kustomize edit add patch --path requeue-interval-patch.yaml --kind Deployment
popd
- name: Patch CA certificate renewBefore
if: ${{matrix.e2e-test == 'ca-certificate-rotation'}}
working-directory: lifecycle-manager
shell: bash
run: "pushd config/watcher_local_test\necho \\\n\"- op: replace\n path: /spec/renewBefore\n value: 59m \n- op: replace\n path: /spec/duration\n value: 1h\">> certificate_renewal.yaml\ncat certificate_renewal.yaml\nkustomize edit add patch --path certificate_renewal.yaml --kind Certificate --group cert-manager.io --version v1 --name watcher-serving\npopd\n"
- name: Deploy LM local testing kustomize
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager
with:
klm_version_tag: ${{ inputs.klm_version_tag }}
klm_image_repo: ${{ inputs.klm_image_repo }}
- name: Expose Metrics Endpoint
working-directory: lifecycle-manager
if: ${{ matrix.e2e-test == 'kyma-metrics' || matrix.e2e-test == 'purge-metrics' || matrix.e2e-test == 'self-signed-certificate-rotation' || matrix.e2e-test == 'mandatory-module-metrics' }}
shell: bash
run: |
kubectl patch svc klm-controller-manager-metrics -p '{"spec": {"type": "LoadBalancer"}}' -n kcp-system
143 changes: 72 additions & 71 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,96 +9,97 @@ on:
description: With Kubernetes version
required: false
pull_request:
types: [ opened, edited, synchronize, reopened, ready_for_review ]
types: [opened, edited, synchronize, reopened, ready_for_review]
jobs:
wait-for-image-build:
name: Wait for image build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Wait for the Docker image
timeout-minutes: 20
env:
ITERATIONS: 40
SLEEP_SECONDS: 30
run: ./.github/scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ github.event.pull_request.head.sha }} ${{ env.ITERATIONS }} ${{ env.SLEEP_SECONDS}}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Wait for the Docker image
timeout-minutes: 20
env:
ITERATIONS: 40
SLEEP_SECONDS: 30
run: ./.github/scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ github.event.pull_request.head.sha }} ${{ env.ITERATIONS }} ${{ env.SLEEP_SECONDS}}
e2e-integration:
name: E2E With ModuleReleaseMeta
needs: wait-for-image-build
strategy:
fail-fast: false
matrix:
e2e-test:
- watcher-enqueue
- kyma-deprovision-with-foreground-propagation
- kyma-deprovision-with-background-propagation
- module-status-decoupling-with-statefulset
- module-status-decoupling-with-deployment
- kyma-metrics
- module-without-default-cr
- module-consistency
- non-blocking-deletion
- upgrade-under-deletion
- purge-controller
- purge-metrics
- module-upgrade-channel-switch
- module-upgrade-new-version
- unmanage-module
- skip-manifest-reconciliation
- ca-certificate-rotation
- self-signed-certificate-rotation
- mandatory-module
- mandatory-module-metrics
- misconfigured-kyma-secret
- rbac-privileges
- ocm-compatible-module-template
- modulereleasemeta-with-obsolete-moduletemplate
- watcher-enqueue
- kyma-deprovision-with-foreground-propagation
- kyma-deprovision-with-background-propagation
- module-status-decoupling-with-statefulset
- module-status-decoupling-with-deployment
- kyma-metrics
- module-without-default-cr
- module-consistency
- non-blocking-deletion
- upgrade-under-deletion
- purge-controller
- purge-metrics
- module-upgrade-channel-switch
- module-upgrade-new-version
- unmanage-module
- skip-manifest-reconciliation
- ca-certificate-rotation
- self-signed-certificate-rotation
- mandatory-module
- mandatory-module-metrics
- misconfigured-kyma-secret
- rbac-privileges
- ocm-compatible-module-template
- modulereleasemeta-with-obsolete-moduletemplate
- modulereleasemeta-watch-trigger
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout lifecycle-manager
uses: actions/checkout@v4
with:
path: lifecycle-manager
- name: Checkout lifecycle-manager
uses: actions/checkout@v4
with:
path: lifecycle-manager

- name: Checkout template-operator
uses: actions/checkout@v4
with:
repository: kyma-project/template-operator
path: template-operator
- name: Checkout template-operator
uses: actions/checkout@v4
with:
repository: kyma-project/template-operator
path: template-operator

- name: Get configuration
uses: ./lifecycle-manager/.github/actions/get-configuration
id: configuration
- name: Get configuration
uses: ./lifecycle-manager/.github/actions/get-configuration
id: configuration

- name: Setup tools
uses: ./lifecycle-manager/.github/actions/setup-tools
with:
k8s_version: ${{ steps.configuration.outputs.k8s_version }}
istio_version: ${{ steps.configuration.outputs.istio_version }}
k3d_version: ${{ steps.configuration.outputs.k3d_version }}
go-version-file: lifecycle-manager/go.mod
cache-dependency-path: lifecycle-manager/go.sum
- name: Setup tools
uses: ./lifecycle-manager/.github/actions/setup-tools
with:
k8s_version: ${{ steps.configuration.outputs.k8s_version }}
istio_version: ${{ steps.configuration.outputs.istio_version }}
k3d_version: ${{ steps.configuration.outputs.k3d_version }}
go-version-file: lifecycle-manager/go.mod
cache-dependency-path: lifecycle-manager/go.sum

- name: Setup test clusters
uses: ./lifecycle-manager/.github/actions/setup-test-clusters
with:
k8s_version: ${{ steps.configuration.outputs.k8s_version }}
cert_manager_version: ${{ steps.configuration.outputs.cert_manager_version }}
- name: Setup test clusters
uses: ./lifecycle-manager/.github/actions/setup-test-clusters
with:
k8s_version: ${{ steps.configuration.outputs.k8s_version }}
cert_manager_version: ${{ steps.configuration.outputs.cert_manager_version }}

- name: Deploy lifecycle-manager
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager-e2e
with:
klm_version_tag: ${{ steps.configuration.outputs.klm_version_tag }}
klm_image_repo: ${{ steps.configuration.outputs.klm_image_repo }}
- name: Deploy lifecycle-manager
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager-e2e
with:
klm_version_tag: ${{ steps.configuration.outputs.klm_version_tag }}
klm_image_repo: ${{ steps.configuration.outputs.klm_image_repo }}

- name: Deploy template-operator
uses: ./lifecycle-manager/.github/actions/deploy-template-operator-with-modulereleasemeta
- name: Deploy template-operator
uses: ./lifecycle-manager/.github/actions/deploy-template-operator-with-modulereleasemeta

- name: Run '${{ matrix.e2e-test }}' test
working-directory: lifecycle-manager
run: |
make -C tests/e2e ${{ matrix.e2e-test }}
- name: Run '${{ matrix.e2e-test }}' test
working-directory: lifecycle-manager
run: |
make -C tests/e2e ${{ matrix.e2e-test }}
5 changes: 4 additions & 1 deletion tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@ ocm-compatible-module-template:
go test -timeout 20m -ginkgo.v -ginkgo.focus "OCM Format Module Template"

modulereleasemeta-with-obsolete-moduletemplate:
go test -timeout 20m -ginkgo.v -ginkgo.focus "ModuleReleaseMeta With Obsolete ModuleTemplate"
go test -timeout 20m -ginkgo.v -ginkgo.focus "ModuleReleaseMeta With Obsolete ModuleTemplate"

modulereleasemeta-watch-trigger:
go test -timeout 20m -ginkgo.v -ginkgo.focus "ModuleReleaseMeta Watch Trigger"
50 changes: 50 additions & 0 deletions tests/e2e/modulereleasemeta_watch_trigger_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package e2e_test

import (
"fmt"

"github.com/kyma-project/lifecycle-manager/api/shared"
"github.com/kyma-project/lifecycle-manager/api/v1beta2"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/kyma-project/lifecycle-manager/pkg/testutils"
)

var _ = Describe("ModuleReleaseMeta Watch Trigger", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
module := NewTemplateOperator(v1beta2.DefaultChannel)

expectedErrorMessage := fmt.Sprintf("failed to get module template: ModuleTemplate.operator.kyma-project.io \"%s-%s\" not found",
module.Name, "1.0.1")

InitEmptyKymaBeforeAll(kyma)
CleanupKymaAfterAll(kyma)

Context("Given kyma deployed in KCP", func() {
It("When enabling Template Operator", func() {
Eventually(EnableModule).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, module).
Should(Succeed())
})

It("Then KCP Kyma CR is in \"Error\" State", func() {
Eventually(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateError).
Should(Succeed())
Consistently(KymaIsInState).
WithContext(ctx).
WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateError).
Should(Succeed())

By("And Module Message in Kyma Status is as expected")
Eventually(ModuleMessageInKymaStatusIsCorrect).
WithContext(ctx).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), module.Name, expectedErrorMessage).
Should(Succeed())
})
})
})

0 comments on commit 4add134

Please sign in to comment.