summaryrefslogtreecommitdiff
path: root/integrationtests/portnumber.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-24 14:06:11 +0300
committerPaul Buetow <paul@buetow.org>2021-10-24 14:06:11 +0300
commit6cfc4e161f94ab159d4b1ea491ffe6f166fa6204 (patch)
tree093fb4bff0bdf086188df86ca5d13dc7f8a34e4f /integrationtests/portnumber.go
parent87b6c47999f49c2deff42fdcc703c419b251bdbc (diff)
Integration tests can run concurrently, so we now have unique TCP ports for each
Diffstat (limited to 'integrationtests/portnumber.go')
-rw-r--r--integrationtests/portnumber.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/integrationtests/portnumber.go b/integrationtests/portnumber.go
new file mode 100644
index 0000000..94c2a11
--- /dev/null
+++ b/integrationtests/portnumber.go
@@ -0,0 +1,15 @@
+package integrationtests
+
+import "sync"
+
+var portNumberMutex sync.Mutex
+var currentPortNumber int = 4241
+
+// Go tests can run concurrently, so we need unique TCP port numbers for
+// each test.
+func getUniquePortNumber() int {
+ portNumberMutex.Lock()
+ defer portNumberMutex.Unlock()
+ currentPortNumber++
+ return currentPortNumber
+}