langfun 0.1.2.dev202510280805__py3-none-any.whl → 0.1.2.dev202510300805__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of langfun might be problematic. Click here for more details.
- langfun/core/agentic/action.py +31 -3
- langfun/core/agentic/action_test.py +25 -0
- langfun/core/llms/gemini.py +3 -3
- langfun/env/__init__.py +4 -0
- langfun/env/base_environment.py +247 -105
- langfun/env/base_feature.py +15 -0
- langfun/env/base_sandbox.py +47 -240
- langfun/env/base_test.py +813 -603
- langfun/env/event_handlers/event_logger_test.py +2 -2
- langfun/env/event_handlers/metric_writer.py +49 -0
- langfun/env/event_handlers/metric_writer_test.py +19 -2
- langfun/env/interface.py +197 -13
- langfun/env/interface_test.py +81 -2
- langfun/env/load_balancers_test.py +19 -0
- langfun/env/test_utils.py +10 -7
- {langfun-0.1.2.dev202510280805.dist-info → langfun-0.1.2.dev202510300805.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202510280805.dist-info → langfun-0.1.2.dev202510300805.dist-info}/RECORD +20 -20
- {langfun-0.1.2.dev202510280805.dist-info → langfun-0.1.2.dev202510300805.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202510280805.dist-info → langfun-0.1.2.dev202510300805.dist-info}/licenses/LICENSE +0 -0
- {langfun-0.1.2.dev202510280805.dist-info → langfun-0.1.2.dev202510300805.dist-info}/top_level.txt +0 -0
langfun/env/base_test.py
CHANGED
|
@@ -15,7 +15,6 @@ import time
|
|
|
15
15
|
from typing import Any
|
|
16
16
|
import unittest
|
|
17
17
|
|
|
18
|
-
from langfun.env import base_sandbox
|
|
19
18
|
from langfun.env import interface
|
|
20
19
|
from langfun.env import test_utils
|
|
21
20
|
from langfun.env.event_handlers import base as event_handler_base
|
|
@@ -31,6 +30,7 @@ class EnvironmentTests(unittest.TestCase):
|
|
|
31
30
|
|
|
32
31
|
def test_basics(self):
|
|
33
32
|
env = TestingEnvironment(
|
|
33
|
+
image_ids=['test_image'],
|
|
34
34
|
root_dir='/tmp',
|
|
35
35
|
pool_size=0,
|
|
36
36
|
features={'test_feature': TestingFeature()},
|
|
@@ -38,11 +38,13 @@ class EnvironmentTests(unittest.TestCase):
|
|
|
38
38
|
outage_retry_interval=0,
|
|
39
39
|
)
|
|
40
40
|
self.assertIsNone(interface.Environment.current())
|
|
41
|
+
self.assertEqual(env.image_ids, ['test_image'])
|
|
42
|
+
self.assertFalse(env.supports_dynamic_image_loading)
|
|
41
43
|
self.assertEqual(env.status, interface.Environment.Status.CREATED)
|
|
42
44
|
self.assertFalse(env.is_online)
|
|
43
|
-
self.assertEqual(env.min_pool_size, 0)
|
|
44
|
-
self.assertEqual(env.max_pool_size, 0)
|
|
45
|
-
self.assertEqual(env.sandbox_pool,
|
|
45
|
+
self.assertEqual(env.min_pool_size('test_image'), 0)
|
|
46
|
+
self.assertEqual(env.max_pool_size('test_image'), 0)
|
|
47
|
+
self.assertEqual(env.sandbox_pool, {})
|
|
46
48
|
self.assertEqual(env.id, interface.Environment.Id('testing-env'))
|
|
47
49
|
self.assertEqual(env.outage_grace_period, 1)
|
|
48
50
|
self.assertEqual(env.features['test_feature'].name, 'test_feature')
|
|
@@ -55,29 +57,211 @@ class EnvironmentTests(unittest.TestCase):
|
|
|
55
57
|
self.assertTrue(env.is_online)
|
|
56
58
|
self.assertIsNotNone(env.start_time)
|
|
57
59
|
self.assertEqual(env.offline_duration, 0.0)
|
|
58
|
-
self.assertEqual(env.sandbox_pool,
|
|
60
|
+
self.assertEqual(env.sandbox_pool, {})
|
|
59
61
|
self.assertEqual(env.working_dir, '/tmp/testing-env')
|
|
60
62
|
|
|
61
|
-
with env.sandbox('session1') as sb:
|
|
63
|
+
with env.sandbox(session_id='session1') as sb:
|
|
62
64
|
self.assertEqual(
|
|
63
|
-
sb.id, interface.Sandbox.Id(
|
|
65
|
+
sb.id, interface.Sandbox.Id(
|
|
66
|
+
environment_id=env.id,
|
|
67
|
+
image_id=sb.image_id,
|
|
68
|
+
sandbox_id='0')
|
|
64
69
|
)
|
|
65
70
|
self.assertEqual(sb.session_id, 'session1')
|
|
66
|
-
self.assertEqual(sb.working_dir, '/tmp/testing-env/0')
|
|
71
|
+
self.assertEqual(sb.working_dir, '/tmp/testing-env/test_image/0')
|
|
67
72
|
self.assertTrue(sb.is_online)
|
|
68
73
|
self.assertIs(sb.test_feature, sb.features['test_feature'])
|
|
69
74
|
self.assertEqual(
|
|
70
75
|
sb.test_feature.working_dir,
|
|
71
|
-
'/tmp/testing-env/0/test_feature'
|
|
76
|
+
'/tmp/testing-env/test_image/0/test_feature'
|
|
72
77
|
)
|
|
73
78
|
with self.assertRaises(AttributeError):
|
|
74
79
|
_ = sb.test_feature2
|
|
75
80
|
self.assertFalse(sb.is_online)
|
|
76
81
|
|
|
77
|
-
self.
|
|
82
|
+
with self.assertRaisesRegex(
|
|
83
|
+
ValueError, 'Environment .* does not serve image ID .*'
|
|
84
|
+
):
|
|
85
|
+
env.sandbox('test_image2')
|
|
86
|
+
|
|
87
|
+
with env.test_feature() as feature:
|
|
88
|
+
self.assertIsInstance(feature, TestingFeature)
|
|
89
|
+
self.assertEqual(
|
|
90
|
+
feature.sandbox.status, interface.Sandbox.Status.IN_SESSION
|
|
91
|
+
)
|
|
92
|
+
self.assertTrue(
|
|
93
|
+
feature.sandbox.session_id.startswith('test_feature-session')
|
|
94
|
+
)
|
|
95
|
+
|
|
78
96
|
with self.assertRaises(AttributeError):
|
|
79
97
|
_ = env.test_feature2
|
|
80
98
|
|
|
99
|
+
def test_dynamic_image_loading(self):
|
|
100
|
+
env = TestingEnvironment(
|
|
101
|
+
image_ids=[],
|
|
102
|
+
supports_dynamic_image_loading=True,
|
|
103
|
+
pool_size=0,
|
|
104
|
+
features={'test_feature': TestingFeature()},
|
|
105
|
+
outage_grace_period=1,
|
|
106
|
+
outage_retry_interval=0,
|
|
107
|
+
)
|
|
108
|
+
with env:
|
|
109
|
+
with env.sandbox(image_id='test_image2') as sb:
|
|
110
|
+
self.assertEqual(sb.image_id, 'test_image2')
|
|
111
|
+
|
|
112
|
+
with self.assertRaisesRegex(
|
|
113
|
+
ValueError, 'Environment .* does not have a default image ID.'
|
|
114
|
+
):
|
|
115
|
+
env.sandbox()
|
|
116
|
+
|
|
117
|
+
def test_dynamic_image_loading_with_pooling(self):
|
|
118
|
+
env = TestingEnvironment(
|
|
119
|
+
image_ids=[],
|
|
120
|
+
supports_dynamic_image_loading=True,
|
|
121
|
+
pool_size=2,
|
|
122
|
+
features={'test_feature': TestingFeature()},
|
|
123
|
+
outage_grace_period=1,
|
|
124
|
+
outage_retry_interval=0,
|
|
125
|
+
)
|
|
126
|
+
with env:
|
|
127
|
+
with env.sandbox(image_id='test_image'):
|
|
128
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 1)
|
|
129
|
+
|
|
130
|
+
with env.sandbox(image_id='test_image'):
|
|
131
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 2)
|
|
132
|
+
|
|
133
|
+
with self.assertRaises(interface.EnvironmentOverloadError):
|
|
134
|
+
with env.sandbox(image_id='test_image'):
|
|
135
|
+
pass
|
|
136
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 2)
|
|
137
|
+
|
|
138
|
+
with env.sandbox(image_id='test_image'):
|
|
139
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 2)
|
|
140
|
+
|
|
141
|
+
def test_image_feature_mappings(self):
|
|
142
|
+
env = TestingEnvironment(
|
|
143
|
+
image_ids=[
|
|
144
|
+
'test_image1',
|
|
145
|
+
'test_image2',
|
|
146
|
+
],
|
|
147
|
+
features={
|
|
148
|
+
'test_feature': TestingFeature(
|
|
149
|
+
applicable_images=['test_image1.*']
|
|
150
|
+
),
|
|
151
|
+
'test_feature2': TestingFeature(
|
|
152
|
+
applicable_images=['test_image2.*']
|
|
153
|
+
),
|
|
154
|
+
'test_feature3': TestingFeature(
|
|
155
|
+
applicable_images=['test_image.*']
|
|
156
|
+
),
|
|
157
|
+
},
|
|
158
|
+
pool_size=0,
|
|
159
|
+
outage_grace_period=1,
|
|
160
|
+
outage_retry_interval=0,
|
|
161
|
+
sandbox_keepalive_interval=0,
|
|
162
|
+
)
|
|
163
|
+
with env:
|
|
164
|
+
with env.sandbox(image_id='test_image1') as sb:
|
|
165
|
+
self.assertIn('test_feature', sb.features)
|
|
166
|
+
self.assertNotIn('test_feature2', sb.features)
|
|
167
|
+
self.assertIn('test_feature3', sb.features)
|
|
168
|
+
|
|
169
|
+
with env.sandbox(image_id='test_image2') as sb:
|
|
170
|
+
self.assertNotIn('test_feature', sb.features)
|
|
171
|
+
self.assertIn('test_feature2', sb.features)
|
|
172
|
+
self.assertIn('test_feature3', sb.features)
|
|
173
|
+
|
|
174
|
+
with env.test_feature() as feature:
|
|
175
|
+
self.assertEqual(feature.sandbox.image_id, 'test_image1')
|
|
176
|
+
|
|
177
|
+
with self.assertRaisesRegex(
|
|
178
|
+
ValueError, 'Feature .* is not applicable to .*'
|
|
179
|
+
):
|
|
180
|
+
with env.test_feature('test_image2'):
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
with env.test_feature2() as feature:
|
|
184
|
+
self.assertEqual(feature.sandbox.image_id, 'test_image2')
|
|
185
|
+
|
|
186
|
+
with env.test_feature3() as feature:
|
|
187
|
+
self.assertEqual(feature.sandbox.image_id, 'test_image1')
|
|
188
|
+
|
|
189
|
+
with env.test_feature3('test_image2') as feature:
|
|
190
|
+
self.assertEqual(feature.sandbox.image_id, 'test_image2')
|
|
191
|
+
|
|
192
|
+
def test_feature_applicability_check(self):
|
|
193
|
+
with self.assertRaisesRegex(
|
|
194
|
+
ValueError, 'Feature .* is not applicable to .*'
|
|
195
|
+
):
|
|
196
|
+
TestingEnvironment(
|
|
197
|
+
image_ids=[
|
|
198
|
+
'test_image1',
|
|
199
|
+
],
|
|
200
|
+
features={
|
|
201
|
+
'test_feature2': TestingFeature(
|
|
202
|
+
applicable_images=['test_image2.*']
|
|
203
|
+
),
|
|
204
|
+
},
|
|
205
|
+
)
|
|
206
|
+
env = TestingEnvironment(
|
|
207
|
+
image_ids=[],
|
|
208
|
+
supports_dynamic_image_loading=True,
|
|
209
|
+
features={
|
|
210
|
+
'test_feature2': TestingFeature(
|
|
211
|
+
applicable_images=['test_image2.*']
|
|
212
|
+
),
|
|
213
|
+
},
|
|
214
|
+
pool_size=0
|
|
215
|
+
)
|
|
216
|
+
with env:
|
|
217
|
+
with self.assertRaisesRegex(
|
|
218
|
+
ValueError, 'No image ID found for feature .*'
|
|
219
|
+
):
|
|
220
|
+
with env.test_feature2():
|
|
221
|
+
pass
|
|
222
|
+
|
|
223
|
+
# Dynamically loaded IDs.
|
|
224
|
+
with env.test_feature2('test_image2') as feature:
|
|
225
|
+
self.assertEqual(feature.sandbox.image_id, 'test_image2')
|
|
226
|
+
|
|
227
|
+
def test_pool_size(self):
|
|
228
|
+
env = TestingEnvironment(
|
|
229
|
+
image_ids=['test_image'],
|
|
230
|
+
pool_size=1,
|
|
231
|
+
outage_grace_period=1,
|
|
232
|
+
outage_retry_interval=0,
|
|
233
|
+
)
|
|
234
|
+
self.assertEqual(env.min_pool_size('test_image'), 1)
|
|
235
|
+
self.assertEqual(env.max_pool_size('test_image'), 1)
|
|
236
|
+
|
|
237
|
+
env = TestingEnvironment(
|
|
238
|
+
image_ids=['test_image'],
|
|
239
|
+
pool_size=(0, 256),
|
|
240
|
+
outage_grace_period=1,
|
|
241
|
+
outage_retry_interval=0,
|
|
242
|
+
)
|
|
243
|
+
self.assertEqual(env.min_pool_size('test_image'), 0)
|
|
244
|
+
self.assertEqual(env.max_pool_size('test_image'), 256)
|
|
245
|
+
|
|
246
|
+
env = TestingEnvironment(
|
|
247
|
+
image_ids=['test_image'],
|
|
248
|
+
pool_size={
|
|
249
|
+
'test_.*': (0, 128),
|
|
250
|
+
'my.*': (5, 64),
|
|
251
|
+
'exact_image_name': 10,
|
|
252
|
+
},
|
|
253
|
+
outage_grace_period=1,
|
|
254
|
+
outage_retry_interval=0,
|
|
255
|
+
)
|
|
256
|
+
self.assertEqual(env.min_pool_size('test_image'), 0)
|
|
257
|
+
self.assertEqual(env.max_pool_size('test_image'), 128)
|
|
258
|
+
self.assertEqual(env.min_pool_size('my_image'), 5)
|
|
259
|
+
self.assertEqual(env.max_pool_size('my_image'), 64)
|
|
260
|
+
self.assertEqual(env.min_pool_size('exact_image_name'), 10)
|
|
261
|
+
self.assertEqual(env.max_pool_size('exact_image_name'), 10)
|
|
262
|
+
self.assertEqual(env.min_pool_size('some_image'), 0) # default
|
|
263
|
+
self.assertEqual(env.max_pool_size('some_image'), 256) # default
|
|
264
|
+
|
|
81
265
|
def test_del(self):
|
|
82
266
|
env = TestingEnvironment(
|
|
83
267
|
features={'test_feature': TestingFeature()},
|
|
@@ -168,19 +352,21 @@ class EnvironmentTests(unittest.TestCase):
|
|
|
168
352
|
sandbox_keepalive_interval=0,
|
|
169
353
|
)
|
|
170
354
|
with env:
|
|
171
|
-
self.assertEqual(len(env.sandbox_pool), 1)
|
|
355
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 1)
|
|
172
356
|
self.assertEqual(
|
|
173
357
|
env.stats(),
|
|
174
358
|
{
|
|
175
359
|
'sandbox': {
|
|
176
|
-
'
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
360
|
+
'test_image': {
|
|
361
|
+
'created': 0,
|
|
362
|
+
'setting_up': 0,
|
|
363
|
+
'ready': 1,
|
|
364
|
+
'acquired': 0,
|
|
365
|
+
'in_session': 0,
|
|
366
|
+
'exiting_session': 0,
|
|
367
|
+
'shutting_down': 0,
|
|
368
|
+
'offline': 0,
|
|
369
|
+
}
|
|
184
370
|
}
|
|
185
371
|
}
|
|
186
372
|
)
|
|
@@ -190,49 +376,44 @@ class EnvironmentTests(unittest.TestCase):
|
|
|
190
376
|
env.stats(),
|
|
191
377
|
{
|
|
192
378
|
'sandbox': {
|
|
193
|
-
'
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
379
|
+
'test_image': {
|
|
380
|
+
'created': 0,
|
|
381
|
+
'setting_up': 0,
|
|
382
|
+
'ready': 0,
|
|
383
|
+
'acquired': 1,
|
|
384
|
+
'in_session': 0,
|
|
385
|
+
'exiting_session': 0,
|
|
386
|
+
'shutting_down': 0,
|
|
387
|
+
'offline': 0,
|
|
388
|
+
}
|
|
201
389
|
}
|
|
202
390
|
}
|
|
203
391
|
)
|
|
204
|
-
self.assertEqual(len(env.sandbox_pool), 1)
|
|
392
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 1)
|
|
205
393
|
sb2 = env.acquire()
|
|
206
394
|
self.assertEqual(sb2.status, interface.Sandbox.Status.ACQUIRED)
|
|
207
|
-
self.assertEqual(len(env.sandbox_pool), 2)
|
|
395
|
+
self.assertEqual(len(env.sandbox_pool['test_image']), 2)
|
|
208
396
|
self.assertEqual(
|
|
209
397
|
env.stats(),
|
|
210
398
|
{
|
|
211
399
|
'sandbox': {
|
|
212
|
-
'
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
400
|
+
'test_image': {
|
|
401
|
+
'created': 0,
|
|
402
|
+
'setting_up': 0,
|
|
403
|
+
'ready': 0,
|
|
404
|
+
'acquired': 2,
|
|
405
|
+
'in_session': 0,
|
|
406
|
+
'exiting_session': 0,
|
|
407
|
+
'shutting_down': 0,
|
|
408
|
+
'offline': 0,
|
|
409
|
+
}
|
|
220
410
|
}
|
|
221
411
|
}
|
|
222
412
|
)
|
|
223
413
|
self.assertEqual(
|
|
224
414
|
env.stats(),
|
|
225
415
|
{
|
|
226
|
-
'sandbox': {
|
|
227
|
-
'created': 0,
|
|
228
|
-
'setting_up': 0,
|
|
229
|
-
'ready': 0,
|
|
230
|
-
'acquired': 0,
|
|
231
|
-
'in_session': 0,
|
|
232
|
-
'exiting_session': 0,
|
|
233
|
-
'shutting_down': 0,
|
|
234
|
-
'offline': 0,
|
|
235
|
-
}
|
|
416
|
+
'sandbox': {}
|
|
236
417
|
}
|
|
237
418
|
)
|
|
238
419
|
|
|
@@ -268,18 +449,21 @@ class EnvironmentTests(unittest.TestCase):
|
|
|
268
449
|
)
|
|
269
450
|
with env:
|
|
270
451
|
self.assertEqual(len(env.sandbox_pool), 1)
|
|
452
|
+
self.assertIn('test_image', env.sandbox_pool)
|
|
271
453
|
self.assertEqual(
|
|
272
|
-
env.sandbox_pool[0].status,
|
|
454
|
+
env.sandbox_pool['test_image'][0].status,
|
|
455
|
+
interface.Sandbox.Status.READY
|
|
273
456
|
)
|
|
274
457
|
# Make future sandbox setup to fail.
|
|
275
458
|
env.features.test_feature.rebind(
|
|
276
459
|
simulate_setup_error=interface.SandboxStateError,
|
|
277
460
|
skip_notification=True
|
|
278
461
|
)
|
|
279
|
-
with
|
|
280
|
-
with
|
|
462
|
+
with self.assertRaises(interface.SandboxStateError):
|
|
463
|
+
with env.sandbox() as sb:
|
|
281
464
|
sb.shell('bad command', raise_error=interface.SandboxStateError)
|
|
282
465
|
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
466
|
+
self.assertEqual(len(sb.state_errors), 1)
|
|
283
467
|
sb_offline_time = time.time()
|
|
284
468
|
while time.time() - sb_offline_time < 10:
|
|
285
469
|
if not env.is_online:
|
|
@@ -322,43 +506,45 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
322
506
|
'feature2': TestingFeature(),
|
|
323
507
|
},
|
|
324
508
|
)
|
|
325
|
-
self.assertFalse(env.enable_pooling)
|
|
509
|
+
self.assertFalse(env.enable_pooling('test_image'))
|
|
326
510
|
with env:
|
|
327
|
-
with env.sandbox('session1') as sb:
|
|
511
|
+
with env.sandbox(session_id='session1') as sb:
|
|
328
512
|
sb.shell('echo "hello"')
|
|
329
513
|
self.assertEqual(
|
|
330
514
|
self.event_handler.logs,
|
|
331
515
|
[
|
|
516
|
+
# pylint: disable=line-too-long
|
|
332
517
|
'[testing-env] environment started',
|
|
333
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
334
|
-
'[testing-env/0/feature1] feature setup',
|
|
335
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
336
|
-
'[testing-env/0/feature2] feature setup',
|
|
337
|
-
'[testing-env/0] created -> ready',
|
|
338
|
-
'[testing-env/0] sandbox started',
|
|
339
|
-
'[testing-env/0] ready -> acquired',
|
|
340
|
-
'[testing-env/0] acquired -> setting_up',
|
|
341
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
342
|
-
'[testing-env/0/feature1] feature setup session',
|
|
343
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
344
|
-
'[testing-env/0/feature2] feature setup session',
|
|
345
|
-
'[testing-env/0] setting_up -> in_session',
|
|
346
|
-
"[testing-env/0] session 'session1' started",
|
|
347
|
-
'[testing-env/0/session1] shell: echo "hello"',
|
|
348
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
349
|
-
'[testing-env/0/session1] shell: "feature1" teardown session',
|
|
350
|
-
'[testing-env/0/feature1] feature teardown session',
|
|
351
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
352
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
353
|
-
"[testing-env/0] session 'session1' ended",
|
|
354
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
355
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
356
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
357
|
-
'[testing-env/0/feature1] feature teardown',
|
|
358
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
359
|
-
'[testing-env/0/feature2] feature teardown',
|
|
360
|
-
'[testing-env/0] shutting_down -> offline',
|
|
361
|
-
'[testing-env/0] sandbox shutdown'
|
|
518
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
519
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
520
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
521
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
522
|
+
'[testing-env/test_image:0] created -> ready',
|
|
523
|
+
'[testing-env/test_image:0] sandbox started',
|
|
524
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
525
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
526
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
527
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
528
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
529
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
530
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
531
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
532
|
+
'[testing-env/test_image:0/session1] shell: echo "hello"',
|
|
533
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
534
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown session',
|
|
535
|
+
'[testing-env/test_image:0/feature1] feature teardown session',
|
|
536
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
537
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
538
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
539
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
540
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
541
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
542
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
543
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
544
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
545
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
546
|
+
'[testing-env/test_image:0] sandbox shutdown'
|
|
547
|
+
# pylint: enable=line-too-long
|
|
362
548
|
]
|
|
363
549
|
)
|
|
364
550
|
|
|
@@ -371,9 +557,9 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
371
557
|
pool_size=1,
|
|
372
558
|
proactive_session_setup=True,
|
|
373
559
|
)
|
|
374
|
-
self.assertTrue(env.enable_pooling)
|
|
560
|
+
self.assertTrue(env.enable_pooling('test_image'))
|
|
375
561
|
with env:
|
|
376
|
-
with env.sandbox('session1') as sb:
|
|
562
|
+
with env.sandbox(session_id='session1') as sb:
|
|
377
563
|
sb.shell('echo "hello"')
|
|
378
564
|
sb.wait_until_not(
|
|
379
565
|
(
|
|
@@ -385,34 +571,36 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
385
571
|
self.assertEqual(
|
|
386
572
|
self.event_handler.logs,
|
|
387
573
|
[
|
|
388
|
-
|
|
389
|
-
'[testing-env/0:0
|
|
390
|
-
'[testing-env/0:0]
|
|
391
|
-
'[testing-env/0:0
|
|
392
|
-
'[testing-env/0:0]
|
|
393
|
-
'[testing-env/0:0
|
|
394
|
-
'[testing-env/0:0]
|
|
395
|
-
'[testing-env/0:0
|
|
396
|
-
'[testing-env/0:0]
|
|
397
|
-
'[testing-env/0:0]
|
|
574
|
+
# pylint: disable=line-too-long
|
|
575
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup',
|
|
576
|
+
'[testing-env/test_image:0:0/feature1] feature setup',
|
|
577
|
+
'[testing-env/test_image:0:0] shell: "feature2" setup',
|
|
578
|
+
'[testing-env/test_image:0:0/feature2] feature setup',
|
|
579
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup session',
|
|
580
|
+
'[testing-env/test_image:0:0/feature1] feature setup session',
|
|
581
|
+
'[testing-env/test_image:0:0] shell: "feature2" setup session',
|
|
582
|
+
'[testing-env/test_image:0:0/feature2] feature setup session',
|
|
583
|
+
'[testing-env/test_image:0:0] created -> ready',
|
|
584
|
+
'[testing-env/test_image:0:0] sandbox started',
|
|
398
585
|
'[testing-env] environment started',
|
|
399
|
-
'[testing-env/0:0] ready -> acquired',
|
|
400
|
-
'[testing-env/0:0] acquired -> setting_up',
|
|
401
|
-
'[testing-env/0:0] setting_up -> in_session',
|
|
402
|
-
"[testing-env/0:0] session 'session1' started",
|
|
403
|
-
'[testing-env/0:0/session1] shell: echo "hello"',
|
|
404
|
-
'[testing-env/0:0] in_session -> exiting_session',
|
|
405
|
-
'[testing-env/0:0/session1] shell: "feature1" teardown session',
|
|
406
|
-
'[testing-env/0:0/feature1] feature teardown session',
|
|
407
|
-
'[testing-env/0:0/session1] shell: "feature2" teardown session',
|
|
408
|
-
'[testing-env/0:0/feature2] feature teardown session',
|
|
409
|
-
"[testing-env/0:0] session 'session1' ended",
|
|
410
|
-
'[testing-env/0:0] exiting_session -> setting_up',
|
|
411
|
-
'[testing-env/0:0] shell: "feature1" setup session',
|
|
412
|
-
'[testing-env/0:0/feature1] feature setup session',
|
|
413
|
-
'[testing-env/0:0] shell: "feature2" setup session',
|
|
414
|
-
'[testing-env/0:0/feature2] feature setup session',
|
|
415
|
-
'[testing-env/0:0] setting_up -> ready'
|
|
586
|
+
'[testing-env/test_image:0:0] ready -> acquired',
|
|
587
|
+
'[testing-env/test_image:0:0] acquired -> setting_up',
|
|
588
|
+
'[testing-env/test_image:0:0] setting_up -> in_session',
|
|
589
|
+
"[testing-env/test_image:0:0] session 'session1' started",
|
|
590
|
+
'[testing-env/test_image:0:0/session1] shell: echo "hello"',
|
|
591
|
+
'[testing-env/test_image:0:0] in_session -> exiting_session',
|
|
592
|
+
'[testing-env/test_image:0:0/session1] shell: "feature1" teardown session',
|
|
593
|
+
'[testing-env/test_image:0:0/feature1] feature teardown session',
|
|
594
|
+
'[testing-env/test_image:0:0/session1] shell: "feature2" teardown session',
|
|
595
|
+
'[testing-env/test_image:0:0/feature2] feature teardown session',
|
|
596
|
+
"[testing-env/test_image:0:0] session 'session1' ended",
|
|
597
|
+
'[testing-env/test_image:0:0] exiting_session -> setting_up',
|
|
598
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup session',
|
|
599
|
+
'[testing-env/test_image:0:0/feature1] feature setup session',
|
|
600
|
+
'[testing-env/test_image:0:0] shell: "feature2" setup session',
|
|
601
|
+
'[testing-env/test_image:0:0/feature2] feature setup session',
|
|
602
|
+
'[testing-env/test_image:0:0] setting_up -> ready'
|
|
603
|
+
# pylint: enable=line-too-long
|
|
416
604
|
]
|
|
417
605
|
)
|
|
418
606
|
|
|
@@ -427,7 +615,7 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
427
615
|
log_session_setup=True,
|
|
428
616
|
)
|
|
429
617
|
with env:
|
|
430
|
-
with env.sandbox('session1') as sb:
|
|
618
|
+
with env.sandbox(session_id='session1') as sb:
|
|
431
619
|
sb.add_event_handler(event_handler)
|
|
432
620
|
sb.test_feature.rebind(
|
|
433
621
|
simulate_setup_session_error=interface.SandboxStateError,
|
|
@@ -445,17 +633,17 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
445
633
|
event_handler.logs,
|
|
446
634
|
[
|
|
447
635
|
# pylint: disable=line-too-long
|
|
448
|
-
'[testing-env/0:0] in_session -> exiting_session',
|
|
449
|
-
'[testing-env/0:0/session1] shell: "test_feature" teardown session',
|
|
450
|
-
'[testing-env/0:0/test_feature] feature teardown session',
|
|
451
|
-
"[testing-env/0:0] session 'session1' ended",
|
|
452
|
-
'[testing-env/0:0] exiting_session -> setting_up',
|
|
453
|
-
'[testing-env/0:0/test_feature] feature setup session with SandboxStateError', # pylint: disable=line-too-long
|
|
454
|
-
'[testing-env/0:0] setting_up -> shutting_down',
|
|
455
|
-
'[testing-env/0:0] shell: "test_feature" teardown',
|
|
456
|
-
'[testing-env/0:0/test_feature] feature teardown',
|
|
457
|
-
'[testing-env/0:0] shutting_down -> offline',
|
|
458
|
-
'[testing-env/0:0] sandbox shutdown'
|
|
636
|
+
'[testing-env/test_image:0:0] in_session -> exiting_session',
|
|
637
|
+
'[testing-env/test_image:0:0/session1] shell: "test_feature" teardown session',
|
|
638
|
+
'[testing-env/test_image:0:0/test_feature] feature teardown session',
|
|
639
|
+
"[testing-env/test_image:0:0] session 'session1' ended",
|
|
640
|
+
'[testing-env/test_image:0:0] exiting_session -> setting_up',
|
|
641
|
+
'[testing-env/test_image:0:0/test_feature] feature setup session with SandboxStateError', # pylint: disable=line-too-long
|
|
642
|
+
'[testing-env/test_image:0:0] setting_up -> shutting_down',
|
|
643
|
+
'[testing-env/test_image:0:0] shell: "test_feature" teardown',
|
|
644
|
+
'[testing-env/test_image:0:0/test_feature] feature teardown',
|
|
645
|
+
'[testing-env/test_image:0:0] shutting_down -> offline',
|
|
646
|
+
'[testing-env/test_image:0:0] sandbox shutdown'
|
|
459
647
|
# pylint: enable=line-too-long
|
|
460
648
|
]
|
|
461
649
|
)
|
|
@@ -470,17 +658,17 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
470
658
|
)
|
|
471
659
|
with env:
|
|
472
660
|
with self.assertRaises(ValueError):
|
|
473
|
-
with env.sandbox('session1'):
|
|
661
|
+
with env.sandbox(session_id='session1'):
|
|
474
662
|
pass
|
|
475
663
|
self.assertTrue(env.is_online)
|
|
476
664
|
self.assertEqual(
|
|
477
665
|
self.event_handler.logs,
|
|
478
666
|
[
|
|
479
667
|
'[testing-env] environment started',
|
|
480
|
-
'[testing-env/0] sandbox started with ValueError',
|
|
481
|
-
'[testing-env/0] created -> shutting_down',
|
|
482
|
-
'[testing-env/0] shutting_down -> offline',
|
|
483
|
-
'[testing-env/0] sandbox shutdown'
|
|
668
|
+
'[testing-env/test_image:0] sandbox started with ValueError',
|
|
669
|
+
'[testing-env/test_image:0] created -> shutting_down',
|
|
670
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
671
|
+
'[testing-env/test_image:0] sandbox shutdown'
|
|
484
672
|
]
|
|
485
673
|
)
|
|
486
674
|
|
|
@@ -499,12 +687,14 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
499
687
|
self.assertEqual(
|
|
500
688
|
self.event_handler.logs,
|
|
501
689
|
[
|
|
502
|
-
|
|
503
|
-
'[testing-env/0:0]
|
|
504
|
-
'[testing-env/0:0]
|
|
505
|
-
'[testing-env/0:0]
|
|
690
|
+
# pylint: disable=line-too-long
|
|
691
|
+
'[testing-env/test_image:0:0] sandbox started with SandboxStateError',
|
|
692
|
+
'[testing-env/test_image:0:0] created -> shutting_down',
|
|
693
|
+
'[testing-env/test_image:0:0] shutting_down -> offline',
|
|
694
|
+
'[testing-env/test_image:0:0] sandbox shutdown',
|
|
506
695
|
'[testing-env] environment started with EnvironmentOutageError',
|
|
507
696
|
'[testing-env] environment shutdown'
|
|
697
|
+
# pylint: enable=line-too-long
|
|
508
698
|
]
|
|
509
699
|
)
|
|
510
700
|
|
|
@@ -518,44 +708,46 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
518
708
|
)
|
|
519
709
|
with env:
|
|
520
710
|
with self.assertRaises(ValueError):
|
|
521
|
-
with env.sandbox('session1') as sb:
|
|
711
|
+
with env.sandbox(session_id='session1') as sb:
|
|
522
712
|
sb.shell('echo "hello"')
|
|
523
713
|
self.assertEqual(len(sb.state_errors), 0)
|
|
524
714
|
|
|
525
715
|
self.assertEqual(
|
|
526
716
|
self.event_handler.logs,
|
|
527
717
|
[
|
|
718
|
+
# pylint: disable=line-too-long
|
|
528
719
|
'[testing-env] environment started',
|
|
529
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
530
|
-
'[testing-env/0/feature1] feature setup',
|
|
531
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
532
|
-
'[testing-env/0/feature2] feature setup',
|
|
533
|
-
'[testing-env/0] created -> ready',
|
|
534
|
-
'[testing-env/0] sandbox started',
|
|
535
|
-
'[testing-env/0] ready -> acquired',
|
|
536
|
-
'[testing-env/0] acquired -> setting_up',
|
|
537
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
538
|
-
'[testing-env/0/feature1] feature setup session',
|
|
539
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
540
|
-
'[testing-env/0/feature2] feature setup session',
|
|
541
|
-
'[testing-env/0] setting_up -> in_session',
|
|
542
|
-
"[testing-env/0] session 'session1' started",
|
|
543
|
-
'[testing-env/0/session1] shell: echo "hello"',
|
|
544
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
545
|
-
'[testing-env/0/session1] shell: "feature1" teardown session',
|
|
546
|
-
'[testing-env/0/feature1] feature teardown session',
|
|
547
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
548
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
549
|
-
"[testing-env/0] session 'session1' ended",
|
|
550
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
551
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
552
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
553
|
-
'[testing-env/0/feature1] feature teardown',
|
|
554
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
555
|
-
'[testing-env/0/feature2] feature teardown',
|
|
556
|
-
'[testing-env/0] shutting_down -> offline',
|
|
557
|
-
'[testing-env/0] sandbox shutdown with ValueError',
|
|
720
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
721
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
722
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
723
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
724
|
+
'[testing-env/test_image:0] created -> ready',
|
|
725
|
+
'[testing-env/test_image:0] sandbox started',
|
|
726
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
727
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
728
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
729
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
730
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
731
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
732
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
733
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
734
|
+
'[testing-env/test_image:0/session1] shell: echo "hello"',
|
|
735
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
736
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown session',
|
|
737
|
+
'[testing-env/test_image:0/feature1] feature teardown session',
|
|
738
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
739
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
740
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
741
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
742
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
743
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
744
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
745
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
746
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
747
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
748
|
+
'[testing-env/test_image:0] sandbox shutdown with ValueError',
|
|
558
749
|
'[testing-env] environment shutdown'
|
|
750
|
+
# pylint: enable=line-too-long
|
|
559
751
|
]
|
|
560
752
|
)
|
|
561
753
|
|
|
@@ -575,25 +767,27 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
575
767
|
self.assertEqual(
|
|
576
768
|
self.event_handler.logs,
|
|
577
769
|
[
|
|
578
|
-
|
|
579
|
-
'[testing-env/0:0
|
|
580
|
-
'[testing-env/0:0]
|
|
581
|
-
'[testing-env/0:0
|
|
582
|
-
'[testing-env/0:0]
|
|
583
|
-
'[testing-env/0:0
|
|
584
|
-
'[testing-env/0:0]
|
|
585
|
-
'[testing-env/0:0
|
|
586
|
-
'[testing-env/0:0]
|
|
587
|
-
'[testing-env/0:0]
|
|
770
|
+
# pylint: disable=line-too-long
|
|
771
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup',
|
|
772
|
+
'[testing-env/test_image:0:0/feature1] feature setup',
|
|
773
|
+
'[testing-env/test_image:0:0] shell: "feature2" setup',
|
|
774
|
+
'[testing-env/test_image:0:0/feature2] feature setup',
|
|
775
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup session',
|
|
776
|
+
'[testing-env/test_image:0:0/feature1] feature setup session',
|
|
777
|
+
'[testing-env/test_image:0:0] shell: "feature2" setup session',
|
|
778
|
+
'[testing-env/test_image:0:0/feature2] feature setup session',
|
|
779
|
+
'[testing-env/test_image:0:0] created -> ready',
|
|
780
|
+
'[testing-env/test_image:0:0] sandbox started',
|
|
588
781
|
'[testing-env] environment started',
|
|
589
|
-
'[testing-env/0:0] ready -> shutting_down',
|
|
590
|
-
'[testing-env/0:0] shell: "feature1" teardown',
|
|
591
|
-
'[testing-env/0:0/feature1] feature teardown',
|
|
592
|
-
'[testing-env/0:0] shell: "feature2" teardown',
|
|
593
|
-
'[testing-env/0:0/feature2] feature teardown',
|
|
594
|
-
'[testing-env/0:0] shutting_down -> offline',
|
|
595
|
-
'[testing-env/0:0] sandbox shutdown with ValueError',
|
|
782
|
+
'[testing-env/test_image:0:0] ready -> shutting_down',
|
|
783
|
+
'[testing-env/test_image:0:0] shell: "feature1" teardown',
|
|
784
|
+
'[testing-env/test_image:0:0/feature1] feature teardown',
|
|
785
|
+
'[testing-env/test_image:0:0] shell: "feature2" teardown',
|
|
786
|
+
'[testing-env/test_image:0:0/feature2] feature teardown',
|
|
787
|
+
'[testing-env/test_image:0:0] shutting_down -> offline',
|
|
788
|
+
'[testing-env/test_image:0:0] sandbox shutdown with ValueError',
|
|
596
789
|
'[testing-env] environment shutdown with ValueError'
|
|
790
|
+
# pylint: enable=line-too-long
|
|
597
791
|
]
|
|
598
792
|
)
|
|
599
793
|
|
|
@@ -606,43 +800,45 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
606
800
|
simulate_shutdown_error=interface.SandboxStateError,
|
|
607
801
|
)
|
|
608
802
|
with env:
|
|
609
|
-
with env.sandbox('session1') as sb:
|
|
803
|
+
with env.sandbox(session_id='session1') as sb:
|
|
610
804
|
sb.shell('echo "hello"')
|
|
611
805
|
self.assertEqual(len(sb.state_errors), 1)
|
|
612
806
|
self.assertEqual(
|
|
613
807
|
self.event_handler.logs,
|
|
614
808
|
[
|
|
809
|
+
# pylint: disable=line-too-long
|
|
615
810
|
'[testing-env] environment started',
|
|
616
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
617
|
-
'[testing-env/0/feature1] feature setup',
|
|
618
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
619
|
-
'[testing-env/0/feature2] feature setup',
|
|
620
|
-
'[testing-env/0] created -> ready',
|
|
621
|
-
'[testing-env/0] sandbox started',
|
|
622
|
-
'[testing-env/0] ready -> acquired',
|
|
623
|
-
'[testing-env/0] acquired -> setting_up',
|
|
624
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
625
|
-
'[testing-env/0/feature1] feature setup session',
|
|
626
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
627
|
-
'[testing-env/0/feature2] feature setup session',
|
|
628
|
-
'[testing-env/0] setting_up -> in_session',
|
|
629
|
-
"[testing-env/0] session 'session1' started",
|
|
630
|
-
'[testing-env/0/session1] shell: echo "hello"',
|
|
631
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
632
|
-
'[testing-env/0/session1] shell: "feature1" teardown session',
|
|
633
|
-
'[testing-env/0/feature1] feature teardown session',
|
|
634
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
635
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
636
|
-
"[testing-env/0] session 'session1' ended",
|
|
637
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
638
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
639
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
640
|
-
'[testing-env/0/feature1] feature teardown',
|
|
641
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
642
|
-
'[testing-env/0/feature2] feature teardown',
|
|
643
|
-
'[testing-env/0] shutting_down -> offline',
|
|
644
|
-
'[testing-env/0] sandbox shutdown with SandboxStateError',
|
|
811
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
812
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
813
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
814
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
815
|
+
'[testing-env/test_image:0] created -> ready',
|
|
816
|
+
'[testing-env/test_image:0] sandbox started',
|
|
817
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
818
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
819
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
820
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
821
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
822
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
823
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
824
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
825
|
+
'[testing-env/test_image:0/session1] shell: echo "hello"',
|
|
826
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
827
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown session',
|
|
828
|
+
'[testing-env/test_image:0/feature1] feature teardown session',
|
|
829
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
830
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
831
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
832
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
833
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
834
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
835
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
836
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
837
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
838
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
839
|
+
'[testing-env/test_image:0] sandbox shutdown with SandboxStateError',
|
|
645
840
|
'[testing-env] environment shutdown'
|
|
841
|
+
# pylint: enable=line-too-long
|
|
646
842
|
]
|
|
647
843
|
)
|
|
648
844
|
|
|
@@ -657,23 +853,25 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
657
853
|
)
|
|
658
854
|
with env:
|
|
659
855
|
with self.assertRaises(ValueError):
|
|
660
|
-
with env.sandbox('session1'):
|
|
856
|
+
with env.sandbox(session_id='session1'):
|
|
661
857
|
pass
|
|
662
858
|
self.assertEqual(
|
|
663
859
|
self.event_handler.logs,
|
|
664
860
|
[
|
|
861
|
+
# pylint: disable=line-too-long
|
|
665
862
|
'[testing-env] environment started',
|
|
666
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
667
|
-
'[testing-env/0/feature1] feature setup',
|
|
668
|
-
'[testing-env/0/feature2] feature setup with ValueError',
|
|
669
|
-
'[testing-env/0] sandbox started with ValueError',
|
|
670
|
-
'[testing-env/0] created -> shutting_down',
|
|
671
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
672
|
-
'[testing-env/0/feature1] feature teardown',
|
|
673
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
674
|
-
'[testing-env/0/feature2] feature teardown',
|
|
675
|
-
'[testing-env/0] shutting_down -> offline',
|
|
676
|
-
'[testing-env/0] sandbox shutdown'
|
|
863
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
864
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
865
|
+
'[testing-env/test_image:0/feature2] feature setup with ValueError',
|
|
866
|
+
'[testing-env/test_image:0] sandbox started with ValueError',
|
|
867
|
+
'[testing-env/test_image:0] created -> shutting_down',
|
|
868
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
869
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
870
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
871
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
872
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
873
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
874
|
+
# pylint: enable=line-too-long
|
|
677
875
|
]
|
|
678
876
|
)
|
|
679
877
|
|
|
@@ -688,20 +886,22 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
688
886
|
)
|
|
689
887
|
with env:
|
|
690
888
|
with self.assertRaises(interface.EnvironmentOutageError):
|
|
691
|
-
with env.sandbox('session1'):
|
|
889
|
+
with env.sandbox(session_id='session1'):
|
|
692
890
|
pass
|
|
693
891
|
self.assertEqual(
|
|
694
892
|
self.event_handler.logs,
|
|
695
893
|
[
|
|
894
|
+
# pylint: disable=line-too-long
|
|
696
895
|
'[testing-env] environment started',
|
|
697
|
-
'[testing-env/0/feature1] feature setup with SandboxStateError',
|
|
698
|
-
'[testing-env/0] sandbox started with SandboxStateError',
|
|
699
|
-
'[testing-env/0] created -> shutting_down',
|
|
700
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
701
|
-
'[testing-env/0/feature1] feature teardown',
|
|
702
|
-
'[testing-env/0] shutting_down -> offline',
|
|
703
|
-
'[testing-env/0] sandbox shutdown',
|
|
704
|
-
'[testing-env] environment shutdown'
|
|
896
|
+
'[testing-env/test_image:0/feature1] feature setup with SandboxStateError',
|
|
897
|
+
'[testing-env/test_image:0] sandbox started with SandboxStateError',
|
|
898
|
+
'[testing-env/test_image:0] created -> shutting_down',
|
|
899
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
900
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
901
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
902
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
903
|
+
'[testing-env] environment shutdown',
|
|
904
|
+
# pylint: enable=line-too-long
|
|
705
905
|
]
|
|
706
906
|
)
|
|
707
907
|
|
|
@@ -716,39 +916,41 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
716
916
|
)
|
|
717
917
|
with env:
|
|
718
918
|
with self.assertRaises(interface.FeatureTeardownError):
|
|
719
|
-
with env.sandbox('session1'):
|
|
919
|
+
with env.sandbox(session_id='session1'):
|
|
720
920
|
pass
|
|
721
921
|
self.assertEqual(
|
|
722
922
|
self.event_handler.logs,
|
|
723
923
|
[
|
|
924
|
+
# pylint: disable=line-too-long
|
|
724
925
|
'[testing-env] environment started',
|
|
725
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
726
|
-
'[testing-env/0/feature1] feature setup',
|
|
727
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
728
|
-
'[testing-env/0/feature2] feature setup',
|
|
729
|
-
'[testing-env/0] created -> ready',
|
|
730
|
-
'[testing-env/0] sandbox started',
|
|
731
|
-
'[testing-env/0] ready -> acquired',
|
|
732
|
-
'[testing-env/0] acquired -> setting_up',
|
|
733
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
734
|
-
'[testing-env/0/feature1] feature setup session',
|
|
735
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
736
|
-
'[testing-env/0/feature2] feature setup session',
|
|
737
|
-
'[testing-env/0] setting_up -> in_session',
|
|
738
|
-
"[testing-env/0] session 'session1' started",
|
|
739
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
740
|
-
'[testing-env/0/session1] shell: "feature1" teardown session',
|
|
741
|
-
'[testing-env/0/feature1] feature teardown session',
|
|
742
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
743
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
744
|
-
"[testing-env/0] session 'session1' ended",
|
|
745
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
746
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
747
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
748
|
-
'[testing-env/0/feature1] feature teardown',
|
|
749
|
-
'[testing-env/0/feature2] feature teardown with ValueError',
|
|
750
|
-
'[testing-env/0] shutting_down -> offline',
|
|
751
|
-
'[testing-env/0] sandbox shutdown with FeatureTeardownError',
|
|
926
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
927
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
928
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
929
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
930
|
+
'[testing-env/test_image:0] created -> ready',
|
|
931
|
+
'[testing-env/test_image:0] sandbox started',
|
|
932
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
933
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
934
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
935
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
936
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
937
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
938
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
939
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
940
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
941
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown session',
|
|
942
|
+
'[testing-env/test_image:0/feature1] feature teardown session',
|
|
943
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
944
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
945
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
946
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
947
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
948
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
949
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
950
|
+
'[testing-env/test_image:0/feature2] feature teardown with ValueError',
|
|
951
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
952
|
+
'[testing-env/test_image:0] sandbox shutdown with FeatureTeardownError',
|
|
953
|
+
# pylint: enable=line-too-long
|
|
752
954
|
]
|
|
753
955
|
)
|
|
754
956
|
|
|
@@ -763,40 +965,42 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
763
965
|
},
|
|
764
966
|
)
|
|
765
967
|
with env:
|
|
766
|
-
with env.sandbox('session1') as sb:
|
|
968
|
+
with env.sandbox(session_id='session1') as sb:
|
|
767
969
|
pass
|
|
768
970
|
self.assertEqual(len(sb.state_errors), 1)
|
|
769
971
|
self.assertEqual(
|
|
770
972
|
self.event_handler.logs,
|
|
771
973
|
[
|
|
974
|
+
# pylint: disable=line-too-long
|
|
772
975
|
'[testing-env] environment started',
|
|
773
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
774
|
-
'[testing-env/0/feature1] feature setup',
|
|
775
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
776
|
-
'[testing-env/0/feature2] feature setup',
|
|
777
|
-
'[testing-env/0] created -> ready',
|
|
778
|
-
'[testing-env/0] sandbox started',
|
|
779
|
-
'[testing-env/0] ready -> acquired',
|
|
780
|
-
'[testing-env/0] acquired -> setting_up',
|
|
781
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
782
|
-
'[testing-env/0/feature1] feature setup session',
|
|
783
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
784
|
-
'[testing-env/0/feature2] feature setup session',
|
|
785
|
-
'[testing-env/0] setting_up -> in_session',
|
|
786
|
-
"[testing-env/0] session 'session1' started",
|
|
787
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
788
|
-
'[testing-env/0/session1] shell: "feature1" teardown session',
|
|
789
|
-
'[testing-env/0/feature1] feature teardown session',
|
|
790
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
791
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
792
|
-
"[testing-env/0] session 'session1' ended",
|
|
793
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
794
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
795
|
-
'[testing-env/0/feature1] feature teardown with SandboxStateError', # pylint: disable=line-too-long
|
|
796
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
797
|
-
'[testing-env/0/feature2] feature teardown',
|
|
798
|
-
'[testing-env/0] shutting_down -> offline',
|
|
799
|
-
'[testing-env/0] sandbox shutdown with FeatureTeardownError'
|
|
976
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
977
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
978
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
979
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
980
|
+
'[testing-env/test_image:0] created -> ready',
|
|
981
|
+
'[testing-env/test_image:0] sandbox started',
|
|
982
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
983
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
984
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
985
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
986
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
987
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
988
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
989
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
990
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
991
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown session',
|
|
992
|
+
'[testing-env/test_image:0/feature1] feature teardown session',
|
|
993
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
994
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
995
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
996
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
997
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
998
|
+
'[testing-env/test_image:0/feature1] feature teardown with SandboxStateError', # pylint: disable=line-too-long
|
|
999
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
1000
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
1001
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
1002
|
+
'[testing-env/test_image:0] sandbox shutdown with FeatureTeardownError',
|
|
1003
|
+
# pylint: enable=line-too-long
|
|
800
1004
|
]
|
|
801
1005
|
)
|
|
802
1006
|
|
|
@@ -811,31 +1015,33 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
811
1015
|
)
|
|
812
1016
|
with env:
|
|
813
1017
|
with self.assertRaises(ValueError):
|
|
814
|
-
with env.sandbox('session1') as sb:
|
|
1018
|
+
with env.sandbox(session_id='session1') as sb:
|
|
815
1019
|
sb.shell('echo "hello"')
|
|
816
1020
|
self.assertEqual(
|
|
817
1021
|
self.event_handler.logs,
|
|
818
1022
|
[
|
|
1023
|
+
# pylint: disable=line-too-long
|
|
819
1024
|
'[testing-env] environment started',
|
|
820
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
821
|
-
'[testing-env/0/feature1] feature setup',
|
|
822
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
823
|
-
'[testing-env/0/feature2] feature setup',
|
|
824
|
-
'[testing-env/0] created -> ready',
|
|
825
|
-
'[testing-env/0] sandbox started',
|
|
826
|
-
'[testing-env/0] ready -> acquired',
|
|
827
|
-
'[testing-env/0] acquired -> setting_up',
|
|
828
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
829
|
-
'[testing-env/0/feature1] feature setup session',
|
|
830
|
-
'[testing-env/0/feature2] feature setup session with ValueError',
|
|
831
|
-
"[testing-env/0] session 'session1' started with ValueError",
|
|
832
|
-
'[testing-env/0] setting_up -> shutting_down',
|
|
833
|
-
'[testing-env/0/session1] shell: "feature1" teardown',
|
|
834
|
-
'[testing-env/0/feature1] feature teardown',
|
|
835
|
-
'[testing-env/0/session1] shell: "feature2" teardown',
|
|
836
|
-
'[testing-env/0/feature2] feature teardown',
|
|
837
|
-
'[testing-env/0] shutting_down -> offline',
|
|
838
|
-
'[testing-env/0] sandbox shutdown'
|
|
1025
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
1026
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
1027
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
1028
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
1029
|
+
'[testing-env/test_image:0] created -> ready',
|
|
1030
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1031
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
1032
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
1033
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
1034
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
1035
|
+
'[testing-env/test_image:0/feature2] feature setup session with ValueError',
|
|
1036
|
+
"[testing-env/test_image:0] session 'session1' started with ValueError",
|
|
1037
|
+
'[testing-env/test_image:0] setting_up -> shutting_down',
|
|
1038
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown',
|
|
1039
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
1040
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown',
|
|
1041
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
1042
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
1043
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1044
|
+
# pylint: enable=line-too-long
|
|
839
1045
|
]
|
|
840
1046
|
)
|
|
841
1047
|
|
|
@@ -850,41 +1056,43 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
850
1056
|
)
|
|
851
1057
|
with env:
|
|
852
1058
|
with self.assertRaises(interface.SessionTeardownError):
|
|
853
|
-
with env.sandbox('session1') as sb:
|
|
1059
|
+
with env.sandbox(session_id='session1') as sb:
|
|
854
1060
|
sb.shell('echo "hello"')
|
|
855
1061
|
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
856
1062
|
self.assertEqual(
|
|
857
1063
|
self.event_handler.logs,
|
|
858
1064
|
[
|
|
1065
|
+
# pylint: disable=line-too-long
|
|
859
1066
|
'[testing-env] environment started',
|
|
860
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
861
|
-
'[testing-env/0/feature1] feature setup',
|
|
862
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
863
|
-
'[testing-env/0/feature2] feature setup',
|
|
864
|
-
'[testing-env/0] created -> ready',
|
|
865
|
-
'[testing-env/0] sandbox started',
|
|
866
|
-
'[testing-env/0] ready -> acquired',
|
|
867
|
-
'[testing-env/0] acquired -> setting_up',
|
|
868
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
869
|
-
'[testing-env/0/feature1] feature setup session',
|
|
870
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
871
|
-
'[testing-env/0/feature2] feature setup session',
|
|
872
|
-
'[testing-env/0] setting_up -> in_session',
|
|
873
|
-
"[testing-env/0] session 'session1' started",
|
|
874
|
-
'[testing-env/0/session1] shell: echo "hello"',
|
|
875
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
876
|
-
'[testing-env/0/feature1] feature teardown session with ValueError', # pylint: disable=line-too-long
|
|
877
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
878
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
879
|
-
"[testing-env/0] session 'session1' ended",
|
|
880
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
881
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
882
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
883
|
-
'[testing-env/0/feature1] feature teardown',
|
|
884
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
885
|
-
'[testing-env/0/feature2] feature teardown',
|
|
886
|
-
'[testing-env/0] shutting_down -> offline',
|
|
887
|
-
'[testing-env/0] sandbox shutdown'
|
|
1067
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
1068
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
1069
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
1070
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
1071
|
+
'[testing-env/test_image:0] created -> ready',
|
|
1072
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1073
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
1074
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
1075
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
1076
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
1077
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
1078
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
1079
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
1080
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1081
|
+
'[testing-env/test_image:0/session1] shell: echo "hello"',
|
|
1082
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
1083
|
+
'[testing-env/test_image:0/feature1] feature teardown session with ValueError', # pylint: disable=line-too-long
|
|
1084
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
1085
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
1086
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
1087
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
1088
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
1089
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
1090
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
1091
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
1092
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
1093
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
1094
|
+
'[testing-env/test_image:0] sandbox shutdown'
|
|
1095
|
+
# pylint: enable=line-too-long
|
|
888
1096
|
]
|
|
889
1097
|
)
|
|
890
1098
|
|
|
@@ -898,42 +1106,44 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
898
1106
|
},
|
|
899
1107
|
)
|
|
900
1108
|
with env:
|
|
901
|
-
with env.sandbox('session1') as sb:
|
|
1109
|
+
with env.sandbox(session_id='session1') as sb:
|
|
902
1110
|
sb.shell('echo "hello"')
|
|
903
1111
|
self.assertEqual(len(sb.state_errors), 1)
|
|
904
1112
|
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
905
1113
|
self.assertEqual(
|
|
906
1114
|
self.event_handler.logs,
|
|
907
1115
|
[
|
|
1116
|
+
# pylint: disable=line-too-long
|
|
908
1117
|
'[testing-env] environment started',
|
|
909
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
910
|
-
'[testing-env/0/feature1] feature setup',
|
|
911
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
912
|
-
'[testing-env/0/feature2] feature setup',
|
|
913
|
-
'[testing-env/0] created -> ready',
|
|
914
|
-
'[testing-env/0] sandbox started',
|
|
915
|
-
'[testing-env/0] ready -> acquired',
|
|
916
|
-
'[testing-env/0] acquired -> setting_up',
|
|
917
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
918
|
-
'[testing-env/0/feature1] feature setup session',
|
|
919
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
920
|
-
'[testing-env/0/feature2] feature setup session',
|
|
921
|
-
'[testing-env/0] setting_up -> in_session',
|
|
922
|
-
"[testing-env/0] session 'session1' started",
|
|
923
|
-
'[testing-env/0/session1] shell: echo "hello"',
|
|
924
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
925
|
-
'[testing-env/0/feature1] feature teardown session with SandboxStateError', # pylint: disable=line-too-long
|
|
926
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
927
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
928
|
-
"[testing-env/0] session 'session1' ended with SandboxStateError",
|
|
929
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
930
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
931
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
932
|
-
'[testing-env/0/feature1] feature teardown',
|
|
933
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
934
|
-
'[testing-env/0/feature2] feature teardown',
|
|
935
|
-
'[testing-env/0] shutting_down -> offline',
|
|
936
|
-
'[testing-env/0] sandbox shutdown'
|
|
1118
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
1119
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
1120
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
1121
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
1122
|
+
'[testing-env/test_image:0] created -> ready',
|
|
1123
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1124
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
1125
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
1126
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
1127
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
1128
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
1129
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
1130
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
1131
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1132
|
+
'[testing-env/test_image:0/session1] shell: echo "hello"',
|
|
1133
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
1134
|
+
'[testing-env/test_image:0/feature1] feature teardown session with SandboxStateError', # pylint: disable=line-too-long
|
|
1135
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
1136
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
1137
|
+
"[testing-env/test_image:0] session 'session1' ended with SandboxStateError",
|
|
1138
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
1139
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
1140
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
1141
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
1142
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
1143
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
1144
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
1145
|
+
'[testing-env/test_image:0] sandbox shutdown'
|
|
1146
|
+
# pylint: enable=line-too-long
|
|
937
1147
|
]
|
|
938
1148
|
)
|
|
939
1149
|
|
|
@@ -947,41 +1157,43 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
947
1157
|
},
|
|
948
1158
|
)
|
|
949
1159
|
with env:
|
|
950
|
-
with env.sandbox('session1') as sb:
|
|
1160
|
+
with env.sandbox(session_id='session1') as sb:
|
|
951
1161
|
sb.shell('echo "hello"')
|
|
952
1162
|
self.assertEqual(
|
|
953
1163
|
self.event_handler.logs,
|
|
954
1164
|
[
|
|
1165
|
+
# pylint: disable=line-too-long
|
|
955
1166
|
'[testing-env] environment started',
|
|
956
|
-
'[testing-env/0] shell: "feature1" setup',
|
|
957
|
-
'[testing-env/0/feature1] feature setup',
|
|
958
|
-
'[testing-env/0] shell: "feature2" setup',
|
|
959
|
-
'[testing-env/0/feature2] feature setup',
|
|
960
|
-
'[testing-env/0] created -> ready',
|
|
961
|
-
'[testing-env/0] sandbox started',
|
|
962
|
-
'[testing-env/0] ready -> acquired',
|
|
963
|
-
'[testing-env/0] acquired -> setting_up',
|
|
964
|
-
'[testing-env/0/session1] shell: "feature1" setup session',
|
|
965
|
-
'[testing-env/0/feature1] feature setup session',
|
|
966
|
-
'[testing-env/0/session1] shell: "feature2" setup session',
|
|
967
|
-
'[testing-env/0/feature2] feature setup session',
|
|
968
|
-
'[testing-env/0] setting_up -> in_session',
|
|
969
|
-
"[testing-env/0] session 'session1' started",
|
|
970
|
-
'[testing-env/0/session1] shell: echo "hello"',
|
|
971
|
-
'[testing-env/0] in_session -> exiting_session',
|
|
972
|
-
'[testing-env/0/session1] shell: "feature1" teardown session',
|
|
973
|
-
'[testing-env/0/feature1] feature teardown session',
|
|
974
|
-
'[testing-env/0/session1] shell: "feature2" teardown session',
|
|
975
|
-
'[testing-env/0/feature2] feature teardown session',
|
|
976
|
-
"[testing-env/0] session 'session1' ended",
|
|
977
|
-
'[testing-env/0] exiting_session -> acquired',
|
|
978
|
-
'[testing-env/0] acquired -> shutting_down',
|
|
979
|
-
'[testing-env/0] shell: "feature1" teardown',
|
|
980
|
-
'[testing-env/0/feature1] feature teardown',
|
|
981
|
-
'[testing-env/0] shell: "feature2" teardown',
|
|
982
|
-
'[testing-env/0/feature2] feature teardown',
|
|
983
|
-
'[testing-env/0] shutting_down -> offline',
|
|
984
|
-
'[testing-env/0] sandbox shutdown'
|
|
1167
|
+
'[testing-env/test_image:0] shell: "feature1" setup',
|
|
1168
|
+
'[testing-env/test_image:0/feature1] feature setup',
|
|
1169
|
+
'[testing-env/test_image:0] shell: "feature2" setup',
|
|
1170
|
+
'[testing-env/test_image:0/feature2] feature setup',
|
|
1171
|
+
'[testing-env/test_image:0] created -> ready',
|
|
1172
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1173
|
+
'[testing-env/test_image:0] ready -> acquired',
|
|
1174
|
+
'[testing-env/test_image:0] acquired -> setting_up',
|
|
1175
|
+
'[testing-env/test_image:0/session1] shell: "feature1" setup session',
|
|
1176
|
+
'[testing-env/test_image:0/feature1] feature setup session',
|
|
1177
|
+
'[testing-env/test_image:0/session1] shell: "feature2" setup session',
|
|
1178
|
+
'[testing-env/test_image:0/feature2] feature setup session',
|
|
1179
|
+
'[testing-env/test_image:0] setting_up -> in_session',
|
|
1180
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1181
|
+
'[testing-env/test_image:0/session1] shell: echo "hello"',
|
|
1182
|
+
'[testing-env/test_image:0] in_session -> exiting_session',
|
|
1183
|
+
'[testing-env/test_image:0/session1] shell: "feature1" teardown session',
|
|
1184
|
+
'[testing-env/test_image:0/feature1] feature teardown session',
|
|
1185
|
+
'[testing-env/test_image:0/session1] shell: "feature2" teardown session',
|
|
1186
|
+
'[testing-env/test_image:0/feature2] feature teardown session',
|
|
1187
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
1188
|
+
'[testing-env/test_image:0] exiting_session -> acquired',
|
|
1189
|
+
'[testing-env/test_image:0] acquired -> shutting_down',
|
|
1190
|
+
'[testing-env/test_image:0] shell: "feature1" teardown',
|
|
1191
|
+
'[testing-env/test_image:0/feature1] feature teardown',
|
|
1192
|
+
'[testing-env/test_image:0] shell: "feature2" teardown',
|
|
1193
|
+
'[testing-env/test_image:0/feature2] feature teardown',
|
|
1194
|
+
'[testing-env/test_image:0] shutting_down -> offline',
|
|
1195
|
+
'[testing-env/test_image:0] sandbox shutdown'
|
|
1196
|
+
# pylint: enable=line-too-long
|
|
985
1197
|
]
|
|
986
1198
|
)
|
|
987
1199
|
|
|
@@ -993,7 +1205,7 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
993
1205
|
},
|
|
994
1206
|
)
|
|
995
1207
|
with env:
|
|
996
|
-
with env.sandbox('session1') as sb:
|
|
1208
|
+
with env.sandbox(session_id='session1') as sb:
|
|
997
1209
|
with self.assertRaises(ValueError):
|
|
998
1210
|
sb.shell('echo foo', raise_error=ValueError)
|
|
999
1211
|
self.assertEqual(len(sb.state_errors), 0)
|
|
@@ -1004,27 +1216,29 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
1004
1216
|
self.assertEqual(
|
|
1005
1217
|
self.event_handler.logs,
|
|
1006
1218
|
[
|
|
1007
|
-
|
|
1008
|
-
'[testing-env/0:0
|
|
1009
|
-
'[testing-env/0:0]
|
|
1010
|
-
'[testing-env/0:0
|
|
1011
|
-
'[testing-env/0:0]
|
|
1012
|
-
'[testing-env/0:0]
|
|
1219
|
+
# pylint: disable=line-too-long
|
|
1220
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup',
|
|
1221
|
+
'[testing-env/test_image:0:0/feature1] feature setup',
|
|
1222
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup session',
|
|
1223
|
+
'[testing-env/test_image:0:0/feature1] feature setup session',
|
|
1224
|
+
'[testing-env/test_image:0:0] created -> ready',
|
|
1225
|
+
'[testing-env/test_image:0:0] sandbox started',
|
|
1013
1226
|
'[testing-env] environment started',
|
|
1014
|
-
'[testing-env/0:0] ready -> acquired',
|
|
1015
|
-
'[testing-env/0:0] acquired -> setting_up',
|
|
1016
|
-
'[testing-env/0:0] setting_up -> in_session',
|
|
1017
|
-
"[testing-env/0:0] session 'session1' started",
|
|
1018
|
-
'[testing-env/0:0/session1] shell: echo foo with ValueError',
|
|
1019
|
-
'[testing-env/0:0/session1] shell: echo bar',
|
|
1020
|
-
'[testing-env/0:0] in_session -> exiting_session',
|
|
1021
|
-
'[testing-env/0:0/session1] shell: "feature1" teardown session',
|
|
1022
|
-
'[testing-env/0:0/feature1] feature teardown session',
|
|
1023
|
-
"[testing-env/0:0] session 'session1' ended",
|
|
1024
|
-
'[testing-env/0:0] exiting_session -> setting_up',
|
|
1025
|
-
'[testing-env/0:0] shell: "feature1" setup session',
|
|
1026
|
-
'[testing-env/0:0/feature1] feature setup session',
|
|
1027
|
-
'[testing-env/0:0] setting_up -> ready',
|
|
1227
|
+
'[testing-env/test_image:0:0] ready -> acquired',
|
|
1228
|
+
'[testing-env/test_image:0:0] acquired -> setting_up',
|
|
1229
|
+
'[testing-env/test_image:0:0] setting_up -> in_session',
|
|
1230
|
+
"[testing-env/test_image:0:0] session 'session1' started",
|
|
1231
|
+
'[testing-env/test_image:0:0/session1] shell: echo foo with ValueError',
|
|
1232
|
+
'[testing-env/test_image:0:0/session1] shell: echo bar',
|
|
1233
|
+
'[testing-env/test_image:0:0] in_session -> exiting_session',
|
|
1234
|
+
'[testing-env/test_image:0:0/session1] shell: "feature1" teardown session',
|
|
1235
|
+
'[testing-env/test_image:0:0/feature1] feature teardown session',
|
|
1236
|
+
"[testing-env/test_image:0:0] session 'session1' ended",
|
|
1237
|
+
'[testing-env/test_image:0:0] exiting_session -> setting_up',
|
|
1238
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup session',
|
|
1239
|
+
'[testing-env/test_image:0:0/feature1] feature setup session',
|
|
1240
|
+
'[testing-env/test_image:0:0] setting_up -> ready',
|
|
1241
|
+
# pylint: enable=line-too-long
|
|
1028
1242
|
]
|
|
1029
1243
|
)
|
|
1030
1244
|
|
|
@@ -1036,39 +1250,37 @@ class SandboxStatusTests(unittest.TestCase):
|
|
|
1036
1250
|
},
|
|
1037
1251
|
)
|
|
1038
1252
|
with env:
|
|
1039
|
-
with
|
|
1040
|
-
with
|
|
1253
|
+
with self.assertRaises(interface.SandboxStateError):
|
|
1254
|
+
with env.sandbox(session_id='session1') as sb:
|
|
1041
1255
|
sb.shell('echo foo', raise_error=RuntimeError)
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
sb.shell('echo bar')
|
|
1256
|
+
self.assertEqual(len(sb.state_errors), 1)
|
|
1257
|
+
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
1045
1258
|
self.assertEqual(
|
|
1046
1259
|
self.event_handler.logs,
|
|
1047
1260
|
[
|
|
1048
1261
|
# pylint: disable=line-too-long
|
|
1049
|
-
'[testing-env/0:0] shell: "feature1" setup',
|
|
1050
|
-
'[testing-env/0:0/feature1] feature setup',
|
|
1051
|
-
'[testing-env/0:0] shell: "feature1" setup session',
|
|
1052
|
-
'[testing-env/0:0/feature1] feature setup session',
|
|
1053
|
-
'[testing-env/0:0] created -> ready',
|
|
1054
|
-
'[testing-env/0:0] sandbox started',
|
|
1262
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup',
|
|
1263
|
+
'[testing-env/test_image:0:0/feature1] feature setup',
|
|
1264
|
+
'[testing-env/test_image:0:0] shell: "feature1" setup session',
|
|
1265
|
+
'[testing-env/test_image:0:0/feature1] feature setup session',
|
|
1266
|
+
'[testing-env/test_image:0:0] created -> ready',
|
|
1267
|
+
'[testing-env/test_image:0:0] sandbox started',
|
|
1055
1268
|
'[testing-env] environment started',
|
|
1056
|
-
'[testing-env/0:0] ready -> acquired',
|
|
1057
|
-
'[testing-env/0:0] acquired -> setting_up',
|
|
1058
|
-
'[testing-env/0:0] setting_up -> in_session',
|
|
1059
|
-
"[testing-env/0:0] session 'session1' started",
|
|
1060
|
-
'[testing-env/0:0/session1] shell: echo foo with RuntimeError',
|
|
1061
|
-
'[testing-env/0:0] in_session -> exiting_session',
|
|
1062
|
-
'[testing-env/0:0/session1] shell: "feature1" teardown session',
|
|
1063
|
-
'[testing-env/0:0/feature1] feature teardown session',
|
|
1064
|
-
"[testing-env/0:0] session 'session1' ended with SandboxStateError",
|
|
1065
|
-
'[testing-env/0:0] exiting_session -> acquired',
|
|
1066
|
-
'[testing-env/0:0] acquired -> shutting_down',
|
|
1067
|
-
'[testing-env/0:0] shell: "feature1" teardown',
|
|
1068
|
-
'[testing-env/0:0/feature1] feature teardown',
|
|
1069
|
-
'[testing-env/0:0] shutting_down -> offline',
|
|
1070
|
-
'[testing-env/0:0] sandbox shutdown',
|
|
1071
|
-
'[testing-env/0:0] shell: echo bar',
|
|
1269
|
+
'[testing-env/test_image:0:0] ready -> acquired',
|
|
1270
|
+
'[testing-env/test_image:0:0] acquired -> setting_up',
|
|
1271
|
+
'[testing-env/test_image:0:0] setting_up -> in_session',
|
|
1272
|
+
"[testing-env/test_image:0:0] session 'session1' started",
|
|
1273
|
+
'[testing-env/test_image:0:0/session1] shell: echo foo with RuntimeError',
|
|
1274
|
+
'[testing-env/test_image:0:0] in_session -> exiting_session',
|
|
1275
|
+
'[testing-env/test_image:0:0/session1] shell: "feature1" teardown session',
|
|
1276
|
+
'[testing-env/test_image:0:0/feature1] feature teardown session',
|
|
1277
|
+
"[testing-env/test_image:0:0] session 'session1' ended with SandboxStateError",
|
|
1278
|
+
'[testing-env/test_image:0:0] exiting_session -> acquired',
|
|
1279
|
+
'[testing-env/test_image:0:0] acquired -> shutting_down',
|
|
1280
|
+
'[testing-env/test_image:0:0] shell: "feature1" teardown',
|
|
1281
|
+
'[testing-env/test_image:0:0/feature1] feature teardown',
|
|
1282
|
+
'[testing-env/test_image:0:0] shutting_down -> offline',
|
|
1283
|
+
'[testing-env/test_image:0:0] sandbox shutdown',
|
|
1072
1284
|
# pylint: enable=line-too-long
|
|
1073
1285
|
]
|
|
1074
1286
|
)
|
|
@@ -1085,19 +1297,12 @@ class SandboxActivityTests(unittest.TestCase):
|
|
|
1085
1297
|
with env.sandbox() as sb:
|
|
1086
1298
|
self.assertRegex(sb.session_id, r'session-[0-9a-f]{7}')
|
|
1087
1299
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
r'session-[0-9a-f]{7}'
|
|
1095
|
-
)
|
|
1096
|
-
|
|
1097
|
-
with self.assertRaisesRegex(ValueError, '`session_id` should not be used'):
|
|
1098
|
-
@base_sandbox.sandbox_service()
|
|
1099
|
-
def foo(session_id: str):
|
|
1100
|
-
del session_id
|
|
1300
|
+
with env.test_feature() as test_feature:
|
|
1301
|
+
self.assertIsInstance(test_feature, TestingFeature)
|
|
1302
|
+
self.assertRegex(
|
|
1303
|
+
test_feature.session_id,
|
|
1304
|
+
r'test_feature-session-[0-9a-f]{7}'
|
|
1305
|
+
)
|
|
1101
1306
|
|
|
1102
1307
|
def test_ping_error(self):
|
|
1103
1308
|
env = TestingEnvironment(
|
|
@@ -1106,13 +1311,13 @@ class SandboxActivityTests(unittest.TestCase):
|
|
|
1106
1311
|
sandbox_keepalive_interval=0,
|
|
1107
1312
|
)
|
|
1108
1313
|
with env:
|
|
1109
|
-
with env.sandbox('session1') as sb:
|
|
1314
|
+
with env.sandbox(session_id='session1') as sb:
|
|
1110
1315
|
sb.rebind(
|
|
1111
1316
|
simulate_ping_error=interface.SandboxStateError,
|
|
1112
1317
|
skip_notification=True
|
|
1113
1318
|
)
|
|
1114
1319
|
sb.wait_until_next_housekeep()
|
|
1115
|
-
self.
|
|
1320
|
+
self.assertIn(sb.status, (sb.Status.SHUTTING_DOWN, sb.Status.OFFLINE))
|
|
1116
1321
|
|
|
1117
1322
|
def test_housekeep_error(self):
|
|
1118
1323
|
event_handler = TestingEventHandler(log_housekeep=False)
|
|
@@ -1126,7 +1331,7 @@ class SandboxActivityTests(unittest.TestCase):
|
|
|
1126
1331
|
event_handlers=[event_handler],
|
|
1127
1332
|
)
|
|
1128
1333
|
with env:
|
|
1129
|
-
with env.sandbox('session1') as sb:
|
|
1334
|
+
with env.sandbox(session_id='session1') as sb:
|
|
1130
1335
|
self.assertEqual(len(env.sandbox_pool), 1)
|
|
1131
1336
|
self.assertEqual(sb.status, interface.Sandbox.Status.IN_SESSION)
|
|
1132
1337
|
self.assertEqual(sb.session_id, 'session1')
|
|
@@ -1139,30 +1344,33 @@ class SandboxActivityTests(unittest.TestCase):
|
|
|
1139
1344
|
sb.status == interface.Sandbox.Status.IN_SESSION
|
|
1140
1345
|
):
|
|
1141
1346
|
time.sleep(0.01)
|
|
1347
|
+
time.sleep(1.0)
|
|
1142
1348
|
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
1143
1349
|
env.wait_for_housekeeping()
|
|
1144
1350
|
self.assertEqual(
|
|
1145
1351
|
event_handler.logs,
|
|
1146
1352
|
[
|
|
1147
|
-
|
|
1148
|
-
'[testing-env/0:0
|
|
1149
|
-
'[testing-env/0:0]
|
|
1150
|
-
'[testing-env/0:0]
|
|
1353
|
+
# pylint: disable=line-too-long
|
|
1354
|
+
'[testing-env/test_image:0:0] shell: "test_feature" setup',
|
|
1355
|
+
'[testing-env/test_image:0:0/test_feature] feature setup',
|
|
1356
|
+
'[testing-env/test_image:0:0] shell: "test_feature" setup session',
|
|
1357
|
+
'[testing-env/test_image:0:0] sandbox started',
|
|
1151
1358
|
'[testing-env] environment started',
|
|
1152
|
-
"[testing-env/0:0] session 'session1' started",
|
|
1153
|
-
'[testing-env/0:0/session1] shell: "test_feature" teardown session',
|
|
1154
|
-
"[testing-env/0:0] session 'session1' ended with SandboxStateError",
|
|
1155
|
-
'[testing-env/0:0] shell: "test_feature" teardown',
|
|
1156
|
-
'[testing-env/0:0/test_feature] feature teardown',
|
|
1157
|
-
'[testing-env/0:0] sandbox shutdown',
|
|
1158
|
-
'[testing-env/0:1] shell: "test_feature" setup',
|
|
1159
|
-
'[testing-env/0:1/test_feature] feature setup',
|
|
1160
|
-
'[testing-env/0:1] shell: "test_feature" setup session',
|
|
1161
|
-
'[testing-env/0:1] sandbox started',
|
|
1162
|
-
'[testing-env/0:1] shell: "test_feature" teardown',
|
|
1163
|
-
'[testing-env/0:1/test_feature] feature teardown',
|
|
1164
|
-
'[testing-env/0:1] sandbox shutdown',
|
|
1359
|
+
"[testing-env/test_image:0:0] session 'session1' started",
|
|
1360
|
+
'[testing-env/test_image:0:0/session1] shell: "test_feature" teardown session',
|
|
1361
|
+
"[testing-env/test_image:0:0] session 'session1' ended with SandboxStateError",
|
|
1362
|
+
'[testing-env/test_image:0:0] shell: "test_feature" teardown',
|
|
1363
|
+
'[testing-env/test_image:0:0/test_feature] feature teardown',
|
|
1364
|
+
'[testing-env/test_image:0:0] sandbox shutdown',
|
|
1365
|
+
'[testing-env/test_image:0:1] shell: "test_feature" setup',
|
|
1366
|
+
'[testing-env/test_image:0:1/test_feature] feature setup',
|
|
1367
|
+
'[testing-env/test_image:0:1] shell: "test_feature" setup session',
|
|
1368
|
+
'[testing-env/test_image:0:1] sandbox started',
|
|
1369
|
+
'[testing-env/test_image:0:1] shell: "test_feature" teardown',
|
|
1370
|
+
'[testing-env/test_image:0:1/test_feature] feature teardown',
|
|
1371
|
+
'[testing-env/test_image:0:1] sandbox shutdown',
|
|
1165
1372
|
'[testing-env] environment shutdown'
|
|
1373
|
+
# pylint: enable=line-too-long
|
|
1166
1374
|
]
|
|
1167
1375
|
)
|
|
1168
1376
|
|
|
@@ -1176,14 +1384,14 @@ class SandboxActivityTests(unittest.TestCase):
|
|
|
1176
1384
|
)
|
|
1177
1385
|
event_handler = TestingEventHandler()
|
|
1178
1386
|
with env:
|
|
1179
|
-
with env.sandbox('session1') as sb:
|
|
1387
|
+
with env.sandbox(session_id='session1') as sb:
|
|
1180
1388
|
sb.add_event_handler(event_handler)
|
|
1181
1389
|
sb.shell('test_feature')
|
|
1182
1390
|
sb.remove_event_handler(event_handler)
|
|
1183
1391
|
events = list(event_handler.logs)
|
|
1184
1392
|
sb.wait_until_not(interface.Sandbox.Status.SETTING_UP)
|
|
1185
1393
|
self.assertGreater(len(events), 0)
|
|
1186
|
-
with env.sandbox('session2') as sb:
|
|
1394
|
+
with env.sandbox(session_id='session2') as sb:
|
|
1187
1395
|
sb.shell('test_feature')
|
|
1188
1396
|
self.assertEqual(len(events), len(event_handler.logs))
|
|
1189
1397
|
|
|
@@ -1230,9 +1438,8 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1230
1438
|
event_handlers=[event_handler],
|
|
1231
1439
|
)
|
|
1232
1440
|
with env:
|
|
1233
|
-
env.test_feature
|
|
1234
|
-
|
|
1235
|
-
)
|
|
1441
|
+
with env.test_feature(session_id='session1') as test_feature:
|
|
1442
|
+
test_feature.call_with_varargs('sum', 1, 2, debug=True)
|
|
1236
1443
|
self.assertEqual(
|
|
1237
1444
|
event_handler.calls,
|
|
1238
1445
|
[
|
|
@@ -1246,7 +1453,7 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1246
1453
|
|
|
1247
1454
|
def test_service_call_from_feature(self):
|
|
1248
1455
|
with self.env:
|
|
1249
|
-
with self.env.sandbox('session1') as sb:
|
|
1456
|
+
with self.env.sandbox(session_id='session1') as sb:
|
|
1250
1457
|
self.assertEqual(sb.test_feature.num_shell_calls(), 2)
|
|
1251
1458
|
self.assertEqual(sb.test_feature.num_shell_calls(), 2)
|
|
1252
1459
|
self.assertEqual(
|
|
@@ -1254,18 +1461,18 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1254
1461
|
[
|
|
1255
1462
|
# pylint: disable=line-too-long
|
|
1256
1463
|
'[testing-env] environment started',
|
|
1257
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1258
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1259
|
-
'[testing-env/0] sandbox started',
|
|
1260
|
-
'[testing-env/0/session1] shell: "test_feature" setup session',
|
|
1261
|
-
"[testing-env/0] session 'session1' started",
|
|
1262
|
-
'[testing-env/0/session1/test_feature] test_feature.num_shell_calls: None',
|
|
1263
|
-
'[testing-env/0/session1/test_feature] test_feature.num_shell_calls: None',
|
|
1264
|
-
'[testing-env/0/session1] shell: "test_feature" teardown session',
|
|
1265
|
-
"[testing-env/0] session 'session1' ended",
|
|
1266
|
-
'[testing-env/0] shell: "test_feature" teardown',
|
|
1267
|
-
'[testing-env/0/test_feature] feature teardown',
|
|
1268
|
-
'[testing-env/0] sandbox shutdown',
|
|
1464
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1465
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1466
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1467
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" setup session',
|
|
1468
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1469
|
+
'[testing-env/test_image:0/session1/test_feature] test_feature.num_shell_calls: None',
|
|
1470
|
+
'[testing-env/test_image:0/session1/test_feature] test_feature.num_shell_calls: None',
|
|
1471
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" teardown session',
|
|
1472
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
1473
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1474
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1475
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1269
1476
|
'[testing-env] environment shutdown'
|
|
1270
1477
|
# pylint: enable=line-too-long
|
|
1271
1478
|
]
|
|
@@ -1273,28 +1480,29 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1273
1480
|
|
|
1274
1481
|
def test_service_call_from_feature_with_error(self):
|
|
1275
1482
|
with self.env:
|
|
1276
|
-
with self.
|
|
1277
|
-
with self.
|
|
1483
|
+
with self.assertRaises(interface.SandboxStateError):
|
|
1484
|
+
with self.env.sandbox(session_id='session1') as sb:
|
|
1278
1485
|
sb.test_feature.bad_shell_call()
|
|
1279
|
-
|
|
1486
|
+
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
1487
|
+
self.assertEqual(len(sb.state_errors), 1)
|
|
1280
1488
|
|
|
1281
1489
|
self.assertEqual(
|
|
1282
1490
|
self.event_handler.logs,
|
|
1283
1491
|
[
|
|
1284
1492
|
# pylint: disable=line-too-long
|
|
1285
1493
|
'[testing-env] environment started',
|
|
1286
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1287
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1288
|
-
'[testing-env/0] sandbox started',
|
|
1289
|
-
'[testing-env/0/session1] shell: "test_feature" setup session',
|
|
1290
|
-
"[testing-env/0] session 'session1' started",
|
|
1291
|
-
'[testing-env/0/session1] shell: bad command with RuntimeError',
|
|
1292
|
-
'[testing-env/0/session1/test_feature] test_feature.bad_shell_call: None with SandboxStateError',
|
|
1293
|
-
'[testing-env/0/session1] shell: "test_feature" teardown session',
|
|
1294
|
-
"[testing-env/0] session 'session1' ended with SandboxStateError",
|
|
1295
|
-
'[testing-env/0] shell: "test_feature" teardown',
|
|
1296
|
-
'[testing-env/0/test_feature] feature teardown',
|
|
1297
|
-
'[testing-env/0] sandbox shutdown',
|
|
1494
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1495
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1496
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1497
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" setup session',
|
|
1498
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1499
|
+
'[testing-env/test_image:0/session1] shell: bad command with RuntimeError',
|
|
1500
|
+
'[testing-env/test_image:0/session1/test_feature] test_feature.bad_shell_call: None with SandboxStateError',
|
|
1501
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" teardown session',
|
|
1502
|
+
"[testing-env/test_image:0] session 'session1' ended with SandboxStateError",
|
|
1503
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1504
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1505
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1298
1506
|
'[testing-env] environment shutdown'
|
|
1299
1507
|
# pylint: enable=line-too-long
|
|
1300
1508
|
]
|
|
@@ -1302,23 +1510,24 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1302
1510
|
|
|
1303
1511
|
def test_service_call_from_environment(self):
|
|
1304
1512
|
with self.env:
|
|
1305
|
-
self.
|
|
1513
|
+
with self.env.test_feature() as test_feature:
|
|
1514
|
+
self.assertEqual(test_feature.num_shell_calls(), 2)
|
|
1306
1515
|
self.assertEqual(
|
|
1307
1516
|
self.event_handler.logs,
|
|
1308
1517
|
[
|
|
1309
1518
|
# pylint: disable=line-too-long
|
|
1310
1519
|
'[testing-env] environment started',
|
|
1311
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1312
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1313
|
-
'[testing-env/0] sandbox started',
|
|
1314
|
-
'[testing-env/0/session-2291d8c] shell: "test_feature" setup session',
|
|
1315
|
-
"[testing-env/0] session 'session-2291d8c' started",
|
|
1316
|
-
'[testing-env/0/session-2291d8c/test_feature] test_feature.num_shell_calls: None',
|
|
1317
|
-
'[testing-env/0/session-2291d8c] shell: "test_feature" teardown session',
|
|
1318
|
-
"[testing-env/0] session 'session-2291d8c' ended",
|
|
1319
|
-
'[testing-env/0] shell: "test_feature" teardown',
|
|
1320
|
-
'[testing-env/0/test_feature] feature teardown',
|
|
1321
|
-
'[testing-env/0] sandbox shutdown',
|
|
1520
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1521
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1522
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1523
|
+
'[testing-env/test_image:0/test_feature-session-2291d8c] shell: "test_feature" setup session',
|
|
1524
|
+
"[testing-env/test_image:0] session 'test_feature-session-2291d8c' started",
|
|
1525
|
+
'[testing-env/test_image:0/test_feature-session-2291d8c/test_feature] test_feature.num_shell_calls: None',
|
|
1526
|
+
'[testing-env/test_image:0/test_feature-session-2291d8c] shell: "test_feature" teardown session',
|
|
1527
|
+
"[testing-env/test_image:0] session 'test_feature-session-2291d8c' ended",
|
|
1528
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1529
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1530
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1322
1531
|
'[testing-env] environment shutdown'
|
|
1323
1532
|
# pylint: enable=line-too-long
|
|
1324
1533
|
]
|
|
@@ -1327,24 +1536,25 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1327
1536
|
def test_service_call_from_environment_with_error(self):
|
|
1328
1537
|
with self.env:
|
|
1329
1538
|
with self.assertRaises(interface.SandboxStateError):
|
|
1330
|
-
self.env.test_feature
|
|
1539
|
+
with self.env.test_feature(session_id='session1') as test_feature:
|
|
1540
|
+
test_feature.bad_shell_call()
|
|
1331
1541
|
self.assertEqual(
|
|
1332
1542
|
self.event_handler.logs,
|
|
1333
1543
|
[
|
|
1334
1544
|
# pylint: disable=line-too-long
|
|
1335
1545
|
'[testing-env] environment started',
|
|
1336
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1337
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1338
|
-
'[testing-env/0] sandbox started',
|
|
1339
|
-
'[testing-env/0/session1] shell: "test_feature" setup session',
|
|
1340
|
-
"[testing-env/0] session 'session1' started",
|
|
1341
|
-
'[testing-env/0/session1] shell: bad command with RuntimeError',
|
|
1342
|
-
'[testing-env/0/session1/test_feature] test_feature.bad_shell_call: None with SandboxStateError',
|
|
1343
|
-
'[testing-env/0/session1] shell: "test_feature" teardown session',
|
|
1344
|
-
"[testing-env/0] session 'session1' ended with SandboxStateError",
|
|
1345
|
-
'[testing-env/0] shell: "test_feature" teardown',
|
|
1346
|
-
'[testing-env/0/test_feature] feature teardown',
|
|
1347
|
-
'[testing-env/0] sandbox shutdown',
|
|
1546
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1547
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1548
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1549
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" setup session',
|
|
1550
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1551
|
+
'[testing-env/test_image:0/session1] shell: bad command with RuntimeError',
|
|
1552
|
+
'[testing-env/test_image:0/session1/test_feature] test_feature.bad_shell_call: None with SandboxStateError',
|
|
1553
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" teardown session',
|
|
1554
|
+
"[testing-env/test_image:0] session 'session1' ended with SandboxStateError",
|
|
1555
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1556
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1557
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1348
1558
|
'[testing-env] environment shutdown'
|
|
1349
1559
|
# pylint: enable=line-too-long
|
|
1350
1560
|
]
|
|
@@ -1352,7 +1562,7 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1352
1562
|
|
|
1353
1563
|
def test_service_context_manager_from_feature(self):
|
|
1354
1564
|
with self.env:
|
|
1355
|
-
with self.env.sandbox('session1') as sb:
|
|
1565
|
+
with self.env.sandbox(session_id='session1') as sb:
|
|
1356
1566
|
with sb.test_feature.my_service() as service:
|
|
1357
1567
|
service.do('hello')
|
|
1358
1568
|
sb.shell('foo')
|
|
@@ -1362,19 +1572,18 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1362
1572
|
[
|
|
1363
1573
|
# pylint: disable=line-too-long
|
|
1364
1574
|
'[testing-env] environment started',
|
|
1365
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1366
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1367
|
-
'[testing-env/0] sandbox started',
|
|
1368
|
-
'[testing-env/0/session1] shell: "test_feature" setup session',
|
|
1369
|
-
"[testing-env/0] session 'session1' started",
|
|
1370
|
-
'[testing-env/0/session1] shell: hello',
|
|
1371
|
-
'[testing-env/0/session1
|
|
1372
|
-
'[testing-env/0/session1] shell:
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
'[testing-env/0]
|
|
1376
|
-
'[testing-env/0
|
|
1377
|
-
'[testing-env/0] sandbox shutdown',
|
|
1575
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1576
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1577
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1578
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" setup session',
|
|
1579
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1580
|
+
'[testing-env/test_image:0/session1] shell: hello',
|
|
1581
|
+
'[testing-env/test_image:0/session1] shell: foo',
|
|
1582
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" teardown session',
|
|
1583
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
1584
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1585
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1586
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1378
1587
|
'[testing-env] environment shutdown'
|
|
1379
1588
|
# pylint: enable=line-too-long
|
|
1380
1589
|
]
|
|
@@ -1382,28 +1591,28 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1382
1591
|
|
|
1383
1592
|
def test_service_context_manager_from_feature_with_error(self):
|
|
1384
1593
|
with self.env:
|
|
1385
|
-
with self.
|
|
1386
|
-
with self.
|
|
1594
|
+
with self.assertRaises(interface.SandboxStateError):
|
|
1595
|
+
with self.env.sandbox(session_id='session1') as sb:
|
|
1387
1596
|
with sb.test_feature.my_service() as service:
|
|
1388
1597
|
service.do('hello', raise_error=interface.SandboxStateError)
|
|
1389
|
-
|
|
1598
|
+
self.assertEqual(sb.status, interface.Sandbox.Status.OFFLINE)
|
|
1599
|
+
self.assertEqual(len(sb.state_errors), 1)
|
|
1390
1600
|
self.assertEqual(
|
|
1391
1601
|
self.event_handler.logs,
|
|
1392
1602
|
[
|
|
1393
1603
|
# pylint: disable=line-too-long
|
|
1394
1604
|
'[testing-env] environment started',
|
|
1395
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1396
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1397
|
-
'[testing-env/0] sandbox started',
|
|
1398
|
-
'[testing-env/0/session1] shell: "test_feature" setup session',
|
|
1399
|
-
"[testing-env/0] session 'session1' started",
|
|
1400
|
-
'[testing-env/0/session1] shell: hello with SandboxStateError',
|
|
1401
|
-
'[testing-env/0/session1
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
'[testing-env/0]
|
|
1405
|
-
'[testing-env/0
|
|
1406
|
-
'[testing-env/0] sandbox shutdown',
|
|
1605
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1606
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1607
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1608
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" setup session',
|
|
1609
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1610
|
+
'[testing-env/test_image:0/session1] shell: hello with SandboxStateError',
|
|
1611
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" teardown session',
|
|
1612
|
+
"[testing-env/test_image:0] session 'session1' ended with SandboxStateError",
|
|
1613
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1614
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1615
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1407
1616
|
'[testing-env] environment shutdown'
|
|
1408
1617
|
# pylint: enable=line-too-long
|
|
1409
1618
|
]
|
|
@@ -1411,39 +1620,40 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1411
1620
|
|
|
1412
1621
|
def test_service_context_manager_from_environment(self):
|
|
1413
1622
|
with self.env:
|
|
1414
|
-
with self.env.test_feature
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1623
|
+
with self.env.test_feature(session_id='session1') as test_feature:
|
|
1624
|
+
with test_feature.my_service() as service:
|
|
1625
|
+
service.do('foo')
|
|
1626
|
+
|
|
1627
|
+
with self.env.test_feature() as test_feature:
|
|
1628
|
+
with test_feature.my_service() as service:
|
|
1629
|
+
service.do('bar')
|
|
1418
1630
|
self.assertEqual(
|
|
1419
1631
|
self.event_handler.logs,
|
|
1420
1632
|
[
|
|
1421
1633
|
# pylint: disable=line-too-long
|
|
1422
1634
|
'[testing-env] environment started',
|
|
1423
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1424
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1425
|
-
'[testing-env/0] sandbox started',
|
|
1426
|
-
'[testing-env/0/session1] shell: "test_feature" setup session',
|
|
1427
|
-
"[testing-env/0] session 'session1' started",
|
|
1428
|
-
'[testing-env/0/session1] shell: foo',
|
|
1429
|
-
'[testing-env/0/session1
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
'[testing-env/0]
|
|
1433
|
-
'[testing-env/0
|
|
1434
|
-
'[testing-env/
|
|
1435
|
-
'[testing-env/1]
|
|
1436
|
-
'[testing-env/1
|
|
1437
|
-
'[testing-env/1]
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
'[testing-env/1/session-2291d8c] shell:
|
|
1441
|
-
|
|
1442
|
-
'[testing-env/1
|
|
1443
|
-
|
|
1444
|
-
'[testing-env/1]
|
|
1445
|
-
'[testing-env/1/test_feature] feature teardown',
|
|
1446
|
-
'[testing-env/1] sandbox shutdown',
|
|
1635
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1636
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1637
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1638
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" setup session',
|
|
1639
|
+
"[testing-env/test_image:0] session 'session1' started",
|
|
1640
|
+
'[testing-env/test_image:0/session1] shell: foo',
|
|
1641
|
+
'[testing-env/test_image:0/session1] shell: "test_feature" teardown session',
|
|
1642
|
+
"[testing-env/test_image:0] session 'session1' ended",
|
|
1643
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1644
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1645
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1646
|
+
'[testing-env/test_image:1] shell: "test_feature" setup',
|
|
1647
|
+
'[testing-env/test_image:1/test_feature] feature setup',
|
|
1648
|
+
'[testing-env/test_image:1] sandbox started',
|
|
1649
|
+
'[testing-env/test_image:1/test_feature-session-2291d8c] shell: "test_feature" setup session',
|
|
1650
|
+
"[testing-env/test_image:1] session 'test_feature-session-2291d8c' started",
|
|
1651
|
+
'[testing-env/test_image:1/test_feature-session-2291d8c] shell: bar',
|
|
1652
|
+
'[testing-env/test_image:1/test_feature-session-2291d8c] shell: "test_feature" teardown session',
|
|
1653
|
+
"[testing-env/test_image:1] session 'test_feature-session-2291d8c' ended",
|
|
1654
|
+
'[testing-env/test_image:1] shell: "test_feature" teardown',
|
|
1655
|
+
'[testing-env/test_image:1/test_feature] feature teardown',
|
|
1656
|
+
'[testing-env/test_image:1] sandbox shutdown',
|
|
1447
1657
|
'[testing-env] environment shutdown'
|
|
1448
1658
|
# pylint: enable=line-too-long
|
|
1449
1659
|
]
|
|
@@ -1452,25 +1662,25 @@ class SandboxServiceTests(unittest.TestCase):
|
|
|
1452
1662
|
def test_service_context_manager_from_environment_with_error(self):
|
|
1453
1663
|
with self.env:
|
|
1454
1664
|
with self.assertRaises(interface.SandboxStateError):
|
|
1455
|
-
with self.env.test_feature
|
|
1456
|
-
|
|
1665
|
+
with self.env.test_feature() as test_feature:
|
|
1666
|
+
with test_feature.my_service() as service:
|
|
1667
|
+
service.do('hello', raise_error=interface.SandboxStateError)
|
|
1457
1668
|
self.assertEqual(
|
|
1458
1669
|
self.event_handler.logs,
|
|
1459
1670
|
[
|
|
1460
1671
|
# pylint: disable=line-too-long
|
|
1461
1672
|
'[testing-env] environment started',
|
|
1462
|
-
'[testing-env/0] shell: "test_feature" setup',
|
|
1463
|
-
'[testing-env/0/test_feature] feature setup',
|
|
1464
|
-
'[testing-env/0] sandbox started',
|
|
1465
|
-
'[testing-env/0/session-2291d8c] shell: "test_feature" setup session',
|
|
1466
|
-
"[testing-env/0] session 'session-2291d8c' started",
|
|
1467
|
-
'[testing-env/0/session-2291d8c] shell: hello with SandboxStateError',
|
|
1468
|
-
'[testing-env/0/session-2291d8c
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
'[testing-env/0]
|
|
1472
|
-
'[testing-env/0
|
|
1473
|
-
'[testing-env/0] sandbox shutdown',
|
|
1673
|
+
'[testing-env/test_image:0] shell: "test_feature" setup',
|
|
1674
|
+
'[testing-env/test_image:0/test_feature] feature setup',
|
|
1675
|
+
'[testing-env/test_image:0] sandbox started',
|
|
1676
|
+
'[testing-env/test_image:0/test_feature-session-2291d8c] shell: "test_feature" setup session',
|
|
1677
|
+
"[testing-env/test_image:0] session 'test_feature-session-2291d8c' started",
|
|
1678
|
+
'[testing-env/test_image:0/test_feature-session-2291d8c] shell: hello with SandboxStateError',
|
|
1679
|
+
'[testing-env/test_image:0/test_feature-session-2291d8c] shell: "test_feature" teardown session',
|
|
1680
|
+
"[testing-env/test_image:0] session 'test_feature-session-2291d8c' ended with SandboxStateError",
|
|
1681
|
+
'[testing-env/test_image:0] shell: "test_feature" teardown',
|
|
1682
|
+
'[testing-env/test_image:0/test_feature] feature teardown',
|
|
1683
|
+
'[testing-env/test_image:0] sandbox shutdown',
|
|
1474
1684
|
'[testing-env] environment shutdown'
|
|
1475
1685
|
# pylint: enable=line-too-long
|
|
1476
1686
|
]
|