Skip to content

Commit 2e7e001

Browse files
committed
Merge pull request #492 from cevich/test_fixes
Collection of fixes for failing tests w/ current version of docker
2 parents 4166335 + 0473b65 commit 2e7e001

File tree

19 files changed

+606
-545
lines changed

19 files changed

+606
-545
lines changed

config_defaults/subtests/docker_cli/commit.ini

-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ docker_expected_result = PASS
1414
commit_author = Author_name
1515
#: Commit message
1616
commit_message = Message
17-
#: Run params
18-
commit_run_params = '{"Cmd": ["ls", "/etc"], "PortSpecs": ["22"]}'
1917
#: Changed files
2018
commit_changed_files = /var/i
2119

@@ -24,8 +22,6 @@ commit_changed_files = /var/i
2422
commit_author = Author_name
2523
#: Commit message
2624
commit_message = Message
27-
#: Run params
28-
commit_run_params = '{"Cmd": ["ls", "/etc"], "PortSpecs": ["22"]}'
2925
#: Changed files
3026
commit_changed_files = /var/i
3127
#: Expected output after executing the image's default command

config_defaults/subtests/docker_cli/create.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ cmd = '/bin/command/does/not/exist'
3333

3434
[docker_cli/create/create_remote_tag]
3535
#: Name of a image on a remote registry appropriate to environment
36-
__example__ = remote_image_fqin
36+
__example__ = remote_image_fqin, docker_timeout
37+
docker_timeout = 60
3738
#: Fully qualified image name of **remote** repository to test automatic pull.
3839
remote_image_fqin = stackbrew/centos:7
3940
run_options_csv =

config_defaults/subtests/docker_cli/dockerhelp.ini

+32-32
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ subsubtests = help_simple
1212
#: section default.
1313
generate_subsubtest_list = yes
1414
#: Space separated list of all the docker commands to check
15-
help_commands: attach
16-
build
17-
commit
18-
cp
19-
diff
20-
events
21-
export
22-
history
23-
images
24-
import
25-
info
26-
inspect
27-
kill
28-
load
29-
login
30-
logs
31-
port
32-
ps
33-
pull
34-
push
35-
restart
36-
rm
37-
rmi
38-
run
39-
save
40-
search
41-
start
42-
stop
43-
tag
44-
top
45-
version
46-
wait
15+
help_commands = attach
16+
build
17+
commit
18+
cp
19+
diff
20+
events
21+
export
22+
history
23+
images
24+
import
25+
info
26+
inspect
27+
kill
28+
load
29+
login
30+
logs
31+
port
32+
ps
33+
pull
34+
push
35+
restart
36+
rm
37+
rmi
38+
run
39+
save
40+
search
41+
start
42+
stop
43+
tag
44+
top
45+
version
46+
wait
4747

4848
[docker_cli/dockerhelp/help_simple]
4949
#: CSV list of docker options where a zero-exit code is expected (though a
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[docker_cli/iptable]
22
subsubtests = iptable_remove
3-
4-
[docker_cli/iptable/iptable_remove]
5-
#: container's shell
6-
bash_cmd = /bin/bash
3+
#: Arguments to pass to run command in addition to -d and --name
4+
run_args_csv = --expose,1234,--publish,1234:1234
5+
#: container's shell command
6+
bash_cmd = /bin/bash -c 'sleep 3s'

config_defaults/subtests/docker_cli/run.ini

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[docker_cli/run]
2-
subsubtests = run_true,run_false,run_interactive,run_attach_stdout,run_remote_tag,run_names,run_passwd
2+
subsubtests = run_true,run_false,run_interactive,run_attach_stdout,run_remote_tag,run_names,run_passwd,run_ping
33
#: The most basic sub-subtests can be generated from a generic
44
#: class at runtime, set 'yes' to enable this feature.
55
generate_generic = no
@@ -33,6 +33,14 @@ expected_status = "Password set"
3333
cmd = 'passwd --status root | grep -qv %(expected_status)s'
3434
exit_status = 0
3535

36+
[docker_cli/run/run_ping]
37+
generate_generic = yes
38+
__example__ = ping_url
39+
#: Host to ping
40+
ping_url = www.google.com
41+
cmd = 'ping -c 10 -q %(ping_url)s'
42+
exit_status = 0
43+
3644
[docker_cli/run/run_names]
3745
cmd = sleep 2s
3846
# Test will find container by CID instead of name, CID must appear
@@ -64,7 +72,8 @@ exit_status = 0
6472

6573
[docker_cli/run/run_remote_tag]
6674
#: Change this to an image remotely available within test environment
67-
__example__ = remote_image_fqin
75+
__example__ = remote_image_fqin, docker_timeout
76+
docker_timeout = 60
6877
#: Fully qualified image name stored on a remote registry, not local.
6978
remote_image_fqin = stackbrew/centos:7
7079
run_options_csv =

config_defaults/subtests/docker_cli/start.ini

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ run_cmd =
1313

1414
[docker_cli/start/simple]
1515
docker_timeout = 60
16+
#: Expected string to see when starting non-running container
17+
missing_msg = o such
1618
#: modifies the running container options
1719
run_options_csv = --interactive=true
1820
docker_attach = no
+62-36
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,63 @@
11
[docker_cli/wait]
2-
subsubtests = no_wait,wait_first,wait_last,wait_missing
3-
docker_timeout = 60
4-
#: modifies the running container options
5-
run_options_csv = --detach,--interactive
6-
#: list of used containers (use _$name to override config variables)
7-
containers = cont0 cont1 cont2
8-
#: executed command on container called ``_cont0``
9-
exec_cmd_cont0 = sleep 10; exit 1
10-
#: executed command on container called ``_cont1``
11-
exec_cmd_cont1 = exit 2
12-
#: executed command on container called ``_cont2``
13-
exec_cmd_cont2 = exit 3
14-
#: Identify containers by True=name,False=id,RANDOM=random
15-
use_names = RANDOM
16-
#: random_seed - can be set to override the initial random seed used in test
17-
random_seed =
18-
#: which containers we should wait for. Either use index of the
19-
#: the container or '_' + string. The leading char will be removed!
20-
wait_for =
21-
#: Error regular expression which should match on missing container name ``%%s``
22-
missing_stderr = Error response from daemon: wait: no such \w+: %%s
23-
#: When 'yes', invert regex failure meaning for test result
24-
invert_missing = no
25-
26-
[docker_cli/wait/no_wait]
27-
wait_for = 1 2
28-
29-
[docker_cli/wait/wait_first]
30-
wait_for = 0 1 2
31-
32-
[docker_cli/wait/wait_last]
33-
wait_for = 2 1 0
34-
35-
[docker_cli/wait/wait_missing]
36-
invert_missing = yes
37-
wait_for = _i_hope_this_container_does_not_exist 0 1 2 _this_one_is_also_missing
2+
subsubtests = Simple, Multi, Sig
3+
4+
#: CSV list of strings describing how containers are setup, "CREATE", "RUN"
5+
#: or "NONE". Each value represents a separate container and all ``target_*``
6+
#: lists must contain exactly the same number of items.
7+
target_setups = RUN
8+
9+
#: CSV list of operations to perform on each container during the test
10+
#: wait command:
11+
#: {n}
12+
#: {t} * ``STOP`` - Use ``docker stop`` on the target container
13+
#: {t} * ``KILL`` - Use ``docker kill`` on the target container
14+
#: {t} * ``<n>`` - Send signal number ``<n>`` to target container
15+
#: {t} * ``REMV`` - Use ``docker rm --force`` on the target container
16+
#: {t} * ``NONE`` - Do nothing
17+
#: {n}
18+
target_waits = NONE
19+
20+
#: CSV list of sleep times for each target, must have same number of items
21+
#: as ``target_setups`` and ``target_waits``. Do not rely on timing for
22+
#: precise synchronization!
23+
target_sleeps = 0.5
24+
25+
#: Expected exit code from wait command
26+
exit = 0
27+
28+
#: (optional) Regular expression that much match wait command stdout
29+
stdout = ^0\n$
30+
31+
#: (optional) Regular expression that much match wait command stderr
32+
stderr =
33+
34+
#: Timeout for the target docker command in seconds
35+
target_timeout = 10
36+
37+
#: Timeout for the wait command itself
38+
docker_timeout = 20
39+
40+
#: Quoted command line to pass to each target container
41+
target_cmd = bash,-c,'trap "echo \"Received Signal 30\"" 30; sleep @SLEEP@s'
42+
43+
#: CSV run command line options minus --name & image for each target container
44+
target_run = --detach
45+
46+
#: Run target containers with more verbosity under all conditions
47+
target_verbose = no
48+
49+
#: Run wait command with more verbosity
50+
wait_verbose = no
51+
52+
[docker_cli/wait/Multi]
53+
docker_timeout = 20
54+
target_setups = RUN, RUN, RUN
55+
target_waits = NONE, KILL, NONE
56+
target_sleeps = 1, 5, 3
57+
stdout = ^0\n137\n0$
58+
59+
[docker_cli/wait/Sig]
60+
docker_timeout = 20
61+
target_setups = RUN
62+
target_waits = 30
63+
target_sleeps = 0.5

dockertest/containers.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@ def clean_all(self, containers):
564564
else:
565565
preserve_cnames = []
566566
preserve_cnames = set(preserve_cnames)
567-
# TODO: Set non-verbose once code stabalized
568-
self.verbose = True
567+
self.verbose = False
569568
try:
570569
for name in containers:
571570
name = name.strip()

dockertest/dockercmd.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,13 @@ def execute(self, stdin=None):
276276
str_stdin = " <<< %s" % stdin
277277
else: # Nothing
278278
str_stdin = ""
279-
self.subtest.logdebug("Execute %s%s", self.command, str_stdin)
279+
else:
280+
str_stdin = ""
281+
if self.verbose:
282+
self.subtest.logdebug("Executing %s%s", str(self), str_stdin)
280283
self.cmdresult = utils.run(self.command, timeout=self.timeout,
281284
stdin=stdin, verbose=False,
282285
ignore_status=True)
283-
if self.verbose:
284-
self.subtest.logdebug(str(self))
285286
# Return value, not reference
286287
return self.cmdresult
287288

@@ -319,6 +320,9 @@ def execute(self, stdin=None):
319320
str_stdin = " <<< %s" % stdin
320321
else:
321322
str_stdin = ""
323+
else:
324+
str_stdin = ""
325+
if self.verbose:
322326
self.subtest.logdebug("Async-execute: %s%s", str(self), str_stdin)
323327
self._async_job = utils.AsyncJob(self.command, verbose=False,
324328
stdin=stdin, close_fds=True)

dockertest/images.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ def docker_cmd_check(self, cmd, timeout=None):
380380
OutputGood(result)
381381
return result
382382

383+
def full_name_from_defaults(self):
384+
"""
385+
Return ``DockerImage.full_name_from_defaults(self.subtest.config)``
386+
"""
387+
return DockerImage.full_name_from_defaults(self.subtest.config)
388+
383389
def get_unique_name(self, prefix="", suffix="", length=4):
384390
"""
385391
Get unique name for a new image
@@ -600,7 +606,7 @@ def clean_all(self, fqins):
600606
preserve_fqins.append(
601607
DockerImage.full_name_from_defaults(self.subtest.config))
602608
preserve_fqins = set(preserve_fqins)
603-
self.verbose = True
609+
self.verbose = False
604610
try:
605611
for name in fqins:
606612
if name in preserve_fqins:

0 commit comments

Comments
 (0)