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

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

Merged

Conversation

AlexNPavel
Copy link
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
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
Contributor Author

Docs updated

@@ -31,7 +31,7 @@ func (ctx *TestCtx) GetNamespace() (string, error) {
if ctx.Namespace != "" {
return ctx.Namespace, nil
}
if Global.InCluster {
if *Global.SingleNamespace {
ctx.Namespace = os.Getenv(TestNamespaceEnv)
Copy link
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.

@@ -136,7 +135,7 @@ func AddToFrameworkScheme(addToScheme addToSchemeFunc, obj runtime.Object) error
Global.RestMapper.Reset()
Global.DynamicClient, err = dynclient.New(Global.KubeConfig, dynclient.Options{Scheme: Global.Scheme, Mapper: Global.RestMapper})
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
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
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