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

Use test namespaces with numeric suffix #5337

Merged
merged 10 commits into from
Jun 16, 2021

Conversation

mgencur
Copy link
Contributor

@mgencur mgencur commented May 3, 2021

Fixes #2776

Proposed Changes

  • Append numeric suffix to a common namespace name so as to make the namespace names predictable
  • Skip namespaces that already exist until we find a free one (similar to what is used in knative-client repo)
  • If ReuseNamespace flag is passed re-use the next namespace which is supposed to exist

The individual tests still create some resources that require admin privileges. This would be resolved in the next PR. Related discussion in #5357

Pre-review Checklist

Release Note


Docs

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 3, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label May 3, 2021
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/test-and-release Test infrastructure, tests or release labels May 3, 2021
@codecov
Copy link

codecov bot commented May 3, 2021

Codecov Report

Merging #5337 (15c78f3) into main (a5db0e1) will increase coverage by 0.32%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5337      +/-   ##
==========================================
+ Coverage   82.28%   82.61%   +0.32%     
==========================================
  Files         194      194              
  Lines        6002     6004       +2     
==========================================
+ Hits         4939     4960      +21     
+ Misses        739      720      -19     
  Partials      324      324              
Impacted Files Coverage Δ
pkg/apis/flows/v1/sequence_lifecycle.go 91.80% <0.00%> (-4.81%) ⬇️
pkg/apis/flows/v1/sequence_types.go 100.00% <0.00%> (ø)
pkg/apis/eventing/v1/broker_types.go 66.66% <0.00%> (ø)
pkg/apis/duck/v1/channelable_types.go 97.95% <0.00%> (ø)
pkg/apis/messaging/v1/channel_types.go 100.00% <0.00%> (ø)
pkg/apis/messaging/v1/subscription_types.go 66.66% <0.00%> (ø)
pkg/apis/config/defaults.go 92.85% <0.00%> (+7.14%) ⬆️
pkg/duck/channel.go 63.63% <0.00%> (+9.09%) ⬆️
pkg/apis/messaging/config/channel_defaults.go 75.00% <0.00%> (+10.00%) ⬆️
pkg/duck/listable.go 83.09% <0.00%> (+19.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5db0e1...15c78f3. Read the comment docs.

@mgencur mgencur changed the title [WIP] Use test namespaces from pre-defined range [WIP] Use test namespaces with numeric suffix May 11, 2021
@mgencur mgencur changed the title [WIP] Use test namespaces with numeric suffix Use test namespaces with numeric suffix May 11, 2021
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 11, 2021
func makeK8sNamespace(baseFuncName string) string {
base := helpers.MakeK8sNamePrefix(baseFuncName)
return names.SimpleNameGenerator.GenerateName(base + "-")
func CreateNamespacedClient(t *testing.T) (*Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: we intend to delete this lib and have it be replaced with knative-sandbox/reconciler-test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. OK. But the previous attempt that I abandoned because of this new framework coming was 11 months ago (#3313). If I understand it correctly, the majority of tests are still using this old style so it would be good to have some solution until we actually migrate everything to the new framework.

@mgencur
Copy link
Contributor Author

mgencur commented May 12, 2021

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 12, 2021
mgencur added 3 commits May 12, 2021 11:41
* also make the retry count and interval shorter to speed up things
* leave previously existing namespaces there
@matzew
Copy link
Member

matzew commented Jun 7, 2021

Is this still on hold, or ready for review?

@mgencur
Copy link
Contributor Author

mgencur commented Jun 7, 2021

@matzew thanks for reminding me. There was enough time and I think this is ready for review

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 7, 2021
Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 16, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, mgencur

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 16, 2021
@knative-prow-robot knative-prow-robot merged commit 193809a into knative:main Jun 16, 2021
mgencur added a commit to mgencur/eventing that referenced this pull request Aug 3, 2021
* Use test namespaces from pre-defined range

* ReuseNamespace flag

* ReuseNamespace variable in lib package

* prevents import cycle when flags are accessed directly from the lib
package

* Fix gofmt

* Fix goimports

* Remove the last occurrence of import cycle

* Remove unused variable

* Fix detection of NotFound api error

* also make the retry count and interval shorter to speed up things

* Delete NS only if we created it

* leave previously existing namespaces there

* Call CreateNamespaceWithRetry directly
openshift-ci bot pushed a commit to openshift/knative-eventing that referenced this pull request Aug 5, 2021
* Use test namespaces with numeric suffix (knative#5337)

* Use test namespaces from pre-defined range

* ReuseNamespace flag

* ReuseNamespace variable in lib package

* prevents import cycle when flags are accessed directly from the lib
package

* Fix gofmt

* Fix goimports

* Remove the last occurrence of import cycle

* Remove unused variable

* Fix detection of NotFound api error

* also make the retry count and interval shorter to speed up things

* Delete NS only if we created it

* leave previously existing namespaces there

* Call CreateNamespaceWithRetry directly

* Run conformance tests as project admin (knative#5596)

* Create RBAC according to the test namespace

* most tests will use just the serviceAccount that has the same name as
the test namespace
* tests using ApiServerSource will user serviceAccount that is named as
follows: ${namespace}-eventwatcher

* Script for creating necessary RBAC for conformance tests

* Readme for running Conformance tests as project admin

* Fix imports

* Minor update for readme

* Fix goimport

* Do not fail if ServiceAccount already exists

* Fix goftm

* Mark tests requiring cluster-admin with specific build tag

* Move the creation of SA,Role,RoleBinding close to namespace creation

* since the name of the resources is aligned with the name of the
namespace it makes sense to create them only once, at the same time as
the namespace

* Formatting

* Move remaining creation of SA,Role,RoleBinding
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. area/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for tests to run in a pre-created NS
4 participants