Skip to content

Commit

Permalink
Merge pull request #492 from cevich/test_fixes
Browse files Browse the repository at this point in the history
Collection of fixes for failing tests w/ current version of docker
  • Loading branch information
cevich committed Apr 8, 2015
2 parents 4166335 + 0473b65 commit 2e7e001
Show file tree
Hide file tree
Showing 19 changed files with 606 additions and 545 deletions.
4 changes: 0 additions & 4 deletions config_defaults/subtests/docker_cli/commit.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ docker_expected_result = PASS
commit_author = Author_name
#: Commit message
commit_message = Message
#: Run params
commit_run_params = '{"Cmd": ["ls", "/etc"], "PortSpecs": ["22"]}'
#: Changed files
commit_changed_files = /var/i

Expand All @@ -24,8 +22,6 @@ commit_changed_files = /var/i
commit_author = Author_name
#: Commit message
commit_message = Message
#: Run params
commit_run_params = '{"Cmd": ["ls", "/etc"], "PortSpecs": ["22"]}'
#: Changed files
commit_changed_files = /var/i
#: Expected output after executing the image's default command
Expand Down
3 changes: 2 additions & 1 deletion config_defaults/subtests/docker_cli/create.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ cmd = '/bin/command/does/not/exist'

[docker_cli/create/create_remote_tag]
#: Name of a image on a remote registry appropriate to environment
__example__ = remote_image_fqin
__example__ = remote_image_fqin, docker_timeout
docker_timeout = 60
#: Fully qualified image name of **remote** repository to test automatic pull.
remote_image_fqin = stackbrew/centos:7
run_options_csv =
64 changes: 32 additions & 32 deletions config_defaults/subtests/docker_cli/dockerhelp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ subsubtests = help_simple
#: section default.
generate_subsubtest_list = yes
#: Space separated list of all the docker commands to check
help_commands: attach
build
commit
cp
diff
events
export
history
images
import
info
inspect
kill
load
login
logs
port
ps
pull
push
restart
rm
rmi
run
save
search
start
stop
tag
top
version
wait
help_commands = attach
build
commit
cp
diff
events
export
history
images
import
info
inspect
kill
load
login
logs
port
ps
pull
push
restart
rm
rmi
run
save
search
start
stop
tag
top
version
wait

[docker_cli/dockerhelp/help_simple]
#: CSV list of docker options where a zero-exit code is expected (though a
Expand Down
8 changes: 4 additions & 4 deletions config_defaults/subtests/docker_cli/iptable.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[docker_cli/iptable]
subsubtests = iptable_remove

[docker_cli/iptable/iptable_remove]
#: container's shell
bash_cmd = /bin/bash
#: Arguments to pass to run command in addition to -d and --name
run_args_csv = --expose,1234,--publish,1234:1234
#: container's shell command
bash_cmd = /bin/bash -c 'sleep 3s'
13 changes: 11 additions & 2 deletions config_defaults/subtests/docker_cli/run.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[docker_cli/run]
subsubtests = run_true,run_false,run_interactive,run_attach_stdout,run_remote_tag,run_names,run_passwd
subsubtests = run_true,run_false,run_interactive,run_attach_stdout,run_remote_tag,run_names,run_passwd,run_ping
#: The most basic sub-subtests can be generated from a generic
#: class at runtime, set 'yes' to enable this feature.
generate_generic = no
Expand Down Expand Up @@ -33,6 +33,14 @@ expected_status = "Password set"
cmd = 'passwd --status root | grep -qv %(expected_status)s'
exit_status = 0

[docker_cli/run/run_ping]
generate_generic = yes
__example__ = ping_url
#: Host to ping
ping_url = www.google.com
cmd = 'ping -c 10 -q %(ping_url)s'
exit_status = 0

[docker_cli/run/run_names]
cmd = sleep 2s
# Test will find container by CID instead of name, CID must appear
Expand Down Expand Up @@ -64,7 +72,8 @@ exit_status = 0

[docker_cli/run/run_remote_tag]
#: Change this to an image remotely available within test environment
__example__ = remote_image_fqin
__example__ = remote_image_fqin, docker_timeout
docker_timeout = 60
#: Fully qualified image name stored on a remote registry, not local.
remote_image_fqin = stackbrew/centos:7
run_options_csv =
Expand Down
2 changes: 2 additions & 0 deletions config_defaults/subtests/docker_cli/start.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ run_cmd =

[docker_cli/start/simple]
docker_timeout = 60
#: Expected string to see when starting non-running container
missing_msg = o such
#: modifies the running container options
run_options_csv = --interactive=true
docker_attach = no
Expand Down
98 changes: 62 additions & 36 deletions config_defaults/subtests/docker_cli/wait.ini
Original file line number Diff line number Diff line change
@@ -1,37 +1,63 @@
[docker_cli/wait]
subsubtests = no_wait,wait_first,wait_last,wait_missing
docker_timeout = 60
#: modifies the running container options
run_options_csv = --detach,--interactive
#: list of used containers (use _$name to override config variables)
containers = cont0 cont1 cont2
#: executed command on container called ``_cont0``
exec_cmd_cont0 = sleep 10; exit 1
#: executed command on container called ``_cont1``
exec_cmd_cont1 = exit 2
#: executed command on container called ``_cont2``
exec_cmd_cont2 = exit 3
#: Identify containers by True=name,False=id,RANDOM=random
use_names = RANDOM
#: random_seed - can be set to override the initial random seed used in test
random_seed =
#: which containers we should wait for. Either use index of the
#: the container or '_' + string. The leading char will be removed!
wait_for =
#: Error regular expression which should match on missing container name ``%%s``
missing_stderr = Error response from daemon: wait: no such \w+: %%s
#: When 'yes', invert regex failure meaning for test result
invert_missing = no

[docker_cli/wait/no_wait]
wait_for = 1 2

[docker_cli/wait/wait_first]
wait_for = 0 1 2

[docker_cli/wait/wait_last]
wait_for = 2 1 0

[docker_cli/wait/wait_missing]
invert_missing = yes
wait_for = _i_hope_this_container_does_not_exist 0 1 2 _this_one_is_also_missing
subsubtests = Simple, Multi, Sig

#: CSV list of strings describing how containers are setup, "CREATE", "RUN"
#: or "NONE". Each value represents a separate container and all ``target_*``
#: lists must contain exactly the same number of items.
target_setups = RUN

#: CSV list of operations to perform on each container during the test
#: wait command:
#: {n}
#: {t} * ``STOP`` - Use ``docker stop`` on the target container
#: {t} * ``KILL`` - Use ``docker kill`` on the target container
#: {t} * ``<n>`` - Send signal number ``<n>`` to target container
#: {t} * ``REMV`` - Use ``docker rm --force`` on the target container
#: {t} * ``NONE`` - Do nothing
#: {n}
target_waits = NONE

#: CSV list of sleep times for each target, must have same number of items
#: as ``target_setups`` and ``target_waits``. Do not rely on timing for
#: precise synchronization!
target_sleeps = 0.5

#: Expected exit code from wait command
exit = 0

#: (optional) Regular expression that much match wait command stdout
stdout = ^0\n$

#: (optional) Regular expression that much match wait command stderr
stderr =

#: Timeout for the target docker command in seconds
target_timeout = 10

#: Timeout for the wait command itself
docker_timeout = 20

#: Quoted command line to pass to each target container
target_cmd = bash,-c,'trap "echo \"Received Signal 30\"" 30; sleep @SLEEP@s'

#: CSV run command line options minus --name & image for each target container
target_run = --detach

#: Run target containers with more verbosity under all conditions
target_verbose = no

#: Run wait command with more verbosity
wait_verbose = no

[docker_cli/wait/Multi]
docker_timeout = 20
target_setups = RUN, RUN, RUN
target_waits = NONE, KILL, NONE
target_sleeps = 1, 5, 3
stdout = ^0\n137\n0$

[docker_cli/wait/Sig]
docker_timeout = 20
target_setups = RUN
target_waits = 30
target_sleeps = 0.5
3 changes: 1 addition & 2 deletions dockertest/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,7 @@ def clean_all(self, containers):
else:
preserve_cnames = []
preserve_cnames = set(preserve_cnames)
# TODO: Set non-verbose once code stabalized
self.verbose = True
self.verbose = False
try:
for name in containers:
name = name.strip()
Expand Down
10 changes: 7 additions & 3 deletions dockertest/dockercmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@ def execute(self, stdin=None):
str_stdin = " <<< %s" % stdin
else: # Nothing
str_stdin = ""
self.subtest.logdebug("Execute %s%s", self.command, str_stdin)
else:
str_stdin = ""
if self.verbose:
self.subtest.logdebug("Executing %s%s", str(self), str_stdin)
self.cmdresult = utils.run(self.command, timeout=self.timeout,
stdin=stdin, verbose=False,
ignore_status=True)
if self.verbose:
self.subtest.logdebug(str(self))
# Return value, not reference
return self.cmdresult

Expand Down Expand Up @@ -319,6 +320,9 @@ def execute(self, stdin=None):
str_stdin = " <<< %s" % stdin
else:
str_stdin = ""
else:
str_stdin = ""
if self.verbose:
self.subtest.logdebug("Async-execute: %s%s", str(self), str_stdin)
self._async_job = utils.AsyncJob(self.command, verbose=False,
stdin=stdin, close_fds=True)
Expand Down
8 changes: 7 additions & 1 deletion dockertest/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ def docker_cmd_check(self, cmd, timeout=None):
OutputGood(result)
return result

def full_name_from_defaults(self):
"""
Return ``DockerImage.full_name_from_defaults(self.subtest.config)``
"""
return DockerImage.full_name_from_defaults(self.subtest.config)

def get_unique_name(self, prefix="", suffix="", length=4):
"""
Get unique name for a new image
Expand Down Expand Up @@ -600,7 +606,7 @@ def clean_all(self, fqins):
preserve_fqins.append(
DockerImage.full_name_from_defaults(self.subtest.config))
preserve_fqins = set(preserve_fqins)
self.verbose = True
self.verbose = False
try:
for name in fqins:
if name in preserve_fqins:
Expand Down
Loading

0 comments on commit 2e7e001

Please sign in to comment.