Skip to content
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

Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to proper e2e #26415

Merged

Conversation

deejross
Copy link

@deejross deejross commented Aug 20, 2021

There is a lot in basicresources.sh including non-resource and multi-resource tests. This PR is moving that logic out of the old bash script and into Go tests, while appropriately organizing them.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 20, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 20, 2021

@deejross: This pull request references Bugzilla bug 1992596, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @zhouying7780

In response to this:

WIP: Bug 1992596: e2e/cli: Move basicresources.sh to proper e2e

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Aug 20, 2021
@deejross
Copy link
Author

/assign @atiratree

@deejross deejross changed the title WIP: Bug 1992596: e2e/cli: Move basicresources.sh to proper e2e WIP: Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to proper e2e Aug 21, 2021
@deejross
Copy link
Author

/retest-required


var (
ctx = context.Background()
oc = exutil.NewCLI("oc-annotation").AsAdmin()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably don't need an admin privileges here. Can you check the other tests as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was required for getting node information

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, keep it in places where you need it

return k8simage.GetE2EImage(k8simage.BusyBox)
}

func getNginxImage() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to wrap these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to avoid an additional import in the compat.go file, but if that's not a concern I can remove these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO that is not a big concern

return k8simage.GetE2EImage(k8simage.Nginx)
}

func newCreateOptions() metav1.CreateOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems too superfluous as well

o.Expect(err).NotTo(o.HaveOccurred())
})

g.It("can ensure the probe command is functioning as expected on pods", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot of these seem quite specific and they could look better in separate files. Can you move these usecases to a separate PR as this one got quite big already? It would be easier to review/merge.

o.Expect(err).NotTo(o.HaveOccurred())
})

g.It("can create deploymentconfig and clusterquota", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could have a special test for cluster quota that also verifies the quotas

o.Expect(out).To(o.ContainSubstring("updated"))
})

g.It("can ensure the expose command is functioning as expected", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be under services or expose file


func newMixedAPIVersionsFile() string {
// this was converted from YAML to JSON to prevent indentation formatting issues
var body = `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the benefit of this? Keeping these in files has a better readability IMO.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since most of the tests are required to run in disconnected environments, using images directly in these files won't work when converted to Go. The appropriate e2e images need to be used instead, which is what the string replacement handles before writing this out to a temporary file. I didn't want to modify a file already under version control during testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • you can do a similar thing with files to what you do in your function. 1. load file 2. replace images. 3 save to tmp file. Then we can version control them directly as yaml files.
  • I also noticed some of the yamls don't include images so you can use them directly as files

Copy link
Member

@atiratree atiratree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deejross Can you please cleanup the commits a bit so there is not the whole history of changes but only the commits specific to this PR?

g.By("Verifying original file is in the local directory")
o.Expect(foundOriginal).To(o.BeTrue())

g.By("Verifying renamed file is not in the local directory")
o.Expect(foundModified).To(o.BeFalse())

g.By("Getting an error if copying to a destination directory where there is no write permission")
result, err = oc.Run("rsync").Args(
_, err = oc.Run("rsync").Args(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Execute can be used here instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still holds.

Name: "testapp",
Image: k8simage.GetE2EImage(k8simage.BusyBox),
Command: []string{"/bin/sleep"},
Args: []string{"300"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be a small timeout for some tests, maybe better to use httpd which does not timeout?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or some kind of nginx


g.It("creates and deletes statefulsets", func() {
g.By("creating a new service for the statefulset")
_, err := oc.KubeClient().CoreV1().Services(oc.Namespace()).Create(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use oc CLI client since it is the purpose of these tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.


var (
ctx = context.Background()
oc = exutil.NewCLI("oc-statefulset").AsAdmin()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not require an admin here

var (
oc = exutil.NewCLI("oc-secret").AsAdmin()
testData = exutil.FixturePath("testdata", "cmd", "test", "cmd", "testdata")
resourceBuilder = filepath.Join(testData, "resource-builder")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not necessary to have testData variable if it is not reused IMO. Also resourceBuilder needs a better naming like resourceBuilderDir or path so its usage is more apparent

defer g.GinkgoRecover()

var (
oc = exutil.NewCLI("oc-secret").AsAdmin()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin

o.Expect(err).NotTo(o.HaveOccurred())

g.By("getting secrets without extensions")
_, err = oc.Run("get").Args("secret", "json-no-extension", "yml-no-extension").Output()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use Execute in these

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var _ = g.Describe("[sig-cli] oc service", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mentioned remarks apply to this file as well

@@ -1,327 +0,0 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please only remove the lines and files that apply to this PR

@deejross deejross changed the title WIP: Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to proper e2e Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to proper e2e Aug 31, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 31, 2021
@openshift-merge-robot
Copy link
Contributor

/bugzilla refresh

The requirements for Bugzilla bugs have changed, recalculating validity.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2021

@openshift-merge-robot: This pull request references Bugzilla bug 1992596, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "4.9.0" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

The requirements for Bugzilla bugs have changed, recalculating validity.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. and removed bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Sep 6, 2021
@deejross
Copy link
Author

deejross commented Sep 7, 2021

/bugzilla refresh

@openshift-ci openshift-ci bot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Sep 7, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 7, 2021

@deejross: This pull request references Bugzilla bug 1992596, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @zhouying7780

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Sep 7, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 7, 2021

@deejross: This pull request references Bugzilla bug 1992596, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @zhouying7780

In response to this:

Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to proper e2e

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deejross deejross force-pushed the e2e-basicresources.sh branch 2 times, most recently from f572091 to 6b4685e Compare September 7, 2021 15:55
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 13, 2021
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of nits, but most importantly you forgot to run make update to regenerate annotations.

defer g.GinkgoRecover()

var (
oc = exutil.NewCLI("oc-statefulset")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for single vars it's fine to just do

oc := exutil.NewCLI("oc-statefulset")

defer g.GinkgoRecover()

var (
oc = exutil.NewCLI("oc-status")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here wrt oc := exutil.NewCLI("oc-status")

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 17, 2021
Copy link
Member

@atiratree atiratree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deejross can you please only remove the relevant lines as mentioned?(#26415 (comment)). This will help us to continue atomically in the next PR

o.Expect(err).NotTo(o.HaveOccurred())
defer os.Remove(statefulSetFile)

err = oc.Run("create").Args("-f", frontendFile).Execute()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw you can also use InputString to read the data from stdin instead of a file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can you please use the oc CLI client instead of an direct API calls in other places as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those can be done in followups

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 21, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 21, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deejross, soltysh

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 21, 2021

@deejross: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-agnostic-cmd 4daa813 link false /test e2e-agnostic-cmd
ci/prow/e2e-aws-csi 4daa813 link false /test e2e-aws-csi
ci/prow/e2e-aws-single-node 4daa813 link false /test e2e-aws-single-node

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit c93debe into openshift:master Sep 21, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 21, 2021

@deejross: All pull requests linked via external trackers have merged:

Bugzilla bug 1992596 has been moved to the MODIFIED state.

In response to this:

Bug 1992596: e2e/cli: Move annotations.sh and basicresources.sh to proper e2e

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hardys
Copy link

hardys commented Jan 11, 2022

/cherry-pick release-4.9

1 similar comment
@hardys
Copy link

hardys commented Jan 11, 2022

/cherry-pick release-4.9

@openshift-cherrypick-robot

@hardys: new pull request created: #26738

In response to this:

/cherry-pick release-4.9

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hardys
Copy link

hardys commented Jan 11, 2022

Backporting this should resolve https://bugzilla.redhat.com/show_bug.cgi?id=1998963 I think since it removes the hard-coded busybox image reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants