Skip to content

Commit

Permalink
reuse existing namespace in several tests
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
alexey-kremsa-globant committed Jun 18, 2020
1 parent a1e7b21 commit a05c63b
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions test/e2e/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,27 @@ func TestAllocator(t *testing.T) {
requestURL := fmt.Sprintf(allocatorReqURLFmt, ip, port)
tlsCA := refreshAllocatorTLSCerts(t, ip)

namespace := fmt.Sprintf("allocator-%s", uuid.NewUUID())

err := framework.CreateNamespace(namespace)
err := framework.CreateNamespace(framework.Namespace)
if !assert.Nil(t, err) {
return
}

defer func() {
if derr := framework.DeleteNamespace(namespace); derr != nil {
if derr := framework.DeleteNamespace(framework.Namespace); derr != nil {
t.Error(derr)
}
}()

clientSecretName := fmt.Sprintf("allocator-client-%s", uuid.NewUUID())
genClientSecret(t, namespace, clientSecretName)
genClientSecret(t, framework.Namespace, clientSecretName)

flt, err := createFleet(namespace)
flt, err := createFleet(framework.Namespace)
if !assert.Nil(t, err) {
return
}
framework.AssertFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas))
request := &pb.AllocationRequest{
Namespace: namespace,
Namespace: framework.Namespace,
RequiredGameServerSelector: &pb.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}},
PreferredGameServerSelectors: []*pb.LabelSelector{{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}}},
Scheduling: pb.AllocationRequest_Packed,
Expand All @@ -92,7 +90,7 @@ func TestAllocator(t *testing.T) {
// wait for the allocation system to come online
err = wait.PollImmediate(2*time.Second, 5*time.Minute, func() (bool, error) {
// create the grpc client each time, as we may end up looking at an old cert
dialOpts, err := createRemoteClusterDialOption(namespace, clientSecretName, tlsCA)
dialOpts, err := createRemoteClusterDialOption(framework.Namespace, clientSecretName, tlsCA)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -127,19 +125,10 @@ func TestAllocatorCrossNamespace(t *testing.T) {
restartAllocator(t)

// Create namespaces A and B
namespaceA := fmt.Sprintf("allocator-a-%s", uuid.NewUUID())
err := framework.CreateNamespace(namespaceA)
if !assert.Nil(t, err) {
return
}
defer func() {
if derr := framework.DeleteNamespace(namespaceA); derr != nil {
t.Error(derr)
}
}()
namespaceA := framework.Namespace // let's reuse an existing one

namespaceB := fmt.Sprintf("allocator-b-%s", uuid.NewUUID())
err = framework.CreateNamespace(namespaceB)
err := framework.CreateNamespace(namespaceB)
if !assert.Nil(t, err) {
return
}
Expand Down

0 comments on commit a05c63b

Please sign in to comment.