2323 get_random_region_with_caps ,
2424 get_random_text ,
2525)
26- from tests .integration .linodes .helpers_linodes import (
27- DEFAULT_LINODE_TYPE ,
28- DEFAULT_RANDOM_PASS ,
29- DEFAULT_REGION ,
30- DEFAULT_TEST_IMAGE ,
31- create_linode_and_wait ,
32- )
33-
34- DOMAIN_BASE_CMD = ["linode-cli" , "domains" ]
35- LINODE_BASE_CMD = ["linode-cli" , "linodes" ]
36- NODEBALANCER_BASE_CMD = ["linode-cli" , "nodebalancers" ]
3726
3827
3928@pytest .fixture (autouse = True , scope = "session" )
@@ -201,209 +190,6 @@ def _generate_test_files(
201190 return _generate_test_files
202191
203192
204- # Test helpers specific to Linodes test suite
205- @pytest .fixture
206- def linode_with_label (linode_cloud_firewall ):
207- timestamp = str (time .time_ns ())
208- label = "cli" + timestamp
209- result = (
210- exec_test_command (
211- LINODE_BASE_CMD
212- + [
213- "create" ,
214- "--type" ,
215- "g6-nanode-1" ,
216- "--region" ,
217- "us-ord" ,
218- "--image" ,
219- DEFAULT_TEST_IMAGE ,
220- "--label" ,
221- label ,
222- "--root_pass" ,
223- DEFAULT_RANDOM_PASS ,
224- "--firewall_id" ,
225- linode_cloud_firewall ,
226- "--text" ,
227- "--delimiter" ,
228- "," ,
229- "--no-headers" ,
230- "--format" ,
231- "label,region,type,image,id" ,
232- "--no-defaults" ,
233- ]
234- )
235- .stdout .decode ()
236- .rstrip ()
237- )
238-
239- yield result
240- res_arr = result .split ("," )
241- linode_id = res_arr [4 ]
242- delete_target_id (target = "linodes" , id = linode_id )
243-
244-
245- @pytest .fixture
246- def linode_min_req (linode_cloud_firewall ):
247- result = (
248- exec_test_command (
249- LINODE_BASE_CMD
250- + [
251- "create" ,
252- "--type" ,
253- "g6-nanode-1" ,
254- "--region" ,
255- "us-ord" ,
256- "--root_pass" ,
257- DEFAULT_RANDOM_PASS ,
258- "--firewall_id" ,
259- linode_cloud_firewall ,
260- "--no-defaults" ,
261- "--text" ,
262- "--delimiter" ,
263- "," ,
264- "--no-headers" ,
265- "--format" ,
266- "id,region,type" ,
267- ]
268- )
269- .stdout .decode ()
270- .rstrip ()
271- )
272-
273- yield result
274-
275- res_arr = result .split ("," )
276- linode_id = res_arr [0 ]
277- delete_target_id (target = "linodes" , id = linode_id )
278-
279-
280- @pytest .fixture
281- def linode_wo_image (linode_cloud_firewall ):
282- label = "cli" + str (int (time .time ()) + randint (10 , 1000 ))
283- linode_id = (
284- exec_test_command (
285- LINODE_BASE_CMD
286- + [
287- "create" ,
288- "--no-defaults" ,
289- "--label" ,
290- label ,
291- "--type" ,
292- DEFAULT_LINODE_TYPE ,
293- "--region" ,
294- DEFAULT_REGION ,
295- "--root_pass" ,
296- DEFAULT_RANDOM_PASS ,
297- "--firewall_id" ,
298- linode_cloud_firewall ,
299- "--format" ,
300- "id" ,
301- "--no-headers" ,
302- "--text" ,
303- ]
304- )
305- .stdout .decode ()
306- .rstrip ()
307- )
308-
309- yield linode_id
310-
311- delete_target_id (target = "linodes" , id = linode_id )
312-
313-
314- @pytest .fixture
315- def linode_backup_enabled (linode_cloud_firewall ):
316- # create linode with backups enabled
317- linode_id = (
318- exec_test_command (
319- [
320- "linode-cli" ,
321- "linodes" ,
322- "create" ,
323- "--backups_enabled" ,
324- "true" ,
325- "--type" ,
326- DEFAULT_LINODE_TYPE ,
327- "--region" ,
328- DEFAULT_REGION ,
329- "--image" ,
330- DEFAULT_TEST_IMAGE ,
331- "--root_pass" ,
332- DEFAULT_RANDOM_PASS ,
333- "--firewall_id" ,
334- linode_cloud_firewall ,
335- "--text" ,
336- "--no-headers" ,
337- "--format=id" ,
338- ]
339- )
340- .stdout .decode ()
341- .rstrip ()
342- )
343-
344- yield linode_id
345-
346- delete_target_id ("linodes" , linode_id )
347-
348-
349- @pytest .fixture
350- def snapshot_of_linode ():
351- timestamp = str (time .time_ns ())
352- # get linode id after creation and wait for "running" status
353- linode_id = create_linode_and_wait ()
354- new_snapshot_label = "test_snapshot" + timestamp
355-
356- result = exec_test_command (
357- LINODE_BASE_CMD
358- + [
359- "snapshot" ,
360- linode_id ,
361- "--label" ,
362- new_snapshot_label ,
363- "--text" ,
364- "--delimiter" ,
365- "," ,
366- "--no-headers" ,
367- ]
368- ).stdout .decode ()
369-
370- yield linode_id , new_snapshot_label
371-
372- delete_target_id ("linodes" , linode_id )
373-
374-
375- # Test helpers specific to Nodebalancers test suite
376- @pytest .fixture
377- def nodebalancer_with_default_conf (linode_cloud_firewall ):
378- result = (
379- exec_test_command (
380- NODEBALANCER_BASE_CMD
381- + [
382- "create" ,
383- "--region" ,
384- "us-ord" ,
385- "--firewall_id" ,
386- linode_cloud_firewall ,
387- "--text" ,
388- "--delimiter" ,
389- "," ,
390- "--format" ,
391- "id,label,region,hostname,client_conn_throttle" ,
392- "--suppress-warnings" ,
393- "--no-headers" ,
394- ]
395- )
396- .stdout .decode ()
397- .rstrip ()
398- )
399-
400- yield result
401-
402- res_arr = result .split ("," )
403- nodebalancer_id = res_arr [0 ]
404- delete_target_id (target = "nodebalancers" , id = nodebalancer_id )
405-
406-
407193def create_vpc_w_subnet ():
408194 """
409195 Creates and returns a VPC and a corresponding subnet.
@@ -416,8 +202,8 @@ def create_vpc_w_subnet():
416202 """
417203
418204 region = get_random_region_with_caps (required_capabilities = ["VPCs" ])
419- vpc_label = str ( time . time_ns () ) + "label"
420- subnet_label = str ( time . time_ns () ) + "label"
205+ vpc_label = get_random_text ( 5 ) + "label"
206+ subnet_label = get_random_text ( 5 ) + "label"
421207
422208 vpc_json = json .loads (
423209 exec_test_command (
@@ -437,8 +223,6 @@ def create_vpc_w_subnet():
437223 "--suppress-warnings" ,
438224 ]
439225 )
440- .stdout .decode ()
441- .rstrip ()
442226 )[0 ]
443227
444228 return vpc_json
@@ -449,45 +233,3 @@ def pytest_configure(config):
449233 config .addinivalue_line (
450234 "markers" , "smoke: mark test as part of smoke test suite"
451235 )
452-
453-
454- @pytest .fixture
455- def support_test_linode_id (linode_cloud_firewall ):
456- timestamp = str (time .time_ns ())
457- label = "cli" + timestamp
458-
459- res = (
460- exec_test_command (
461- LINODE_BASE_CMD
462- + [
463- "create" ,
464- "--type" ,
465- "g6-nanode-1" ,
466- "--region" ,
467- "us-mia" ,
468- "--image" ,
469- DEFAULT_TEST_IMAGE ,
470- "--label" ,
471- label ,
472- "--root_pass" ,
473- DEFAULT_RANDOM_PASS ,
474- "--firewall_id" ,
475- linode_cloud_firewall ,
476- "--text" ,
477- "--delimiter" ,
478- "," ,
479- "--no-headers" ,
480- "--format" ,
481- "id" ,
482- "--no-defaults" ,
483- ]
484- )
485- .stdout .decode ()
486- .rstrip ()
487- )
488-
489- linode_id = res
490-
491- yield linode_id
492-
493- delete_target_id (target = "linodes" , id = linode_id )
0 commit comments