Skip to content

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

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

lihongyan1
Copy link
Contributor

@lihongyan1 lihongyan1 commented Jul 17, 2024

#COO-237 Change OCP script to enable OCP mode
#COO-160 Add uiplugin-DB auto testing

@lihongyan1 lihongyan1 requested a review from a team as a code owner July 17, 2024 08:16
@lihongyan1 lihongyan1 requested review from danielmellado and simonpasquier and removed request for a team July 17, 2024 08:16
@openshift-ci openshift-ci bot requested review from jgbernalp and periklis July 17, 2024 08:16
@lihongyan1 lihongyan1 force-pushed the test-uiplugin-db branch 5 times, most recently from bc2d54f to 11f3282 Compare July 19, 2024 05:13
@lihongyan1 lihongyan1 changed the title test: add auto case for uiplugin dashboard test: enable OCP mode and add auto case for uiplugin dashboard Jul 19, 2024
test/run-e2e.sh Outdated
@@ -209,6 +213,10 @@ parse_args() {
RUN_REGEX=$1
shift
;;
--ocp)
Copy link
Collaborator

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.

@openshift-ci openshift-ci bot removed the approved label Aug 6, 2024
@lihongyan1 lihongyan1 force-pushed the test-uiplugin-db branch 5 times, most recently from 5f7ba2d to 62bcd73 Compare August 7, 2024 03:11
@@ -156,3 +170,17 @@ func (f *Framework) CleanUp(t *testing.T, cleanupFunc func()) {
}
})
}

func (f *Framework) IsOpenshiftCluster() bool {
Copy link
Collaborator

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.

@@ -156,3 +170,17 @@ func (f *Framework) CleanUp(t *testing.T, cleanupFunc func()) {
}
})
}

func (f *Framework) IsOpenshiftCluster() bool {
c, err := f.getOpenshiftClient()
Copy link
Collaborator

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 {
and rely on the client being there. Otherwise we have to remember to initialize this in future functions that needs the openshift client.

return false
}
_, err = c.ConfigV1().ClusterVersions().Get(context.TODO(), "version", metav1.GetOptions{})
if err != nil {
Copy link
Collaborator

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).

Copy link

openshift-ci bot commented Aug 20, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lihongyan1 lihongyan1 force-pushed the test-uiplugin-db branch 4 times, most recently from 29e90f5 to a43e6bb Compare August 20, 2024 06:26
@lihongyan1
Copy link
Contributor Author

/test images

@lihongyan1
Copy link
Contributor Author

ci/prow/images job failed not for obo, ocp-testplatform team solve in progress

@lihongyan1
Copy link
Contributor Author

/test images

@lihongyan1
Copy link
Contributor Author

@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.

@@ -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)
Copy link
Contributor

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.

Suggested change
err := configv1.AddToScheme(scheme)
err := configv1.Install(scheme)


func isOpenshiftCluster(k8sClient client.Client) (bool, error) {
clusterVersion := &configv1.ClusterVersion{}
err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: "version"}, clusterVersion)
Copy link
Contributor

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.

Suggested change
err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: "version"}, clusterVersion)
err := k8sClient.Get(context.Background(), client.ObjectKey{Name: "version"}, clusterVersion)

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"`) {
Copy link
Contributor

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
@lihongyan1 lihongyan1 force-pushed the test-uiplugin-db branch 2 times, most recently from 31c727b to 24b7494 Compare September 18, 2024 08:57
@lihongyan1
Copy link
Contributor Author

/retest

@jan--f
Copy link
Collaborator

jan--f commented Sep 30, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 30, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 6cbfed6 into rhobs:main Sep 30, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants