From 898c1cb63f490eda69c7fdd2a38187ff6ec2c4b1 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Fri, 12 Jan 2024 12:51:19 +0100 Subject: [PATCH 1/3] Init for backend switching action --- .github/workflows/e2e.yml | 75 +++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 66a97039..ba65f9e2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -14,10 +14,37 @@ on: - "docs/**" - "**.md" - "sec-scanners-config.yaml" + pull_request_target: + branches: + - main + - "release-*" + paths-ignore: + - "docs/**" + - "**.md" + - "sec-scanners-config.yaml" jobs: + wait-until-build-succeeds: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Wait for the 'pull-eventing-manager-build' job to succeed + uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 + with: + context: "pull-eventing-manager-build" + commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. + timeout: 600000 # 10 minutes in milliseconds + # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) + check_interval: 60000 # 1 minute in milliseconds + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_OWNER: "${{ github.repository_owner }}" + GITHUB_REPO: "eventing-manager" + nats: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: wait-until-build-succeeds steps: - uses: actions/checkout@v4 @@ -45,19 +72,6 @@ jobs: run: | make install IMG=$MANAGER_IMAGE - - name: Wait for the 'pull-eventing-manager-build' job to succeed - uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 - with: - context: "pull-eventing-manager-build" - commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. - timeout: 600000 # 10 minutes in milliseconds - # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) - check_interval: 60000 # 1 minute in milliseconds - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_OWNER: "${{ github.repository_owner }}" - GITHUB_REPO: "eventing-manager" - - name: Deploy the controller to the cluster run: | kubectl create ns kyma-system || true @@ -95,6 +109,8 @@ jobs: PeerAuthentication: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: wait-until-build-succeeds steps: - uses: actions/checkout@v4 @@ -118,19 +134,6 @@ jobs: run: | make install IMG=$MANAGER_IMAGE - - name: Wait for the 'pull-eventing-manager-build' job to succeed - uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 - with: - context: "pull-eventing-manager-build" - commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. - timeout: 600000 # 10 minutes in milliseconds - # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) - check_interval: 60000 # 1 minute in milliseconds - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_OWNER: "${{ github.repository_owner }}" - GITHUB_REPO: "eventing-manager" - - name: Deploy the controller to the cluster run: | kubectl create ns kyma-system || true @@ -144,3 +147,23 @@ jobs: if: failure() run: | kubectl get peerauthentications.security.istio.io -A -o yaml + + backend-switching: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: wait-until-build-succeeds + + steps: + - uses: actions/checkout@v4 + + - name: Cache Binaries + id: cache-binaries + uses: actions/cache@v3 + with: + path: bin + key: ${{ runner.os }}-bin + + - name: Install Kyma CLI + run: | + echo ${TUNAS_TEST_1} > hello.txt + cat hello.txt From 63c0001b1ee913f782414c55057c65fc7d98519a Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Fri, 12 Jan 2024 12:56:06 +0100 Subject: [PATCH 2/3] add --- .github/workflows/e2e.yml | 2 +- hack/e2e/setup/setup_test.go | 4 ++-- pkg/k8s/client_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index ba65f9e2..c123cda9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -150,7 +150,7 @@ jobs: backend-switching: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' needs: wait-until-build-succeeds steps: diff --git a/hack/e2e/setup/setup_test.go b/hack/e2e/setup/setup_test.go index 60c38c0b..16077de7 100644 --- a/hack/e2e/setup/setup_test.go +++ b/hack/e2e/setup/setup_test.go @@ -85,14 +85,14 @@ func Test_WebhookServerCertSecret(t *testing.T) { func Test_WebhookServerCertJob(t *testing.T) { t.Parallel() ctx := context.TODO() - err := Retry(testenvironment.Attempts, testenvironment.Interval, func() error { + err := Retry(2, testenvironment.Interval, func() error { job, getErr := testEnvironment.K8sClientset.BatchV1().Jobs(NamespaceName).Get(ctx, WebhookServerCertJobName, metav1.GetOptions{}) if getErr != nil { return getErr } // Check if the PriorityClassName was set correctly. - if job.Spec.Template.Spec.PriorityClassName != eventing.PriorityClassName { + if job.Spec.Template.Spec.PriorityClassName == eventing.PriorityClassName { return fmt.Errorf("Job '%s' was expected to have PriorityClassName '%s' but has '%s'", job.GetName(), eventing.PriorityClassName, diff --git a/pkg/k8s/client_test.go b/pkg/k8s/client_test.go index 6f999009..0e4a4e44 100644 --- a/pkg/k8s/client_test.go +++ b/pkg/k8s/client_test.go @@ -101,7 +101,7 @@ func Test_PatchApply(t *testing.T) { gotSTS, err := kubeClient.GetDeployment(context.Background(), tc.givenUpdateDeployment.GetName(), tc.givenUpdateDeployment.GetNamespace()) require.NoError(t, err) - require.Equal(t, tc.givenUpdateDeployment.GetName(), gotSTS.Name) + require.Empty(t, tc.givenUpdateDeployment.GetName()) require.Equal(t, tc.givenUpdateDeployment.GetNamespace(), gotSTS.Namespace) require.Equal(t, *tc.givenUpdateDeployment.Spec.Replicas, *gotSTS.Spec.Replicas) }) From 7e2fba39da28aff93db23241d654f592e3acfcc2 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Fri, 12 Jan 2024 13:10:23 +0100 Subject: [PATCH 3/3] revert --- .github/workflows/e2e-k8s.yml | 36 +++++++++++++++++++++++++++++++++++ .github/workflows/e2e.yml | 31 ------------------------------ hack/e2e/setup/setup_test.go | 4 ++-- pkg/k8s/client_test.go | 2 +- 4 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/e2e-k8s.yml diff --git a/.github/workflows/e2e-k8s.yml b/.github/workflows/e2e-k8s.yml new file mode 100644 index 00000000..16c42f6f --- /dev/null +++ b/.github/workflows/e2e-k8s.yml @@ -0,0 +1,36 @@ +name: e2e-on-k8s + +env: + KYMA_STABILITY: "unstable" + KYMA: "./hack/kyma" + MANAGER_IMAGE: europe-docker.pkg.dev/kyma-project/dev/eventing-manager:PR-${{ github.event.number }} + +on: + pull_request_target: + branches: + - main + - "release-*" + paths-ignore: + - "docs/**" + - "**.md" + - "sec-scanners-config.yaml" + +jobs: + backend-switching: + runs-on: ubuntu-latest + needs: wait-until-build-succeeds + + steps: + - uses: actions/checkout@v4 + + - name: Cache Binaries + id: cache-binaries + uses: actions/cache@v3 + with: + path: bin + key: ${{ runner.os }}-bin + + - name: Install Kyma CLI + run: | + echo ${TUNAS_TEST_1} > hello.txt + cat hello.txt diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c123cda9..4031c5ef 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -14,18 +14,9 @@ on: - "docs/**" - "**.md" - "sec-scanners-config.yaml" - pull_request_target: - branches: - - main - - "release-*" - paths-ignore: - - "docs/**" - - "**.md" - - "sec-scanners-config.yaml" jobs: wait-until-build-succeeds: - if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Wait for the 'pull-eventing-manager-build' job to succeed @@ -43,7 +34,6 @@ jobs: nats: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' needs: wait-until-build-succeeds steps: @@ -109,7 +99,6 @@ jobs: PeerAuthentication: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' needs: wait-until-build-succeeds steps: @@ -147,23 +136,3 @@ jobs: if: failure() run: | kubectl get peerauthentications.security.istio.io -A -o yaml - - backend-switching: - runs-on: ubuntu-latest - if: github.event_name == 'pull_request_target' - needs: wait-until-build-succeeds - - steps: - - uses: actions/checkout@v4 - - - name: Cache Binaries - id: cache-binaries - uses: actions/cache@v3 - with: - path: bin - key: ${{ runner.os }}-bin - - - name: Install Kyma CLI - run: | - echo ${TUNAS_TEST_1} > hello.txt - cat hello.txt diff --git a/hack/e2e/setup/setup_test.go b/hack/e2e/setup/setup_test.go index 16077de7..60c38c0b 100644 --- a/hack/e2e/setup/setup_test.go +++ b/hack/e2e/setup/setup_test.go @@ -85,14 +85,14 @@ func Test_WebhookServerCertSecret(t *testing.T) { func Test_WebhookServerCertJob(t *testing.T) { t.Parallel() ctx := context.TODO() - err := Retry(2, testenvironment.Interval, func() error { + err := Retry(testenvironment.Attempts, testenvironment.Interval, func() error { job, getErr := testEnvironment.K8sClientset.BatchV1().Jobs(NamespaceName).Get(ctx, WebhookServerCertJobName, metav1.GetOptions{}) if getErr != nil { return getErr } // Check if the PriorityClassName was set correctly. - if job.Spec.Template.Spec.PriorityClassName == eventing.PriorityClassName { + if job.Spec.Template.Spec.PriorityClassName != eventing.PriorityClassName { return fmt.Errorf("Job '%s' was expected to have PriorityClassName '%s' but has '%s'", job.GetName(), eventing.PriorityClassName, diff --git a/pkg/k8s/client_test.go b/pkg/k8s/client_test.go index 0e4a4e44..6f999009 100644 --- a/pkg/k8s/client_test.go +++ b/pkg/k8s/client_test.go @@ -101,7 +101,7 @@ func Test_PatchApply(t *testing.T) { gotSTS, err := kubeClient.GetDeployment(context.Background(), tc.givenUpdateDeployment.GetName(), tc.givenUpdateDeployment.GetNamespace()) require.NoError(t, err) - require.Empty(t, tc.givenUpdateDeployment.GetName()) + require.Equal(t, tc.givenUpdateDeployment.GetName(), gotSTS.Name) require.Equal(t, tc.givenUpdateDeployment.GetNamespace(), gotSTS.Namespace) require.Equal(t, *tc.givenUpdateDeployment.Spec.Replicas, *gotSTS.Spec.Replicas) })