Skip to content

commands,pkg/test: support single namespace mode for local test#546

Merged
AlexNPavel merged 6 commits into
operator-framework:masterfrom
AlexNPavel:single-namespace-local
Sep 28, 2018
Merged

commands,pkg/test: support single namespace mode for local test#546
AlexNPavel merged 6 commits into
operator-framework:masterfrom
AlexNPavel:single-namespace-local

Conversation

@AlexNPavel
Copy link
Copy Markdown
Contributor

This commit brings support for running the tests in a single
namespace when using test local, which was previously only used
by test cluster (where it was a requirement to properly function)

/cc @hasbro17 @fanminshi

This commit brings support for running the tests in a single
namespace when using `test local`, which was previously only used
by `test cluster` (where it was a requirement to properly function)
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 27, 2018
@AlexNPavel AlexNPavel changed the title commands,pkg/test: support single namespace mode for local test [WIP] commands,pkg/test: support single namespace mode for local test Sep 27, 2018
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2018
@AlexNPavel
Copy link
Copy Markdown
Contributor Author

Changed to WIP because needs docs

@AlexNPavel AlexNPavel changed the title [WIP] commands,pkg/test: support single namespace mode for local test commands,pkg/test: support single namespace mode for local test Sep 27, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2018
@AlexNPavel
Copy link
Copy Markdown
Contributor Author

Docs updated

Comment thread pkg/test/resource_creator.go Outdated
}
if Global.InCluster {
if *Global.SingleNamespace {
ctx.Namespace = os.Getenv(TestNamespaceEnv)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check if env is set and is not empty otherwise return error. We always expect len(os.Getenv(TestNamespaceEnv)) >0 for the single namespace case.

Comment thread pkg/test/framework.go Outdated
err = wait.PollImmediate(time.Second, time.Second*10, func() (done bool, err error) {
if Global.InCluster {
if *Global.SingleNamespace {
err = Global.DynamicClient.List(goctx.TODO(), &dynclient.ListOptions{Namespace: os.Getenv(TestNamespaceEnv)}, obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of doing os.Getenv(TestNamespaceEnv) wherever it's needed, let's initialize a Namespace field to the framework.
During the framework setup() we check this once (if singleNamespace=true) and set Global.Namespace=<namespace>.

@hasbro17
Copy link
Copy Markdown
Contributor

LGTM

@AlexNPavel AlexNPavel merged commit 1a3f18b into operator-framework:master Sep 28, 2018
@AlexNPavel AlexNPavel deleted the single-namespace-local branch September 28, 2018 23:42
johnkim76 pushed a commit to dymurray/operator-sdk that referenced this pull request Oct 2, 2018
…ator-framework#546)

* commands,pkg/test: support single namespace mode for local test

This commit brings support for running the tests in a single
namespace when using `test local`, which was previously only used
by `test cluster` (where it was a requirement to properly function)

* doc: update docs with new test local --namespace flag

* pkg/test/resource_creator.go: check namespace env value

* pkg/test: change handling of TestNamespaceEnv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants