Skip to content

Commit

Permalink
fix(#3393): Disable cron job e2e test on OpenShift 3.x
Browse files Browse the repository at this point in the history
CronJob batch/v1 API is not available on OpenShift 3.x
  • Loading branch information
christophd committed Jun 29, 2022
1 parent 56d3bc6 commit 1b0b0cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 3 additions & 8 deletions e2e/common/cli/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package common

import (
"bytes"
"reflect"
"strings"
"testing"
"text/template"
Expand All @@ -36,9 +35,8 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/install"
"github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/apache/camel-k/pkg/util/openshift"
console "github.com/openshift/api/console/v1"
consolev1 "github.com/openshift/api/console/v1"
corev1 "k8s.io/api/core/v1"
)

Expand Down Expand Up @@ -98,11 +96,8 @@ func TestConsoleCliDownload(t *testing.T) {
ocp, err := openshift.IsOpenShift(TestClient())
assert.Nil(t, err)

ok, err := kubernetes.IsAPIResourceInstalled(TestClient(), "console.openshift.io/v1", reflect.TypeOf(console.ConsoleCLIDownload{}).Name())
assert.Nil(t, err)

if !ocp || !ok {
t.Skip("This test requires ConsoleCliDownload object which is available on OpenShift 4 only.")
if !ocp || !IsAPIResourceInstalled(t, TestClient(), "console.openshift.io/v1", consolev1.ConsoleCLIDownload{}) {
t.Skip("This test requires ConsoleCliDownload object which is available on OpenShift 4+ only.")
return
}

Expand Down
6 changes: 6 additions & 0 deletions e2e/common/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ import (

. "github.com/onsi/gomega"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"

. "github.com/apache/camel-k/e2e/support"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)

func TestRunCronExample(t *testing.T) {
if !IsAPIResourceInstalled(t, TestClient(), "batch/v1", batchv1.CronJob{}) {
t.Skip("This test requires CronJob batch/v1 API installed.")
return
}

WithNewTestNamespace(t, func(ns string) {
Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())

Expand Down
6 changes: 6 additions & 0 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -1933,3 +1933,9 @@ func GetOutputStringAsync(cmd *cobra.Command) func() string {
return buffer.String()
}
}

func IsAPIResourceInstalled(t *testing.T, client client.Client, groupVersion string, i any) bool {
ok, err := kubernetes.IsAPIResourceInstalled(client, groupVersion, reflect.TypeOf(i).Name())
assert.Nil(t, err)
return ok
}

0 comments on commit 1b0b0cb

Please sign in to comment.