Exemple #1
0
    def postprocess(self):
        super(tag_base, self).postprocess()
        if self.config["docker_expected_result"] == "PASS":
            # Raise exception if problems found
            OutputGood(self.sub_stuff['cmdresult'])
            self.failif(
                self.sub_stuff['cmdresult'].exit_status != 0,
                "Non-zero tag exit status: %s" % self.sub_stuff['cmdresult'])

            img = self.get_images_by_name(self.sub_stuff["new_image_name"])
            # Needed for cleanup
            self.sub_stuff['image_list'] += img
            self.failif(len(img) < 1, "Failed to look up tagted image ")

        elif self.config["docker_expected_result"] == "FAIL":
            chck = OutputGood(self.sub_stuff['cmdresult'], ignore_error=True)
            exit_code = self.sub_stuff['cmdresult'].exit_status
            self.failif(
                not chck or not exit_code,
                "Zero tag exit status: Command should fail due to"
                " wrong command arguments.")
        else:
            self.failif(
                True, "Improper 'docker_expected_result' value %s" %
                self.config["docker_expected_result"])
Exemple #2
0
 def postprocess(self):
     super(help_base, self).postprocess()  # Prints out basic info
     for cmdresult in self.sub_stuff["success_cmdresults"]:
         no_usage = cmdresult.stdout.lower().find('usage:') == -1
         self.failif(
             no_usage, "Did not return usage help on stdout for: "
             "%s" % cmdresult.command)
         outputgood = OutputGood(
             cmdresult,
             ignore_error=True,
             skip=['usage_check', 'error_check', 'nonprintables_check'])
         self.failif(not outputgood, str(outputgood))
     for cmdresult in self.sub_stuff['failure_cmdresults']:
         defined = cmdresult.stdout.lower().find('flag provided but '
                                                 'not defined') > -1
         usage = cmdresult.stdout.lower().find('usage:') > -1
         self.failif(
             defined or usage, 'Did not return undefined '
             'error or usage message for: '
             "%s" % cmdresult.command)
         outputgood = OutputGood(
             cmdresult,
             ignore_error=True,
             skip=['usage_check', 'nonprintables_check'])
         self.failif(not outputgood, str(outputgood))
Exemple #3
0
 def postprocess(self):
     super(stop_base, self).postprocess()
     self.check_output()
     stop_results = self.sub_stuff['stop_results']
     if self.config.get("stop_duration"):
         stop_duration = float(self.config.get("stop_duration"))
         self.failif(
             stop_results.duration > (stop_duration + 2),
             "'docker stop' cmd execution took longer, than "
             "expected: %ss (%s+-2s)" %
             (stop_results.duration, stop_duration))
         self.failif(
             stop_results.duration < (stop_duration - 2),
             "'docker stop' cmd execution took shorter, than "
             "expected: %ss (%s+-2s)" %
             (stop_results.duration, stop_duration))
     # Look for docker failures
     OutputGood(stop_results)
     OutputGood(self.sub_stuff['container_results'],
                skip=['nonprintables_check'])
     self.failif_ne(
         stop_results.exit_status, 0, "Exit status of the "
         "docker stop command was not 0: %s" % stop_results)
     exp = self.config.get('docker_exit_code', 0)
     self.failif_ne(
         self.sub_stuff['container_results'].exit_status, exp,
         "Exit status of the docker run command was not %s: %s" %
         (exp, self.sub_stuff['container_results']))
Exemple #4
0
 def verify_output(self):
     cmdresult = self.sub_stuff['cmdresult']
     rm_cmdresult = self.sub_stuff['rm_cmdresult']
     self.failif_ne(cmdresult.exit_status, 0, "Exit status: %s" % cmdresult)
     self.failif_ne(rm_cmdresult.exit_status, 0,
                    "Expected zero exit: %s" % rm_cmdresult)
     OutputGood(cmdresult, skip=['nonprintables_check'])
     OutputGood(rm_cmdresult)
Exemple #5
0
 def verify_output(self):
     cmdresult = self.sub_stuff['cmdresult']
     rm_cmdresult = self.sub_stuff['rm_cmdresult']
     self.failif(cmdresult.exit_status == 0,
                 ("Expected non-zero exit: %s" % cmdresult))
     self.failif_ne(rm_cmdresult.exit_status, 0,
                    ("Expected zero exit: %s" % rm_cmdresult))
     OutputGood(cmdresult)
     OutputGood(rm_cmdresult)
Exemple #6
0
 def postprocess(self):
     OutputGood(self.sub_stuff['run_dkrcmd'].cmdresult)
     OutputGood(self.sub_stuff['top_dkrcmd'].cmdresult)
     pstable = TextTable(self.sub_stuff['top_dkrcmd'].stdout)
     self.failif(len(pstable) != 1)
     psrow = pstable[0]
     self.failif(psrow['USER'] != 'root')
     self.failif(int(psrow['PID']) == 1)
     self.failif(psrow['COMMAND'] != self.COMMAND)
Exemple #7
0
 def postprocess(self):
     OutputGood(self.sub_stuff['run_dkrcmd'].cmdresult)
     OutputGood(self.sub_stuff['top_dkrcmd'].cmdresult)
     pstable = TextTable(self.sub_stuff['top_dkrcmd'].stdout)
     self.failif_ne(len(pstable), 1, "Number of rows returned by top")
     psrow = pstable[0]
     self.failif_ne(psrow['USER'], 'root', 'Expected user')
     self.failif(int(psrow['PID']) == 1, 'Process PID is 1')
     self.failif_ne(psrow['COMMAND'], self.COMMAND, 'Expected command')
Exemple #8
0
 def postprocess(self):
     super(run_twice, self).postprocess()
     for cmdresult in self.stuff['cmdresults']:
         self.loginfo("command: '%s'" % cmdresult.command)
         outputgood = OutputGood(cmdresult)
         self.failif(not outputgood, str(outputgood))
     for cmdresult in self.stuff['2nd_cmdresults']:
         self.loginfo("command: '%s'" % cmdresult.command)
         outputgood = OutputGood(cmdresult, ignore_error=True,
                                 skip=['error_check'])
         self.failif(cmdresult.exit_status == 0, str(outputgood))
         if cmdresult.exit_status != 0:
             self.logerror("Intend to fail:\n%s" % cmdresult.stderr.strip())
Exemple #9
0
 def postprocess(self):
     super(psa, self).postprocess()
     OutputGood(self.stuff['cmdresult'], skip=['nonprintables_check'])
     dc = self.stuff['dc']
     cnts = dc.list_containers_with_name(self.stuff['container_name'])
     self.failif(len(cnts) < 1, "Test container not found in list")
     cnt = cnts[0]
     estat1 = str(cnt.status).startswith("Exit 0")  # pre docker 0.9.1
     estat2 = str(cnt.status).startswith("Exited (0)")  # docker 0.9.1+
     msg = ("Exit status mismatch: %s does not"
            "start with %s or %s" % (str(cnt), "Exit 0", "Exited (0)"))
     self.failif(not (estat1 or estat2), msg)
     cid = self.stuff['container_id']
     cl0_ids = [cnt.long_id for cnt in self.stuff['cl0']]
     cl1_ids = [cnt.long_id for cnt in self.stuff['cl1']]
     cl2_ids = [cnt.long_id for cnt in self.stuff['cl2']]
     try:
         self.failif(
             cid in cl0_ids, "Test container's ID found in ps "
             "output before this test started it!")
         self.failif(
             cid not in cl1_ids, "Test container's ID not found in "
             "ps output after starting it")
         self.failif(
             cid not in cl2_ids, "Test container's ID not found in "
             "ps output after it exited")
     except DockerTestFail:
         self.logdebug("Parsed docker ps table before starting: %s",
                       self.stuff['cl0'])
         self.logdebug("Parsed docker ps table after starting: %s",
                       self.stuff['cl1'])
         self.logdebug("Parsed docker ps table after exiting: %s",
                       self.stuff['cl2'])
         raise
Exemple #10
0
 def basic_postprocess(self, build_def, command, parameter):
     del parameter  # not used
     # June 2017: docker-1.13 ignores $TERM for build sub-command.
     #            Jambs ANSI codes in output, BZ1403326
     skip = ['nonprintables_check']
     if self.config['enable_nonprintables_check']:
         skip = None
     if command == 'positive':
         # Verify zero exit status and healthy output
         opg = OutputGood(build_def.dockercmd.cmdresult,
                          skip=skip,
                          ignore_error=True)
         if opg:
             return build_def.dockercmd.cmdresult.exit_status == 0
         self.logwarning('Positive output expected but check'
                         ' failed: %s', str(opg))
         return False
     elif command == 'negative':
         # Verify non-zero exit status and no panics
         notbad = OutputNotBad(build_def.dockercmd.cmdresult,
                               skip=skip,
                               ignore_error=True)
         if notbad:
             return build_def.dockercmd.cmdresult.exit_status != 0
         self.logwarning(
             'Negative output expected, but'
             ' this is worse: %s', str(notbad))
         return False
     else:
         raise DockerTestError("Command error: %s" % command)
Exemple #11
0
 def basic_postprocess(build_def, command, parameter):
     del parameter  # not used
     if command == 'positive':
         # Verify zero exit status + healthy output
         if OutputGood(build_def.dockercmd.cmdresult, ignore_error=True):
             return build_def.dockercmd.cmdresult.exit_status == 0
         else:
             return False
     elif command == 'negative':
         # Verify non-zero exit status + healthy output
         if OutputGood(build_def.dockercmd.cmdresult,
                       ignore_error=True,
                       skip=['error_check']):
             return build_def.dockercmd.cmdresult.exit_status != 0
     else:
         raise DockerTestError("Command error: %s" % command)
Exemple #12
0
 def basic_postprocess(self, build_def, command, parameter):
     del parameter  # not used
     if command == 'positive':
         # Verify zero exit status and healthy output
         opg = OutputGood(build_def.dockercmd.cmdresult, ignore_error=True)
         if opg:
             return build_def.dockercmd.cmdresult.exit_status == 0
         else:
             self.logwarning(
                 'Positive output expected but check'
                 ' failed: %s', str(opg))
             return False
     elif command == 'negative':
         # Verify non-zero exit status and no panics
         notbad = OutputNotBad(build_def.dockercmd.cmdresult,
                               ignore_error=True)
         if notbad:
             return build_def.dockercmd.cmdresult.exit_status != 0
         else:
             self.logwarning(
                 'Negative output expected, but'
                 ' this is worse: %s', str(notbad))
             return False
     else:
         raise DockerTestError("Command error: %s" % command)
Exemple #13
0
 def _common_post(self):
     # Raise exception if problems found
     OutputGood(self.sub_stuff['cmdresult'],
                skip=['error_check'])  # error is expected
     self.failif(self.sub_stuff['cmdresult'].exit_status == 0,
                 "Zero rmi exit status: Command should fail due to"
                 " wrong image name.")
Exemple #14
0
 def postprocess(self):
     super(run_base, self).postprocess()  # Prints out basic info
     dockercmd = self.sub_stuff['dkrcmd']
     OutputGood(dockercmd.cmdresult)
     expected = self.config['exit_status']
     self.failif_ne(dockercmd.exit_status, expected,
                    "Exit status %s" % dockercmd.cmdresult)
Exemple #15
0
    def postprocess(self):
        super(history_base, self).postprocess()
        if self.config["docker_expected_result"] == "PASS":
            # Raise exception if problems found
            OutputGood(self.sub_stuff['cmdresult'])
            self.failif(
                self.sub_stuff['cmdresult'].exit_status != 0,
                "Non-zero history exit status: %s" %
                self.sub_stuff['cmdresult'])

            new_img_name = self.sub_stuff["new_image_name"]
            new_img_name2 = self.sub_stuff["new_image_name2"]
            base_img_name = DockerImage.full_name_from_defaults(self.config)

            self.failif(
                base_img_name in self.sub_stuff['cmdresult'].stdout,
                "Unable find image name %s in image history: %s" %
                (base_img_name, self.sub_stuff['cmdresult'].stdout))

            self.failif(
                new_img_name in self.sub_stuff['cmdresult'].stdout,
                "Unable find image name %s in image history: %s" %
                (new_img_name, self.sub_stuff['cmdresult'].stdout))

            self.failif(
                new_img_name2 in self.sub_stuff['cmdresult'].stdout,
                "Unable find image name %s in image history: %s" %
                (new_img_name2, self.sub_stuff['cmdresult'].stdout))
Exemple #16
0
    def postprocess(self):
        super(history_base, self).postprocess()
        # Raise exception if problems found
        expect = self.config["docker_expected_exit_status"]
        OutputGood(self.sub_stuff['cmdresult'],
                   ignore_error=(expect != 0),
                   skip=['nonprintables_check'])
        self.failif_ne(self.sub_stuff['cmdresult'].exit_status, expect,
                       "Exit status")

        if expect == 0:
            new_img_name = self.sub_stuff["new_image_name"]
            new_img_name2 = self.sub_stuff["new_image_name2"]
            base_img_name = DockerImage.full_name_from_defaults(self.config)

            self.failif(
                base_img_name in self.sub_stuff['cmdresult'].stdout,
                "Unable find image name %s in image history: %s" %
                (base_img_name, self.sub_stuff['cmdresult'].stdout))

            self.failif(
                new_img_name in self.sub_stuff['cmdresult'].stdout,
                "Unable find image name %s in image history: %s" %
                (new_img_name, self.sub_stuff['cmdresult'].stdout))

            self.failif(
                new_img_name2 in self.sub_stuff['cmdresult'].stdout,
                "Unable find image name %s in image history: %s" %
                (new_img_name2, self.sub_stuff['cmdresult'].stdout))
Exemple #17
0
 def postprocess(self):
     # Raise exception on Go Panic or usage help message
     outputgood = OutputGood(self.stuff['cmdresult'])
     info_map = self._build_table(outputgood.stdout_strip)
     # Verify some individual items
     self.failif_ne(info_map['Storage Driver'].lower(), 'devicemapper',
                    'Storage Driver')
     self.failif_ne(info_map['Data file'].lower(), '', 'Data file')
     self.failif_ne(info_map['Metadata file'].lower(), '', 'Metadata file')
     di = DockerImages(self)
     # Make sure nothing is 'hidden'
     di.images_args = "%s --all" % di.images_args
     # Possible race-condition here...
     img_set = set(di.list_imgs_ids())  # don't count multi-tags
     # ...with this
     img_cnt = int(info_map['Images'].lower())
     self.failif_ne(
         len(img_set), img_cnt,
         "More/less images %d than info reported %d" %
         (len(img_set), img_cnt))
     # verify value of elements
     self.verify_pool_name(info_map['Pool Name'])
     data_name = 'Data loop file'
     metadata_name = 'Metadata loop file'
     if data_name in info_map:
         self.verify_sizes(info_map[data_name], info_map['Data Space Used'],
                           info_map['Data Space Total'],
                           info_map[metadata_name],
                           info_map['Metadata Space Used'],
                           info_map['Metadata Space Total'])
     else:
         data_name = 'Data file'
         metadata_name = 'Metadata file'
Exemple #18
0
 def postprocess(self):
     super(simple, self).postprocess()  # Prints out basic info
     # Fail test if bad command or other stdout/stderr problems detected
     cmdresult = self.sub_stuff['cmdresult']
     OutputGood(cmdresult)
     self.failif_ne(cmdresult.exit_status, 0,
                    "Problem with export import cmd detail :%s" % cmdresult)
Exemple #19
0
 def postprocess(self):
     super(login_fail, self).postprocess()
     cmdresult = self.sub_stuff['cmdresult']
     OutputGood(cmdresult, ignore_error=True)
     mustfail(cmdresult, 1)
     self.failif_not_in("401 Unauthorized", cmdresult.stderr,
                        "stderr from failed docker login")
Exemple #20
0
 def postprocess(self):
     super(delete_wrong_name, self).postprocess()
     # Raise exception if problems found
     OutputGood(self.sub_stuff['cmdresult'], ignore_error=True)
     self.failif_ne(self.sub_stuff['cmdresult'].exit_status,
                    self.config["docker_expected_exit_status"],
                    "Docker exit status")
Exemple #21
0
 def postprocess(self):
     super(delete_wrong_name, self).postprocess()
     # Raise exception if problems found
     OutputGood(self.sub_stuff['cmdresult'], ignore_error=True)
     if self.config["docker_expected_result"] == "FAIL":
         self.failif(self.sub_stuff['cmdresult'].exit_status == 0,
                     "Zero rmi exit status: Command should fail due to"
                     " wrong image name.")
Exemple #22
0
 def postprocess(self):
     super(login_ok, self).postprocess()
     cmdresult = self.sub_stuff['cmdresult']
     OutputGood(cmdresult)
     mustpass(cmdresult)
     self.failif_not_in("Login Succeeded", cmdresult.stdout,
                        "stdout from docker login")
     self._check_credentials()
Exemple #23
0
 def postprocess(self):
     super(file_volume, self).postprocess()
     cmdresult = self.sub_stuff['cmdresults'][0]
     OutputGood(cmdresult)
     regex = re.compile(self.config['regex'])
     self.failif(not regex.search(cmdresult.stdout),
                 "Fail match regex '%s' to: '%s'"
                 % (regex.pattern, cmdresult.stdout))
Exemple #24
0
    def postprocess(self):
        super(sig_proxy_off_base, self).postprocess()

        OutputGood(self.sub_stuff['cmdresult'])

        c_name = self.sub_stuff["rand_name"]
        containers = self.sub_stuff['cont'].list_containers_with_name(c_name)
        self.check_containers(containers)
 def postprocess(self):
     super(kill_base, self).postprocess()
     for kill_result in self.sub_stuff.get('kill_results', []):
         OutputGood(kill_result)
         self.failif(
             kill_result.exit_status != 0, "Exit status of the %s "
             "command was not 0 (%s)" %
             (kill_result.command, kill_result.exit_status))
Exemple #26
0
 def postprocess(self):
     super(version, self).postprocess()
     # Raise exception on Go Panic or usage help message
     outputgood = OutputGood(self.stuff['cmdresult'])
     docker_version = DockerVersion(outputgood.stdout_strip)
     self.loginfo("docker version client: %s server %s",
                  docker_version.client, docker_version.server)
     self.verify_version(docker_version)
Exemple #27
0
 def postprocess(self):
     dkrcmd_exec = self.sub_stuff['dkrcmd_exec']
     mustpass(dkrcmd_exec.cmdresult)
     OutputGood(dkrcmd_exec.cmdresult)
     pids = dkrcmd_exec.stdout.strip().splitlines()
     expected = self.config["pid_count"]
     self.failif_ne(len(pids), expected, "Number of pids: %s" % pids)
     super(exec_pid_count, self).postprocess()
    def postprocess(self):
        super(run_cgroup_parent_base, self).postprocess()

        cmdresult = self.sub_stuff["cmdresult"]
        expected_status = self.sub_stuff["expected_status"]
        OutputGood(cmdresult, ignore_error=(expected_status != 0),
                   skip=['nonprintables_check'])

        self.sub_stuff["cid"] = self._read_cid()
        path_exp = self.sub_stuff['expected_path'].format(**self.sub_stuff)
        stderr_exp = self.sub_stuff['expected_stderr'].format(**self.sub_stuff)

        # Check stderr first: that way if we're not expecting an error, but
        # get one, our user has a better chance of seeing something useful.
        # (Note: Running docker with -D (debug) produces lots of cruft:
        #    time="...." level=debug msg="unwanted stuff"
        # Strip them out.)
        stderr = "\n".join([line
                            for line in cmdresult.stderr.strip().split("\n")
                            if not line.startswith('time="')])
        if stderr_exp:
            re_stderr = re.compile(stderr_exp)
            if not re.match(re_stderr, stderr):
                raise DockerTestFail("expected '%s' not found in stderr ('%s')"
                                     % (stderr_exp, stderr))
        else:
            self.failif_ne(stderr, stderr_exp, "unexpected stderr")

        # If we're expecting stdout, it must contain multiple lines each
        # of the form:
        #    <num>:<cgroup controller>:<path>
        # ...where <path> must exactly match the one in our test setup.
        stdout = cmdresult.stdout.strip()
        if path_exp:
            re_cgroup = re.compile(r'^(\d+):([^:]*):(.*)')
            found_match = False
            for line in stdout.split("\n"):
                m = re.match(re_cgroup, line)
                if m is None:
                    raise DockerTestFail("cgroup line does not conform to"
                                         " '<n>:<controller>:<path>': '%s'"
                                         % line)
                # bz1385924: 'pids' fails in docker-1.10; not worth fixing.
                if m.group(2) == 'pids':
                    if DockerVersion().server.startswith("1.10"):
                        continue
                self.failif_ne(m.group(3), path_exp, "cgroup path for %s:%s"
                               % (m.group(1), m.group(2)))
                found_match = True

            # Must find at least one matching cgroup line
            if not found_match:
                raise DockerTestFail("No output from cgroups")
        else:
            self.failif_ne(stdout, '', "unexpected output on stdout")

        # Check exit code last: the stdout/stderr diagnostics are more helpful
        self.failif_ne(cmdresult.exit_status, expected_status, "exit status")
Exemple #29
0
 def postprocess(self):
     super(push_ok, self).postprocess()
     cmdresult = self.sub_stuff['pushresult']
     OutputGood(cmdresult)
     mustpass(cmdresult)
     self.failif_not_in(": Pushed", cmdresult.stdout,
                        "stdout from docker push")
     self.failif_not_in("tag_ok: digest:", cmdresult.stdout,
                        "stdout from docker push")
Exemple #30
0
 def postprocess(self):
     super(create_signal, self).postprocess()
     sigdkrcmd = self.sub_stuff['sigdkrcmd']
     OutputGood(sigdkrcmd)
     self.failif(sigdkrcmd.exit_status != 0,
                 "Signaling created container returnd non-zero")
     # On success, docker kill should echo back CID of container
     expected_cid = self.get_cid()
     returned_cid = self.get_cid(sigdkrcmd)
     self.failif(expected_cid != returned_cid,
                 "Container CID does not match kill --signal output")