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

e2e test fails if there are resouces created by the previous test #576

Closed
MIBc opened this issue Dec 19, 2019 · 6 comments · Fixed by #596
Closed

e2e test fails if there are resouces created by the previous test #576

MIBc opened this issue Dec 19, 2019 · 6 comments · Fixed by #596
Labels
kind/feature New feature or request

Comments

@MIBc
Copy link
Contributor

MIBc commented Dec 19, 2019

Describe the feature:

The e2e test may fail in sometime, for example failing download docker image. When start test again, it will fail for some existed resource. In this situation, I have to clear resource manually.
Is there a command or shell to clear all resource the test has created?

@MIBc MIBc added the kind/feature New feature or request label Dec 19, 2019
@MIBc MIBc changed the title e2e test failed if there were resouces created by the previous test e2e test fails if there were resouces created by the previous test Dec 19, 2019
@MIBc MIBc changed the title e2e test fails if there were resouces created by the previous test e2e test fails if there are resouces created by the previous test Dec 19, 2019
@rhuss
Copy link
Contributor

rhuss commented Dec 19, 2019

AFAIR we create all resources in a temporary namespace and then just remove that namespace after the test. So a kubectl delete ns <temp-namespace> should be enough. (@navidshaikh please me correct me when I'm wrong)

Or are you talking about cluster-wide resources ?

@MIBc
Copy link
Contributor Author

MIBc commented Dec 19, 2019

I try delete ns. But clusterrole and clusterrolebinding still left.

@navidshaikh
Copy link
Collaborator

That's correct, though there are multiple test namespaces kne2etests[0-9], and the SA, ClusterRole and ClusterRoleBindings are introduced recently. We do need tear down functionality.

@rhuss
Copy link
Contributor

rhuss commented Dec 19, 2019

correct, ClusterRole and ClusterRoleBindings are cluster-wide resources which need to be cleaned up seperately. I wonder, whether those cluster-wide resources (if different) work nicely with parallel running tests ? Or ar their names also randomized (so that they don't interfer which each other) ?

An idea: We could use the suffix of the namespace under test for the cluster role names and then just delete all clusterroles with those prefix. This would be generic enough and doesn't need constant maintenance.

@maximilien
Copy link
Contributor

maximilien commented Dec 19, 2019

I am also seeing this issue consistently as well with ClusterRole and ClusterRoleBindings.

The kne2etestsX namespaces from previous runs are not deleted (sometimes) on failures, so will cause errors in subsequent runs of e2e. I think we need to have a clean up of these namespaces at the start of the e2e run. Like a cleanup to ensure all is well. The danger is if there is a running e2e, which we can claim is not supported (e.g., running e2e multiple times at once). Thoughts?

@MIBc
Copy link
Contributor Author

MIBc commented Dec 20, 2019

The danger is if there is a running e2e, which we can claim is not supported (e.g., running e2e multiple times at once). Thoughts?

-- It must fail . If a test is running, another test will meet resource already exists error.

MIBc pushed a commit to MIBc/client that referenced this issue Jan 6, 2020
MIBc pushed a commit to MIBc/client that referenced this issue Jan 6, 2020
MIBc added a commit to MIBc/client that referenced this issue Jan 6, 2020
MIBc added a commit to MIBc/client that referenced this issue Jan 6, 2020
navidshaikh added a commit to navidshaikh/client that referenced this issue Jan 6, 2020
 Completes knative#576
 - For ApiServer source: ClusteRole and ClusterRoleBinding name(s)
   are now test-namespace specific. They are cleared in test's tearDown method.
 - Use constant prefix as:
  clusterRolePrefix        = "apiserver-role-"
  clusterRoleBindingPrefix = "apiserver-binding-"
 - Use constant ServiceAccountName as:
  testServiceAccount = "apiserver-sa"
 - Rename methods and cleanup.
navidshaikh added a commit to navidshaikh/client that referenced this issue Jan 6, 2020
 Completes knative#576
 - For ApiServer source: ClusteRole and ClusterRoleBinding name(s)
   are now test-namespace specific. They are cleared in test's tearDown method.
 - Use constant prefix as:
  clusterRolePrefix        = "apiserver-role-"
  clusterRoleBindingPrefix = "apiserver-binding-"
 - Use constant ServiceAccountName as:
  testServiceAccount = "apiserver-sa"
 - Rename methods and cleanup.
knative-prow-robot pushed a commit that referenced this issue Jan 10, 2020
* chore(e2e): Namespace specific k8s resources for tests

 Completes #576
 - For ApiServer source: ClusteRole and ClusterRoleBinding name(s)
   are now test-namespace specific. They are cleared in test's tearDown method.
 - Use constant prefix as:
  clusterRolePrefix        = "apiserver-role-"
  clusterRoleBindingPrefix = "apiserver-binding-"
 - Use constant ServiceAccountName as:
  testServiceAccount = "apiserver-sa"
 - Rename methods and cleanup.

* Use correct format specifier for error as %v instead of %s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
4 participants