Skip to content

Commit

Permalink
Merge branch 'main' into add-reusable-release-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken authored Feb 8, 2024
2 parents d676efd + 4fcbb1c commit 8968d81
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 29 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/e2e-upgrade-test-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,31 @@ env:
E2E_LOG_LEVEL: debug
KYMA_STABILITY: "unstable"
KYMA: "./hack/kyma"
DOCKER_IMAGE_REPO: "europe-docker.pkg.dev/kyma-project/prod/eventing-manager"
DOCKER_IMAGE_REPO_DEV: "europe-docker.pkg.dev/kyma-project/dev/eventing-manager"

on:
workflow_call:
inputs:
# image tag before upgrade
pre-upgrade-image-tag:
required: true
type: string
# image tag after upgrade
description: "The image tag of the Eventing Manager before the upgrade"
post-upgrade-image-tag:
required: true
type: string
# job name of the prow build job
description: "The image tag of the Eventing Manager after the upgrade"
build-job-name:
type: string
# commit sha of the PR or main branch commit
build-job-commit-sha:
description: "The name of the build job to wait for"
commit-sha:
type: string
description: "The commit sha of the new version"
required: true

# For example,
# PR: main -> PR
# main: latest release -> main

jobs:
e2e-upgrade: # This job tests the upgrade of Eventing module from the latest image of the main branch to the current commit.
Expand All @@ -31,8 +38,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pre-upgrade checkout
run: git checkout -b ${{ inputs.pre-upgrade-image-tag }}
with:
ref: ${{ inputs.pre-upgrade-image-tag }}

- name: Install k3d tools
run: make -C hack/ci/ install-k3d-tools
Expand All @@ -59,13 +66,13 @@ jobs:
- name: Install Eventing manager before upgrade
run: |
pre_upgrade_image=$(./hack/ci/build-full-image-path.sh ${{ inputs.pre-upgrade-image-tag }})
pre_upgrade_image=$DOCKER_IMAGE_REPO:${{ inputs.pre-upgrade-image-tag }}
echo "Pre-upgrade image: $pre_upgrade_image"
make deploy IMG=$pre_upgrade_image
- name: Create test resources and wait for eventing CR readiness
run: |
export MANAGER_IMAGE=$(./hack/ci/build-full-image-path.sh ${{ inputs.pre-upgrade-image-tag }})
export MANAGER_IMAGE=$DOCKER_IMAGE_REPO:${{ inputs.pre-upgrade-image-tag }}
make e2e-setup
make e2e-eventing-setup
Expand All @@ -74,7 +81,7 @@ jobs:
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: ${{ inputs.build-job-name }}
commit_ref: "${{ inputs.build-job-commit-sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests.
commit_ref: "${{ inputs.commit-sha }}"
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
Expand All @@ -85,18 +92,24 @@ jobs:

- name: Checkout
uses: actions/checkout@v4
- name: Post-upgrade checkout
run: git checkout -b ${{ inputs.post-upgrade-image-tag }}
with:
ref: ${{ inputs.commit-sha }}

- name: Install Eventing manager after upgrade
- name: Upgrade Eventing manager
id: upgrade-eventing-manager
run: |
post_upgrade_image=$(./hack/ci/build-full-image-path.sh ${{ inputs.post-upgrade-image-tag }})
if [[ ${{ inputs.post-upgrade-image-tag }} == PR* ]]; then
post_upgrade_image=$DOCKER_IMAGE_REPO_DEV:${{ inputs.post-upgrade-image-tag }}
else
post_upgrade_image=$DOCKER_IMAGE_REPO:${{ inputs.post-upgrade-image-tag }}
fi
echo "Post-upgrade image: $post_upgrade_image"
make deploy IMG=$post_upgrade_image
echo "post_upgrade_image=$post_upgrade_image" >> "$GITHUB_OUTPUT"
- name: Create test resources and waits for eventing CR readiness
run: |
export MANAGER_IMAGE=$(./hack/ci/build-full-image-path.sh ${{ inputs.post-upgrade-image-tag }})
export MANAGER_IMAGE=${{ steps.upgrade-eventing-manager.outputs.post_upgrade_image }}
make e2e-setup
- name: Run e2e tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
pre-upgrade-image-tag: main
post-upgrade-image-tag: PR-${{ github.event.number }}
build-job-name: pull-eventing-manager-build
build-job-commit-sha: ${{ github.event.pull_request.head.sha }}
commit-sha: ${{ github.event.pull_request.head.sha }}
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/push-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
with:
pre-upgrade-image-tag: ${{ needs.get-latest-release.outputs.latest_release_tag }}
post-upgrade-image-tag: main
build-job-name: push-eventing-manager-build
build-job-commit-sha: ${{ github.sha }}
build-job-name: post-eventing-manager-build
commit-sha: ${{ github.sha }}
secrets: inherit
4 changes: 2 additions & 2 deletions internal/controller/operator/eventing/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,11 @@ func (r *Reconciler) reconcileNATSBackend(ctx context.Context,
if connErr := r.connectToNATS(eventingCR); connErr != nil {
if errors.Is(connErr, natsconnectionerrors.ErrCannotConnect) {
return kctrl.Result{}, reconcile.TerminalError(
r.syncStatusWithNATSErr(ctx, eventingCR, connErr, log),
r.syncStatusWithNATSState(ctx, operatorv1alpha1.StateWarning, eventingCR, connErr, log),
)
}

return kctrl.Result{}, r.syncStatusWithNATSErr(ctx, eventingCR, connErr, log)
return kctrl.Result{}, r.syncStatusWithNATSState(ctx, operatorv1alpha1.StateWarning, eventingCR, connErr, log)
}

// set NATSAvailable condition to true and update status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
natstestutils "github.com/kyma-project/nats-manager/testutils"
"github.com/onsi/gomega"
gomegatypes "github.com/onsi/gomega/types"
"github.com/pkg/errors"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
kappsv1 "k8s.io/api/apps/v1"
Expand All @@ -22,6 +23,9 @@ import (
// Test_NATSConnection tests the Eventing CR status when connecting to NATS.
func Test_NATSConnection(t *testing.T) {
// given

ErrAny := errors.New("any")

testCases := []struct {
name string
givenNATSConnectionMock func() *natsconnectionmocks.Connection
Expand All @@ -33,8 +37,6 @@ func Test_NATSConnection(t *testing.T) {
conn := &natsconnectionmocks.Connection{}
conn.On("Connect", mock.Anything, mock.Anything).Return(nil)
conn.On("IsConnected").Return(true)
conn.On("RegisterReconnectHandler", mock.Anything).Return()
conn.On("RegisterDisconnectErrHandler", mock.Anything).Return()
return conn
},
wantMatches: gomega.And(
Expand All @@ -45,24 +47,39 @@ func Test_NATSConnection(t *testing.T) {
),
},
{
name: "Eventing CR should be in error state if not connected to NATS",
name: "Eventing CR should be in warning state if the connect behaviour returned a cannot connect error",
givenNATSConnectionMock: func() *natsconnectionmocks.Connection {
conn := &natsconnectionmocks.Connection{}
conn.On("Connect", mock.Anything, mock.Anything).Return(natsconnectionerrors.ErrCannotConnect)
conn.On("IsConnected").Return(false)
conn.On("RegisterReconnectHandler", mock.Anything).Return()
conn.On("RegisterDisconnectErrHandler", mock.Anything).Return()
return conn
},
wantMatches: gomega.And(
matchers.HaveStatusError(),
matchers.HaveStatusWarning(),
matchers.HaveBackendNotAvailableConditionWith(
natsconnectionerrors.ErrCannotConnect.Error(),
operatorv1alpha1.ConditionReasonNATSNotAvailable,
),
matchers.HaveFinalizer(),
),
},
{
name: "Eventing CR should be in warning state if the connect behaviour returned any error",
givenNATSConnectionMock: func() *natsconnectionmocks.Connection {
conn := &natsconnectionmocks.Connection{}
conn.On("Connect", mock.Anything, mock.Anything).Return(ErrAny)
conn.On("IsConnected").Return(false)
return conn
},
wantMatches: gomega.And(
matchers.HaveStatusWarning(),
matchers.HaveBackendNotAvailableConditionWith(
ErrAny.Error(),
operatorv1alpha1.ConditionReasonNATSNotAvailable,
),
matchers.HaveFinalizer(),
),
},
}

for _, tc := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion sec-scanners-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The value for the publisher image is extracted from config/manager/manager.yaml.
# The value for the webhook image is extracted from config/webhook/kustomization.yaml.
module-name: eventing
rc-tag: 0.8.0
rc-tag: 1.1.0
protecode:
- europe-docker.pkg.dev/kyma-project/prod/eventing-manager:0.8.0
- europe-docker.pkg.dev/kyma-project/prod/eventing-publisher-proxy:1.0.1
Expand Down
2 changes: 0 additions & 2 deletions test/utils/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ func NewTestEnvironment(config TestEnvironmentConfig, connMock *natsconnectionmo
connMock.On("Connect", mock.Anything, mock.Anything).Return(nil)
connMock.On("IsConnected").Return(true)
connMock.On("Disconnect").Return()
connMock.On("RegisterReconnectHandler", mock.Anything).Return()
connMock.On("RegisterDisconnectErrHandler", mock.Anything).Return()
}

// create a new watcher
Expand Down

0 comments on commit 8968d81

Please sign in to comment.