Skip to content

Commit

Permalink
test/env/generate: Randomize network names
Browse files Browse the repository at this point in the history
The e2e tests currently randomize the namespaces, but
the network name inside the NADs is the same, creating
dependency between the tests.
In order to runthe tests in parallel, a change that will
be introduced in future commit - randomizing the network
names as well.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Jan 8, 2025
1 parent 1ee9a54 commit 7b7d14c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/env/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package env

import (
"fmt"
"strings"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/utils/pointer"

nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
Expand All @@ -14,7 +16,8 @@ import (
)

func GenerateLayer2WithSubnetNAD(nadName, namespace, role string) *nadv1.NetworkAttachmentDefinition {
networkName := "l2"
const randCharacters = 5
networkName := strings.Join([]string{"l2", role, rand.String(randCharacters)}, "-")
return &nadv1.NetworkAttachmentDefinition{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Expand Down

0 comments on commit 7b7d14c

Please sign in to comment.