Exemple #1
0
    def initialize(self):
        super(simple_base, self).initialize()
        rand_name = utils.generate_random_string(8)
        self.sub_stuff["rand_name"] = rand_name
        self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)

        run_in_pipe_r, run_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(run_in_pipe_r)
        self.sub_stuff['file_desc'].append(run_in_pipe_w)
        self.sub_stuff["run_in_pipe_w"] = run_in_pipe_w
        dkrcmd = AsyncDockerCmd(self.parent_subtest, 'run',
                                self.sub_stuff['subargs'],
                                verbose=True)

        # Runs in background
        self.sub_stuff['cmdresult'] = dkrcmd.execute(run_in_pipe_r)
        self.sub_stuff['cmd_run'] = dkrcmd
        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("Detail after waiting: %s", dkrcmd)

        attach_options = self.config['attach_options_csv'].split(',')
        self.sub_stuff['subargs_a'] = attach_options

        c_name = self.sub_stuff["rand_name"]
        self.sub_stuff["containers"].append(c_name)
        cid = self.sub_stuff["cont"].list_containers_with_name(c_name)

        self.failif(cid == [],
                    "Unable to search container with name %s" % (c_name))
Exemple #2
0
    def run_once(self):
        super(simple_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds",
                     self.config['docker_timeout'])

        attach_in_pipe_r, attach_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(attach_in_pipe_r)
        self.sub_stuff['file_desc'].append(attach_in_pipe_w)

        self.sub_stuff['subargs_a'].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self.parent_subtest, 'attach',
                                self.sub_stuff['subargs_a'],
                                verbose=True)
        # Runs in background
        self.sub_stuff['cmd_attach'] = dkrcmd
        self.sub_stuff['cmdresult_attach'] = dkrcmd.execute(attach_in_pipe_r)
        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("Before input should be ignored: %s", dkrcmd)

        # This input should be ignored.
        os.write(self.sub_stuff["run_in_pipe_w"],
                 self.config['interactive_cmd_run'] + "\n")

        dkrcmd.update_result()
        self.logdebug("Before input should be passed: %s", dkrcmd)
        # This input should be passed to container.
        os.write(attach_in_pipe_w,
                 self.config['interactive_cmd_attach'] + "\n")

        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("After input was passsed: %s", dkrcmd)
Exemple #3
0
    def run_once(self):
        super(sig_proxy_off_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds",
                     self.config['docker_timeout'])

        self.sub_stuff['subargs_a'].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self.parent_subtest, 'attach',
                                self.sub_stuff['subargs_a'],
                                verbose=True)
        # Runs in background
        self.sub_stuff['cmd_attach'] = dkrcmd
        self.sub_stuff['cmdresult_attach'] = dkrcmd.execute()

        self.wait_interactive_cmd()
        dkrcmd.update_result()

        pid = dkrcmd.process_id
        os.kill(pid, int(self.config["signal"]))

        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("After the killing: %s", dkrcmd)