-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
commands,pkg/test: support single namespace mode for local test #546
Conversation
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)
Changed to WIP because needs docs |
Docs updated |
pkg/test/resource_creator.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
pkg/test/framework.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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>
.
LGTM |
…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
This commit brings support for running the tests in a single
namespace when using
test local
, which was previously only usedby
test cluster
(where it was a requirement to properly function)/cc @hasbro17 @fanminshi