-
Notifications
You must be signed in to change notification settings - Fork 64
test: enable OCP mode and add auto case for uiplugin dashboard #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bc2d54f
to
11f3282
Compare
test/run-e2e.sh
Outdated
@@ -209,6 +213,10 @@ parse_args() { | |||
RUN_REGEX=$1 | |||
shift | |||
;; | |||
--ocp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have the tests determine whether they run on OCP or not. I think checking for the presence of the ClusterVersion
or ClusterOperator
CRD should be good enough. We can get this up once during test setup and the framework
can pass it to all tests. Then a test can t.Skip
if it can't run.
11f3282
to
69a1a7f
Compare
5f7ba2d
to
62bcd73
Compare
test/e2e/framework/framework.go
Outdated
@@ -156,3 +170,17 @@ func (f *Framework) CleanUp(t *testing.T, cleanupFunc func()) { | |||
} | |||
}) | |||
} | |||
|
|||
func (f *Framework) IsOpenshiftCluster() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add memoization here too like in getOpenShiftClient
? I think we can assume this won't change during a test run so we can safely store the result of this and return the cached value on subsequent calls.
test/e2e/framework/framework.go
Outdated
@@ -156,3 +170,17 @@ func (f *Framework) CleanUp(t *testing.T, cleanupFunc func()) { | |||
} | |||
}) | |||
} | |||
|
|||
func (f *Framework) IsOpenshiftCluster() bool { | |||
c, err := f.getOpenshiftClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be better off to initialize this in
func setupFramework() error { |
test/e2e/framework/framework.go
Outdated
return false | ||
} | ||
_, err = c.ConfigV1().ClusterVersions().Get(context.TODO(), "version", metav1.GetOptions{}) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this one. To me this reads we implicitly assume the error is a 404, in which case we can skip a test. If this returns a different error (say a 5xx) we would want to propagate an error. Otherwise we risk skipping the openshift tests even if we are in an openshift cluster. @simonpasquier @machine424 wdyt?
We might be better off to only return false if apierrors.IsNotFound(err)
.
449e630
to
05f347c
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lihongyan1 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
29e90f5
to
a43e6bb
Compare
/test images |
ci/prow/images job failed not for obo, ocp-testplatform team solve in progress |
/test images |
@jan--f @simonpasquier @jgbernalp please help review, I would like this to merge so that we can run on IBM P/Z prow job in future. |
test/e2e/main_test.go
Outdated
@@ -83,17 +86,28 @@ func main(m *testing.M) int { | |||
|
|||
func setupFramework() error { | |||
cfg := config.GetConfigOrDie() | |||
scheme := operator.NewScheme(&operator.OperatorConfiguration{}) | |||
err := configv1.AddToScheme(scheme) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc says that AddToScheme is deprecated.
err := configv1.AddToScheme(scheme) | |
err := configv1.Install(scheme) |
test/e2e/main_test.go
Outdated
|
||
func isOpenshiftCluster(k8sClient client.Client) (bool, error) { | ||
clusterVersion := &configv1.ClusterVersion{} | ||
err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: "version"}, clusterVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Background() is fine to use here.
err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: "version"}, clusterVersion) | |
err := k8sClient.Get(context.Background(), client.ObjectKey{Name: "version"}, clusterVersion) |
test/e2e/main_test.go
Outdated
err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: "version"}, clusterVersion) | ||
if err == nil { | ||
return true, nil | ||
} else if strings.Contains(err.Error(), `no matches for kind "ClusterVersion" in version "config.openshift.io/v1"`) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use https://pkg.go.dev/k8s.io/apimachinery/pkg/api/meta#IsNoMatchError to check the error type rather than looking at the error string?
Change OCP script to enable OCP mode Add uiplugin auto testing
Check if cluster is OCP by checking for the presence of the ClusterVersion
remove openshift client go
31c727b
to
24b7494
Compare
24b7494
to
a187ddb
Compare
/retest |
/lgtm |
#COO-237 Change OCP script to enable OCP mode
#COO-160 Add uiplugin-DB auto testing