Utility to re-run a docker container with slightly different arguments
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

test.py 1.6KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/python3
  2. import subprocess
  3. from nose_parameterized import parameterized
  4. def _run(cmd):
  5. subprocess.call(cmd,
  6. stdout=subprocess.DEVNULL,
  7. stderr=subprocess.DEVNULL)
  8. @parameterized([
  9. ['docker', 'run', '--name=test123', '-d', 'hello-world'],
  10. ['docker', 'run', '--name=test123', '-d', 'hello-world:latest'],
  11. ['docker', 'run', '--name=test123', '-d', 'hello-world', '/hello', 'world...'],
  12. ['docker', 'run', '--env=PATH=/root', '--env=Z=X', '--name=test123', '-d', 'hello-world'],
  13. ['docker', 'run', '--env=FOO=bar baz', '--name=test123', '-d', 'hello-world'],
  14. ['docker', 'run', '--name=test123', '--restart=always', '-d', 'hello-world'],
  15. ['docker', 'run', '--name=test123', '--restart=on-failure:10', '-d', 'hello-world'],
  16. ['docker', 'run', '--name=test123', '--net=host', '-d', 'hello-world'],
  17. ['docker', 'run', '--name=test123', '-d', '-p=127.0.0.1:443:443/tcp', '-p=127.0.0.1::1336/tcp', 'hello-world'],
  18. ['docker', 'run', '--name=test123', '-d', '-p=443/tcp', 'hello-world'],
  19. ['docker', 'run', '--name=test123', '--user=root', '-d', 'hello-world', '/hello', 'foobar'],
  20. ['docker', 'run', '--name=test123', '--volume=/dev/null:/null', '--volume=/dev/urandom:/mnt/random', '-d', 'hello-world'],
  21. ])
  22. def test_command_matches(*command):
  23. _run(['docker', 'rm', '-f', 'test123'])
  24. _run(command)
  25. output = subprocess.check_output(['./docker-rerun', '--dry-run', 'test123'])
  26. output = output.decode('utf-8').strip().splitlines()
  27. assert output[3] == ' '.join(command)
  28. _run(['docker', 'rm', '-f', 'test123'])