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))