3
3
import unittest
4
4
import logging
5
5
import sys
6
+ import random
6
7
7
8
from docker .errors import NotFound
8
9
15
16
16
17
NAMESPACE = os .environ .get ('NAMESPACE' )
17
18
VERSION = os .environ .get ('VERSION' )
19
+ USE_RANDOM_USER_ID = os .environ .get ('USE_RANDOM_USER_ID' )
18
20
19
21
IMAGE_NAME_MAP = {
20
22
# Hub
@@ -70,7 +72,13 @@ def launch_hub():
70
72
logger .debug ("hub killed" )
71
73
existing_hub .remove ()
72
74
logger .debug ("hub removed" )
73
- hub_container_id = launch_container ('Hub' , ports = {'4444' : 4444 })
75
+
76
+
77
+ if use_random_user_id :
78
+ hub_container_id = launch_container ('Hub' , ports = {'4444' : 4444 }, user = random_user_id )
79
+ else :
80
+ hub_container_id = launch_container ('Hub' , ports = {'4444' : 4444 })
81
+
74
82
logger .info ("Hub Launched" )
75
83
return hub_container_id
76
84
@@ -101,6 +109,12 @@ def launch_container(container, **kwargs):
101
109
# The container to test against
102
110
image = sys .argv [1 ]
103
111
112
+ use_random_user_id = USE_RANDOM_USER_ID == 'true'
113
+ random_user_id = random .randint (100000 ,2147483647 )
114
+
115
+ if use_random_user_id :
116
+ logger .info ("Running tests with a random user ID -> %s" % random_user_id )
117
+
104
118
standalone = 'standalone' in image .lower ()
105
119
106
120
# Flag for failure (for posterity)
@@ -113,14 +127,20 @@ def launch_container(container, **kwargs):
113
127
Standalone Configuration
114
128
"""
115
129
smoke_test_class = 'StandaloneTest'
116
- test_container_id = launch_container (image , ports = {'4444' : 4444 })
130
+ if use_random_user_id :
131
+ test_container_id = launch_container (image , ports = {'4444' : 4444 }, user = random_user_id )
132
+ else :
133
+ test_container_id = launch_container (image , ports = {'4444' : 4444 })
117
134
else :
118
135
"""
119
136
Hub / Node Configuration
120
137
"""
121
138
smoke_test_class = 'NodeTest'
122
139
hub_id = launch_hub ()
123
- test_container_id = launch_container (image , links = {hub_id : 'hub' }, ports = {'5555' : 5555 })
140
+ if use_random_user_id :
141
+ test_container_id = launch_container (image , links = {hub_id : 'hub' }, ports = {'5555' : 5555 }, user = random_user_id )
142
+ else :
143
+ test_container_id = launch_container (image , links = {hub_id : 'hub' }, ports = {'5555' : 5555 })
124
144
125
145
logger .info ('========== / Containers ready to go ==========' )
126
146
0 commit comments