Browse Source

Change docker-cmd for recent paunch changes

paunch was changed to support podman, it breaks some arguments, and
expectations in our tests. Let's fix that.

Change-Id: I7127cc2edb9af785e0533e0a1e5f2608417390e7
Thomas Herve 5 months ago
parent
commit
637e4260ca

+ 3
- 3
heat-config-docker-cmd/install.d/hook-docker-cmd.py View File

@@ -76,9 +76,9 @@ def main(argv=sys.argv):
76 76
     stdout, stderr, deploy_status_code = paunch.apply(
77 77
         cid,
78 78
         config,
79
-        managed_by='docker-cmd',
80
-        labels=labels,
81
-        docker_cmd=DOCKER_CMD
79
+        'docker-cmd',
80
+        labels,
81
+        DOCKER_CMD
82 82
     )
83 83
 
84 84
     json.dump(build_response(

+ 2
- 2
heat-config-docker-cmd/os-refresh-config/configure.d/50-heat-config-docker-cmd View File

@@ -53,8 +53,8 @@ def main(argv=sys.argv):
53 53
 
54 54
     paunch.cleanup(
55 55
         cmd_config_ids,
56
-        managed_by='docker-cmd',
57
-        docker_cmd=DOCKER_CMD
56
+        'docker-cmd',
57
+        DOCKER_CMD
58 58
     )
59 59
 
60 60
 

+ 63
- 13
tests/test_hook_docker_cmd.py View File

@@ -234,6 +234,8 @@ class HookDockerCmdTest(common.RunScriptTest):
234 234
                 {},
235 235
                 # docker run web
236 236
                 {'stderr': 'Creating web...'},
237
+                # inspect
238
+                {},
237 239
                 # name lookup for exec web
238 240
                 {'stdout': 'web'},
239 241
                 # docker exec web
@@ -253,7 +255,7 @@ class HookDockerCmdTest(common.RunScriptTest):
253 255
             'deploy_status_code': 0
254 256
         }, json.loads(stdout.decode('utf-8')))
255 257
 
256
-        state = list(self.json_from_files(self.test_state_path, 13))
258
+        state = list(self.json_from_files(self.test_state_path, 14))
257 259
         self.check_basic_response(state)
258 260
         self.assert_args_and_labels([
259 261
             self.fake_tool_path,
@@ -308,6 +310,15 @@ class HookDockerCmdTest(common.RunScriptTest):
308 310
             u'container_name=web',
309 311
             u'managed_by=docker-cmd',
310 312
         ], state[10]['args'])
313
+        self.assertEqual([
314
+            self.fake_tool_path,
315
+            'inspect',
316
+            '--type',
317
+            'container',
318
+            '--format',
319
+            'exists',
320
+            'web-ls'
321
+        ], state[11]['args'])
311 322
         self.assertEqual([
312 323
             self.fake_tool_path,
313 324
             u'ps',
@@ -318,14 +329,14 @@ class HookDockerCmdTest(common.RunScriptTest):
318 329
             u'label=config_id=abc123',
319 330
             u'--format',
320 331
             u'{{.Names}}',
321
-        ], state[11]['args'])
332
+        ], state[12]['args'])
322 333
         self.assertEqual([
323 334
             self.fake_tool_path,
324 335
             u'exec',
325 336
             u'web',
326 337
             u'/bin/ls',
327 338
             u'-l'
328
-        ], state[12]['args'])
339
+        ], state[13]['args'])
329 340
 
330 341
     def test_hook_exit_codes(self):
331 342
 
@@ -337,6 +348,7 @@ class HookDockerCmdTest(common.RunScriptTest):
337 348
                 {},
338 349
                 # ps for currently running containers
339 350
                 {},
351
+                {},
340 352
                 {'stdout': 'web'},
341 353
                 {
342 354
                     'stdout': '',
@@ -354,7 +366,7 @@ class HookDockerCmdTest(common.RunScriptTest):
354 366
             'deploy_status_code': 0
355 367
         }, json.loads(stdout.decode('utf-8')))
356 368
 
357
-        state = list(self.json_from_files(self.test_state_path, 5))
369
+        state = list(self.json_from_files(self.test_state_path, 6))
358 370
         self.assertEqual([
359 371
             self.fake_tool_path,
360 372
             'ps',
@@ -386,6 +398,15 @@ class HookDockerCmdTest(common.RunScriptTest):
386 398
             '--format',
387 399
             '{{.Names}} {{.Label "container_name"}}'
388 400
         ], state[2]['args'])
401
+        self.assertEqual([
402
+            self.fake_tool_path,
403
+            'inspect',
404
+            '--type',
405
+            'container',
406
+            '--format',
407
+            'exists',
408
+            'web-ls'
409
+        ], state[3]['args'])
389 410
         self.assertEqual([
390 411
             self.fake_tool_path,
391 412
             'ps',
@@ -396,14 +417,14 @@ class HookDockerCmdTest(common.RunScriptTest):
396 417
             'label=config_id=abc123',
397 418
             '--format',
398 419
             '{{.Names}}',
399
-        ], state[3]['args'])
420
+        ], state[4]['args'])
400 421
         self.assertEqual([
401 422
             self.fake_tool_path,
402 423
             'exec',
403 424
             'web',
404 425
             '/bin/ls',
405 426
             '-l'
406
-        ], state[4]['args'])
427
+        ], state[5]['args'])
407 428
 
408 429
     def test_hook_failed(self):
409 430
 
@@ -431,6 +452,8 @@ class HookDockerCmdTest(common.RunScriptTest):
431 452
                 {},
432 453
                 # docker run web
433 454
                 {'stderr': 'Creating web...'},
455
+                # inspect
456
+                {},
434 457
                 # name lookup for exec web
435 458
                 {'stdout': 'web'},
436 459
                 # docker exec web fails
@@ -452,7 +475,7 @@ class HookDockerCmdTest(common.RunScriptTest):
452 475
             'deploy_status_code': 2
453 476
         }, json.loads(stdout.decode('utf-8')))
454 477
 
455
-        state = list(self.json_from_files(self.test_state_path, 13))
478
+        state = list(self.json_from_files(self.test_state_path, 14))
456 479
         self.check_basic_response(state)
457 480
         self.assert_args_and_labels([
458 481
             self.fake_tool_path,
@@ -507,6 +530,15 @@ class HookDockerCmdTest(common.RunScriptTest):
507 530
             u'container_name=web',
508 531
             u'managed_by=docker-cmd',
509 532
         ], state[10]['args'])
533
+        self.assertEqual([
534
+            self.fake_tool_path,
535
+            'inspect',
536
+            '--type',
537
+            'container',
538
+            '--format',
539
+            'exists',
540
+            'web-ls'
541
+        ], state[11]['args'])
510 542
         self.assertEqual([
511 543
             self.fake_tool_path,
512 544
             u'ps',
@@ -517,14 +549,14 @@ class HookDockerCmdTest(common.RunScriptTest):
517 549
             u'label=config_id=abc123',
518 550
             u'--format',
519 551
             u'{{.Names}}',
520
-        ], state[11]['args'])
552
+        ], state[12]['args'])
521 553
         self.assertEqual([
522 554
             self.fake_tool_path,
523 555
             u'exec',
524 556
             u'web',
525 557
             u'/bin/ls',
526 558
             u'-l'
527
-        ], state[12]['args'])
559
+        ], state[13]['args'])
528 560
 
529 561
     def test_hook_unique_names(self):
530 562
         self.env.update({
@@ -571,7 +603,7 @@ class HookDockerCmdTest(common.RunScriptTest):
571 603
 
572 604
         self.assertEqual(0, returncode, stderr)
573 605
 
574
-        state = list(self.json_from_files(self.test_state_path, 15))
606
+        state = list(self.json_from_files(self.test_state_path, 17))
575 607
         dd = []
576 608
         for i in state:
577 609
             dd.append(i['args'])
@@ -651,6 +683,24 @@ class HookDockerCmdTest(common.RunScriptTest):
651 683
             u'container_name=web',
652 684
             u'managed_by=docker-cmd',
653 685
         ], state[12]['args'])
686
+        self.assertEqual([
687
+            self.fake_tool_path,
688
+            'inspect',
689
+            '--type',
690
+            'container',
691
+            '--format',
692
+            'exists',
693
+            'web-ls'
694
+        ], state[13]['args'])
695
+        self.assertEqual([
696
+            self.fake_tool_path,
697
+            'inspect',
698
+            '--type',
699
+            'container',
700
+            '--format',
701
+            'exists',
702
+            state[14]['args'][6]
703
+        ], state[14]['args'])
654 704
         self.assertEqual([
655 705
             self.fake_tool_path,
656 706
             u'ps',
@@ -661,14 +711,14 @@ class HookDockerCmdTest(common.RunScriptTest):
661 711
             u'label=config_id=abc123',
662 712
             u'--format',
663 713
             u'{{.Names}}',
664
-        ], state[13]['args'])
714
+        ], state[15]['args'])
665 715
         self.assertEqual([
666 716
             self.fake_tool_path,
667 717
             u'exec',
668
-            u'web-asdf1234',
718
+            u'web',
669 719
             u'/bin/ls',
670 720
             u'-l'
671
-        ], state[14]['args'])
721
+        ], state[16]['args'])
672 722
 
673 723
     def test_cleanup_deleted(self):
674 724
         self.env.update({

Loading…
Cancel
Save