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

Make namespace auto-generated name more unique #501

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/test/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (t *Case) determineNamespace() *namespace {
}
// no preferred ns, means we auto-create with petnames
if t.PreferredNamespace == "" {
ns.Name = fmt.Sprintf("kuttl-test-%s", petname.Generate(2, "-"))
ns.Name = fmt.Sprintf("kuttl-test-%s", petname.Generate(4, "-"))
Copy link
Member

Choose a reason for hiding this comment

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

I'm more than a little afraid we might blow through the limit of max namespace length because of this. 😟
Or, more likely, when the code under test takes the namespace name as input to generating names of cluster-scoped resources (by slapping some additional prefix on it). Does petname provide any guarantees on the max generated name length?

ns.AutoCreated = true
}
// if we have a preferred namespace, we do NOT auto-create
Expand Down
4 changes: 2 additions & 2 deletions pkg/test/step_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func TestCheckResourceIntegration(t *testing.T) {
} {
test := test
t.Run(test.testName, func(t *testing.T) {
namespace := fmt.Sprintf("kuttl-test-%s", petname.Generate(2, "-"))
namespace := fmt.Sprintf("kuttl-test-%s", petname.Generate(4, "-"))

err := testenv.Client.Create(context.TODO(), testutils.NewResource("v1", "Namespace", namespace, ""))
if !k8serrors.IsAlreadyExists(err) {
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestStepFailure(t *testing.T) {
},
}

namespace := fmt.Sprintf("kuttl-test-%s", petname.Generate(2, "-"))
namespace := fmt.Sprintf("kuttl-test-%s", petname.Generate(4, "-"))

err := testenv.Client.Create(context.TODO(), testutils.NewResource("v1", "Namespace", namespace, ""))
if !k8serrors.IsAlreadyExists(err) {
Expand Down