Skip to content

Commit

Permalink
chore(ci): move OLM test as nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Aug 13, 2024
1 parent d3efe3c commit e039e22
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 33 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,6 @@ jobs:
run: |
make release-helm
- name: Install OLM
shell: bash
run: |
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/crds.yaml
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/olm.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded csv packageserver -n olm --timeout=2m
- name: Login to staging container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push OLM bundle
shell: bash
run: |
echo "BUNDLE_IMAGE_NAME=ghcr.io/${{ github.actor }}/camel-k-bundle" >> $GITHUB_ENV
echo "Setting bundle image name as as $BUNDLE_IMAGE_NAME which is required by OLM tests"
BUNDLE_IMAGE_NAME=ghcr.io/${{ github.actor }}/camel-k-bundle make bundle-push
- name: Run tests
shell: bash
run: |
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/nightly-install-olm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
--- # ---------------------------------------------------------------------------

# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------

# TODO: follow up the evolution of https://github.com/operator-framework/operator-sdk/issues/6699
# and move into a normal test once it is possible for the operator-sdk to test local bundles
name: Nightly OLM test


env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
schedule:
- cron: "15 1 * * *"
workflow_dispatch:

jobs:
release:
strategy:
fail-fast: false
matrix:
ref-branch: [main, release-2.3.x, release-2.4.x]

if: github.repository == 'apache/camel-k'
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
ref: ${{ matrix.ref-branch }}
persist-credentials: false
submodules: recursive

- name: Infra setting
uses: ./.github/actions/infra-setting

- name: Install OLM
shell: bash
run: |
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/crds.yaml
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/olm.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded csv packageserver -n olm --timeout=2m
# Building and pushing a bundle to a running container is required due to how
# Operator-SDK works. Once it allows for local bundle testing, this part may be omitted
- name: Login to staging container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.TEST_DOCKER_HUB_USERNAME }}
password: ${{ secrets.TEST_DOCKER_HUB_PASSWORD }}

- name: Build and push OLM bundle
shell: bash
run: |
echo "BUNDLE_IMAGE_NAME=docker.io/testcamelk/camel-k-bundle" >> $GITHUB_ENV
echo "Setting bundle image name as as $BUNDLE_IMAGE_NAME which is required by OLM tests"
BUNDLE_IMAGE_NAME=docker.io/testcamelk/camel-k-bundle make bundle-push
- name: Run tests
shell: bash
run: |
DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-install-olm
14 changes: 10 additions & 4 deletions e2e/install/helm/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func TestHelmInstallation(t *testing.T) {
"--force",
),
)
// Refresh the test client to account for the newly installed CRDs
RefreshClient(t)

g.Eventually(OperatorPod(t, ctx, ns)).ShouldNot(BeNil())
// Check if restricted security context has been applied
Expand All @@ -74,10 +76,9 @@ func TestHelmInstallation(t *testing.T) {

// Test a simple route
t.Run("simple route", func(t *testing.T) {
name := RandomizedSuffixName("yaml")
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
})

ExpectExecSucceed(t, g,
Expand All @@ -91,5 +92,10 @@ func TestHelmInstallation(t *testing.T) {
)

g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil())

// Test CRD uninstall (will remove Integrations as well)
UninstallCRDs(t, ctx, g, "../../../")

g.Eventually(CRDs(t)).Should(BeNil())
})
}
2 changes: 0 additions & 2 deletions e2e/install/kustomize/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func TestKustomizeNamespaced(t *testing.T) {
UninstallCRDs(t, ctx, g, "../../../")

g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil())
g.Eventually(Integration(t, ctx, ns, "yaml"), TestTimeoutShort).Should(BeNil())
g.Eventually(CRDs(t)).Should(BeNil())
})
}
Expand Down Expand Up @@ -219,7 +218,6 @@ func TestKustomizeDescoped(t *testing.T) {
UninstallCRDs(t, ctx, g, "../../../")

g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil())
g.Eventually(Integration(t, ctx, nsIntegration, "yaml"), TestTimeoutShort).Should(BeNil())
g.Eventually(CRDs(t)).Should(BeNil())
})
})
Expand Down
8 changes: 6 additions & 2 deletions e2e/install/olm/olm_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func TestOLMInstallation(t *testing.T) {
),
"180s",
)
// Refresh the test client to account for the newly installed CRDs
RefreshClient(t)
// Find the only one Camel K CSV
noAdditionalConditions := func(csv olm.ClusterServiceVersion) bool {
return true
Expand All @@ -73,8 +75,6 @@ func TestOLMInstallation(t *testing.T) {
g.Eventually(OperatorPodPhase(t, ctx, ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
g.Eventually(OperatorImage(t, ctx, ns), TestTimeoutShort).Should(Equal(defaults.OperatorImage()))

// This is required in order to wait the availability of IntegrationPlatform CRDs
g.Eventually(CRDs(t)).Should(HaveLen(ExpectedCRDs))
// Check the IntegrationPlatform has been reconciled after setting the expected container registry
g.Expect(UpdatePlatform(t, ctx, ns, func(ip *v1.IntegrationPlatform) {
ip.Spec.Build.Registry.Address = containerRegistry
Expand Down Expand Up @@ -105,5 +105,9 @@ func TestOLMInstallation(t *testing.T) {
g.Consistently(
IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), 15*time.Second, 5*time.Second).
Should(Equal(corev1.ConditionTrue))

// Test CRD uninstall (will remove Integrations as well)
UninstallCRDs(t, ctx, g, "../../../")
g.Eventually(CRDs(t)).Should(BeNil())
})
}
8 changes: 6 additions & 2 deletions e2e/install/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ func TestUpgrade(t *testing.T) {
installPrevCmd.Dir = lastVersionDir
ExpectExecSucceed(t, g, installPrevCmd)

// Refresh the test client to account for the newly installed CRDs
RefreshClient(t)
// Check the operator image is the previous one
g.Eventually(OperatorImage(t, ctx, ns)).Should(ContainSubstring(lastVersion))
// Check the operator pod is running
g.Eventually(OperatorPodPhase(t, ctx, ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
// Check the IntegrationPlatform has been reconciled
g.Eventually(PlatformPhase(t, ctx, ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
g.Eventually(PlatformVersion(t, ctx, ns), TestTimeoutMedium).Should(Equal(lastVersion))
g.Eventually(PlatformPhase(t, ctx, ns)).Should(Equal(v1.IntegrationPlatformPhaseReady))
g.Eventually(PlatformVersion(t, ctx, ns)).Should(Equal(lastVersion))

// We need a different namespace from the global operator
WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsIntegration string) {
Expand All @@ -105,6 +107,8 @@ func TestUpgrade(t *testing.T) {
)
installNextCmd.Dir = "../../.."
ExpectExecSucceed(t, g, installNextCmd)
// Refresh the test client to account for the newly installed CRDs
RefreshClient(t)

// Check the operator image is the current built one
g.Eventually(OperatorImage(t, ctx, ns)).Should(ContainSubstring(defaults.Version))
Expand Down
11 changes: 9 additions & 2 deletions script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,23 @@ test-advanced:
exit $${FAILED}

#
# Installation procedure test using CLi and Kustomize methodologies
# Installation and upgrade procedure test using
#
test-install:
FAILED=0; \
go test -timeout 20m -v ./e2e/install/kustomize -tags=integration $(GOTESTFMT) || ((FAILED++)); \
go test -timeout 20m -v ./e2e/install/helm -tags=integration $(GOTESTFMT) || ((FAILED++)); \
go test -timeout 20m -v ./e2e/install/olm -tags=integration $(GOTESTFMT) || ((FAILED++)); \
go test -timeout 60m -v ./e2e/install/upgrade -tags=integration $(GOTESTFMT) || ((FAILED++)); \
exit $${FAILED}

#
# Installation procedure test via OLM
#
test-install-olm:
FAILED=0; \
go test -timeout 20m -v ./e2e/install/olm -tags=integration $(GOTESTFMT) || ((FAILED++)); \
exit $${FAILED}

#
# Knative tests that require the presence of Knative configuration
#
Expand Down

0 comments on commit e039e22

Please sign in to comment.