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
This commit is contained in:
Thomas Herve 2018-11-06 15:02:12 +01:00 committed by Quique Llorente
parent 64b57bfef7
commit 637e4260ca
3 changed files with 68 additions and 18 deletions

View File

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

View File

@ -53,8 +53,8 @@ def main(argv=sys.argv):
paunch.cleanup( paunch.cleanup(
cmd_config_ids, cmd_config_ids,
managed_by='docker-cmd', 'docker-cmd',
docker_cmd=DOCKER_CMD DOCKER_CMD
) )

View File

@ -234,6 +234,8 @@ class HookDockerCmdTest(common.RunScriptTest):
{}, {},
# docker run web # docker run web
{'stderr': 'Creating web...'}, {'stderr': 'Creating web...'},
# inspect
{},
# name lookup for exec web # name lookup for exec web
{'stdout': 'web'}, {'stdout': 'web'},
# docker exec web # docker exec web
@ -253,7 +255,7 @@ class HookDockerCmdTest(common.RunScriptTest):
'deploy_status_code': 0 'deploy_status_code': 0
}, json.loads(stdout.decode('utf-8'))) }, json.loads(stdout.decode('utf-8')))
state = list(self.json_from_files(self.test_state_path, 13)) state = list(self.json_from_files(self.test_state_path, 14))
self.check_basic_response(state) self.check_basic_response(state)
self.assert_args_and_labels([ self.assert_args_and_labels([
self.fake_tool_path, self.fake_tool_path,
@ -308,6 +310,15 @@ class HookDockerCmdTest(common.RunScriptTest):
u'container_name=web', u'container_name=web',
u'managed_by=docker-cmd', u'managed_by=docker-cmd',
], state[10]['args']) ], state[10]['args'])
self.assertEqual([
self.fake_tool_path,
'inspect',
'--type',
'container',
'--format',
'exists',
'web-ls'
], state[11]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
u'ps', u'ps',
@ -318,14 +329,14 @@ class HookDockerCmdTest(common.RunScriptTest):
u'label=config_id=abc123', u'label=config_id=abc123',
u'--format', u'--format',
u'{{.Names}}', u'{{.Names}}',
], state[11]['args']) ], state[12]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
u'exec', u'exec',
u'web', u'web',
u'/bin/ls', u'/bin/ls',
u'-l' u'-l'
], state[12]['args']) ], state[13]['args'])
def test_hook_exit_codes(self): def test_hook_exit_codes(self):
@ -337,6 +348,7 @@ class HookDockerCmdTest(common.RunScriptTest):
{}, {},
# ps for currently running containers # ps for currently running containers
{}, {},
{},
{'stdout': 'web'}, {'stdout': 'web'},
{ {
'stdout': '', 'stdout': '',
@ -354,7 +366,7 @@ class HookDockerCmdTest(common.RunScriptTest):
'deploy_status_code': 0 'deploy_status_code': 0
}, json.loads(stdout.decode('utf-8'))) }, json.loads(stdout.decode('utf-8')))
state = list(self.json_from_files(self.test_state_path, 5)) state = list(self.json_from_files(self.test_state_path, 6))
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
'ps', 'ps',
@ -386,6 +398,15 @@ class HookDockerCmdTest(common.RunScriptTest):
'--format', '--format',
'{{.Names}} {{.Label "container_name"}}' '{{.Names}} {{.Label "container_name"}}'
], state[2]['args']) ], state[2]['args'])
self.assertEqual([
self.fake_tool_path,
'inspect',
'--type',
'container',
'--format',
'exists',
'web-ls'
], state[3]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
'ps', 'ps',
@ -396,14 +417,14 @@ class HookDockerCmdTest(common.RunScriptTest):
'label=config_id=abc123', 'label=config_id=abc123',
'--format', '--format',
'{{.Names}}', '{{.Names}}',
], state[3]['args']) ], state[4]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
'exec', 'exec',
'web', 'web',
'/bin/ls', '/bin/ls',
'-l' '-l'
], state[4]['args']) ], state[5]['args'])
def test_hook_failed(self): def test_hook_failed(self):
@ -431,6 +452,8 @@ class HookDockerCmdTest(common.RunScriptTest):
{}, {},
# docker run web # docker run web
{'stderr': 'Creating web...'}, {'stderr': 'Creating web...'},
# inspect
{},
# name lookup for exec web # name lookup for exec web
{'stdout': 'web'}, {'stdout': 'web'},
# docker exec web fails # docker exec web fails
@ -452,7 +475,7 @@ class HookDockerCmdTest(common.RunScriptTest):
'deploy_status_code': 2 'deploy_status_code': 2
}, json.loads(stdout.decode('utf-8'))) }, json.loads(stdout.decode('utf-8')))
state = list(self.json_from_files(self.test_state_path, 13)) state = list(self.json_from_files(self.test_state_path, 14))
self.check_basic_response(state) self.check_basic_response(state)
self.assert_args_and_labels([ self.assert_args_and_labels([
self.fake_tool_path, self.fake_tool_path,
@ -507,6 +530,15 @@ class HookDockerCmdTest(common.RunScriptTest):
u'container_name=web', u'container_name=web',
u'managed_by=docker-cmd', u'managed_by=docker-cmd',
], state[10]['args']) ], state[10]['args'])
self.assertEqual([
self.fake_tool_path,
'inspect',
'--type',
'container',
'--format',
'exists',
'web-ls'
], state[11]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
u'ps', u'ps',
@ -517,14 +549,14 @@ class HookDockerCmdTest(common.RunScriptTest):
u'label=config_id=abc123', u'label=config_id=abc123',
u'--format', u'--format',
u'{{.Names}}', u'{{.Names}}',
], state[11]['args']) ], state[12]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
u'exec', u'exec',
u'web', u'web',
u'/bin/ls', u'/bin/ls',
u'-l' u'-l'
], state[12]['args']) ], state[13]['args'])
def test_hook_unique_names(self): def test_hook_unique_names(self):
self.env.update({ self.env.update({
@ -571,7 +603,7 @@ class HookDockerCmdTest(common.RunScriptTest):
self.assertEqual(0, returncode, stderr) self.assertEqual(0, returncode, stderr)
state = list(self.json_from_files(self.test_state_path, 15)) state = list(self.json_from_files(self.test_state_path, 17))
dd = [] dd = []
for i in state: for i in state:
dd.append(i['args']) dd.append(i['args'])
@ -651,6 +683,24 @@ class HookDockerCmdTest(common.RunScriptTest):
u'container_name=web', u'container_name=web',
u'managed_by=docker-cmd', u'managed_by=docker-cmd',
], state[12]['args']) ], state[12]['args'])
self.assertEqual([
self.fake_tool_path,
'inspect',
'--type',
'container',
'--format',
'exists',
'web-ls'
], state[13]['args'])
self.assertEqual([
self.fake_tool_path,
'inspect',
'--type',
'container',
'--format',
'exists',
state[14]['args'][6]
], state[14]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
u'ps', u'ps',
@ -661,14 +711,14 @@ class HookDockerCmdTest(common.RunScriptTest):
u'label=config_id=abc123', u'label=config_id=abc123',
u'--format', u'--format',
u'{{.Names}}', u'{{.Names}}',
], state[13]['args']) ], state[15]['args'])
self.assertEqual([ self.assertEqual([
self.fake_tool_path, self.fake_tool_path,
u'exec', u'exec',
u'web-asdf1234', u'web',
u'/bin/ls', u'/bin/ls',
u'-l' u'-l'
], state[14]['args']) ], state[16]['args'])
def test_cleanup_deleted(self): def test_cleanup_deleted(self):
self.env.update({ self.env.update({