def postprocess(self): self.loginfo("postprocess()") # Raise exception if problems found OutputGood(self.sub_stuff["cmdresult"]) self.failif_ne( self.sub_stuff["cmdresult"].exit_status, 0, "Non-zero commit exit status: %s" % self.sub_stuff["cmdresult"] ) im = self.check_image_exists(self.sub_stuff["new_image_name"]) # Needed for cleanup self.sub_stuff["image_list"] = im self.failif(len(im) < 1, "Failed to look up committed image ") self.check_file_in_image() # Check if is possible start image with default command. dc = DockerCmd( self, "run", ["--rm", self.sub_stuff["image_list"][0].long_id], timeout=self.config["docker_timeout"] ) results = dc.execute() dct = DockerContainers(self) cnts = dct.list_containers() for cont in cnts: if cont.image_name == self.sub_stuff["image_list"][0].full_name: try: dct.kill_container_by_long_id(cont.long_id) except ValueError: pass dc = DockerCmd(self, "rm", ["-f", cont.long_id]) rm_results = dc.execute() self.failif_ne(rm_results.exit_status, 0, "Non-zero commit exit status: %s" % rm_results) self.failif_ne(results.exit_status, 0, "Non-zero commit exit status: %s" % results) self.failif(not self.sub_stuff["rand_data"] in results.stdout, "Unexpected command result: %s" % results.stdout)
def try_kill(subtest, cidfilename, cmdresult): docker_containers = DockerContainers(subtest) try: cidfile = open(cidfilename, 'rb') cid = cidfile.read() if len(cid) < 12: raise ValueError() else: docker_containers.kill_container_by_long_id(cid.strip()) except ValueError: subtest.logdebug("Container %s not found to kill", cid[:12]) except IOError: subtest.logdebug("Container never ran for %s", cmdresult)
def postprocess(self): super(commit_base, self).postprocess() # Raise exception if problems found OutputGood(self.sub_stuff['cmdresult']) self.failif(self.sub_stuff['cmdresult'].exit_status != 0, "Non-zero commit exit status: %s" % self.sub_stuff['cmdresult']) im = self.check_image_exists(self.sub_stuff["new_image_name"]) # Needed for cleanup self.sub_stuff['image_list'] = im self.failif(len(im) < 1, "Failed to look up committed image ") self.check_file_in_image() # Check if is possible start image with default command. dc = DockerCmd(self.parent_subtest, "run", [self.sub_stuff['image_list'][0].long_id], timeout=self.config['docker_timeout']) results = dc.execute() dct = DockerContainers(self.parent_subtest) cnts = dct.list_containers() for cont in cnts: if cont.image_name == self.sub_stuff['image_list'][0].full_name: try: dct.kill_container_by_long_id(cont.long_id) except ValueError: pass dc = DockerCmd(self.parent_subtest, "rm", ["-f", cont.long_id]) rm_results = dc.execute() self.failif(rm_results.exit_status != 0, "Non-zero commit exit status: %s" % rm_results) self.failif(results.exit_status != 0, "Non-zero commit exit status: %s" % results) self.failif(not self.config['check_results_contain'] in results.stdout, "Unable to start image with default command: %s" % results)
def postprocess(self): self.loginfo("postprocess()") # Raise exception if problems found OutputGood(self.sub_stuff['cmdresult']) self.failif_ne( self.sub_stuff['cmdresult'].exit_status, 0, "Non-zero commit exit status: %s" % self.sub_stuff['cmdresult']) im = self.check_image_exists(self.sub_stuff["new_image_name"]) # Needed for cleanup self.sub_stuff['image_list'] = im self.failif(len(im) < 1, "Failed to look up committed image ") self.check_file_in_image() # Check if is possible start image with default command. dc = DockerCmd(self, "run", ['--rm', self.sub_stuff['image_list'][0].long_id], timeout=self.config['docker_timeout']) results = dc.execute() dct = DockerContainers(self) cnts = dct.list_containers() for cont in cnts: if cont.image_name == self.sub_stuff['image_list'][0].full_name: try: dct.kill_container_by_long_id(cont.long_id) except ValueError: pass dc = DockerCmd(self, "rm", ["-f", cont.long_id]) rm_results = dc.execute() self.failif_ne(rm_results.exit_status, 0, "Non-zero commit exit status: %s" % rm_results) self.failif_ne(results.exit_status, 0, "Non-zero commit exit status: %s" % results) self.failif(not self.sub_stuff['rand_data'] in results.stdout, "Unexpected command result: %s" % results.stdout)