Skip to content

Commit 53e6d4a

Browse files
authored
Fix image counting in build subtest (#640)
default image is not always build base image In these situations, the image count can be off because docker build will pull the base-image. This changes moves the accounting for existing images, after a 'docker pull' of the default image. Then for each remote dockerfile test, configure it's base-image explicitly in case the global base image is different. Also, resolved old build sub-subtest FIXME Signed-off-by: Chris Evich <[email protected]>
1 parent 53e0588 commit 53e6d4a

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

config_defaults/subtests/docker_cli/build.ini

+10
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,23 @@ dockerfile_dir_path = /full
7575
__example__ = dockerfile_dir_path, postproc_cmd_csv
7676
use_config_repo = no
7777
dockerfile_dir_path = https://raw.githubusercontent.com/autotest/autotest-docker/master/subtests/docker_cli/build/full/Dockerfile
78+
# Hard code this to base-image used in remote dockerfile (above)
79+
docker_registry_host = docker.io
80+
docker_registry_user = stackbrew
81+
docker_repo_name = centos
82+
docker_repo_tag = 7
7883
# Inherits options from main subtest section (above)
7984
# no need to repeat them here.
8085

8186
[docker_cli/build/git_path]
8287
__example__ = dockerfile_dir_path, postproc_cmd_csv
8388
use_config_repo = no
8489
dockerfile_dir_path = git://github.com/autotest/autotest-docker.git
90+
# Hard code this to base-image used in remote dockerfile (above)
91+
docker_registry_host = docker.io
92+
docker_registry_user = stackbrew
93+
docker_repo_name = centos
94+
docker_repo_tag = 7
8595
postproc_cmd_csv = positive(),
8696
rx_out('Removing intermediate container'),
8797
rx_out('\s*Successfully built\s*(\w{64}|\w{12})'),

subtests/docker_cli/build/build.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ def basic_postprocess(build_def, command, parameter):
223223
if OutputGood(build_def.dockercmd.cmdresult,
224224
ignore_error=True,
225225
skip=['error_check']):
226-
# FIXME: this is likely to fail in docker-1.10; bz1097344
227-
return build_def.dockercmd.cmdresult.exit_status == 1
226+
return build_def.dockercmd.cmdresult.exit_status != 0
228227
else:
229228
raise DockerTestError("Command error: %s" % command)
230229

@@ -428,15 +427,13 @@ def initialize_utils(self):
428427
# Get the latest container (remove all newly created in cleanup
429428
self.sub_stuff['dc'] = DockerContainers(self)
430429
self.sub_stuff['di'] = DockerImages(self)
431-
pec = self.parent_subtest.stuff['existing_containers']
432-
self.sub_stuff['existing_containers'] = pec
433-
pei = self.parent_subtest.stuff['existing_images']
434-
self.sub_stuff['existing_images'] = pei
435430

436431
def make_builds(self, source):
437432
dimg = self.sub_stuff['di']
438433
image_name = dimg.get_unique_name()
439434
base_repo_fqin = DockerImage.full_name_from_defaults(source)
435+
# Existing images recorded after this method runs
436+
DockerCmd(self, 'pull', [base_repo_fqin]).execute()
440437
use_config_repo = source['use_config_repo']
441438
postproc_cmd_csv = source['postproc_cmd_csv']
442439
dockerfile_dir_path = source['dockerfile_dir_path'].strip()
@@ -482,7 +479,13 @@ def initialize(self):
482479
super(build_base, self).initialize()
483480
self.initialize_utils()
484481
self.sub_stuff['builds'] = []
482+
# Side-effect: docker pulls the base-image
485483
self.sub_stuff['builds'] += self.make_builds(self.config)
484+
pec = self.parent_subtest.stuff['existing_containers']
485+
self.sub_stuff['existing_containers'] = pec
486+
# Count after pulling base-image
487+
pei = self.parent_subtest.stuff['existing_images']
488+
self.sub_stuff['existing_images'] = pei
486489

487490
def run_once(self):
488491
super(build_base, self).run_once()

subtests/docker_cli/build/full/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM stackbrew/centos:centos7
1+
FROM stackbrew/centos:7
22
33
ENV PATH /usr/sbin:/usr/bin
44
RUN echo "Schazam!"

0 commit comments

Comments
 (0)