From 47e05bec03c82d1e847b09ee58b9d3d6d29c5092 Mon Sep 17 00:00:00 2001 From: Dimitris Gkanatsios Date: Wed, 21 Sep 2022 08:29:53 -0700 Subject: [PATCH] fixing unit test --- pkg/operator/controllers/port_registry_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/operator/controllers/port_registry_test.go b/pkg/operator/controllers/port_registry_test.go index e256a3a2..03b762b9 100644 --- a/pkg/operator/controllers/port_registry_test.go +++ b/pkg/operator/controllers/port_registry_test.go @@ -430,7 +430,13 @@ var _ = Describe("Random port registration on port registry with two thousand po defer wg.Done() n := rand.Intn(200) + 50 // n will be between 50 and 250 time.Sleep(time.Duration(n) * time.Millisecond) - gameServerName := generateName(prefix) + var gameServerName string + for { // make sure we don't register the same GameServer twice + gameServerName = generateName(prefix) + if _, ok := gameServerNamesAndPorts.Load(gameServerName); !ok { + break + } + } ports, err := portRegistry.GetNewPorts(testnamespace, gameServerName, 1) Expect(err).ToNot(HaveOccurred()) Expect(len(ports)).To(Equal(1))