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 3720d1f + 16186d4 commit e94291a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 35 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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/kyma-project/kyma/common/logging v0.0.0-20231220133808-e2c22b79a28b
github.com/kyma-project/nats-manager v1.0.3-0.20231219150808-13159cfea47c
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/nats-io/nats-server/v2 v2.10.9
github.com/nats-io/nats-server/v2 v2.10.10
github.com/nats-io/nats.go v1.32.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.31.1
Expand Down Expand Up @@ -62,7 +62,7 @@ require (
github.com/jinzhu/copier v0.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/compress v1.17.5 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dv
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.5 h1:d4vBd+7CHydUqpFBgUEKkSdtSugf9YFmSkvUYPquI5E=
github.com/klauspost/compress v1.17.5/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand Down Expand Up @@ -251,8 +251,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nats-io/jwt/v2 v2.5.3 h1:/9SWvzc6hTfamcgXJ3uYRpgj+QuY2aLNqRiqrKcrpEo=
github.com/nats-io/jwt/v2 v2.5.3/go.mod h1:iysuPemFcc7p4IoYots3IuELSI4EDe9Y0bQMe+I3Bf4=
github.com/nats-io/nats-server/v2 v2.10.9 h1:VEW43Zz+p+9lARtiPM9ctd6ckun+92ZT2T17HWtwiFI=
github.com/nats-io/nats-server/v2 v2.10.9/go.mod h1:oorGiV9j3BOLLO3ejQe+U7pfAGyPo+ppD7rpgNF6KTQ=
github.com/nats-io/nats-server/v2 v2.10.10 h1:g1Wd64J5SGsoqWSx1qoNu9/At7a2x+jE7Qtf2XpEx/I=
github.com/nats-io/nats-server/v2 v2.10.10/go.mod h1:/TE61Dos8NlwZnjzyE3ZlOnM6dgl7tf937dnf4VclrA=
github.com/nats-io/nats.go v1.32.0 h1:Bx9BZS+aXYlxW08k8Gd3yR2s73pV5XSoAQUyp1Kwvp0=
github.com/nats-io/nats.go v1.32.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
Expand Down
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.7.0
rc-tag: 1.1.0
protecode:
- europe-docker.pkg.dev/kyma-project/prod/eventing-manager:0.7.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 e94291a

Please sign in to comment.