Exemplo n.º 1
0
    def initialize(self):
        super(invalid_base, self).initialize()

        self.sub_stuff['tag'] = []
        self.sub_stuff['container_names'] = []

        self.sub_stuff['arg_inpars'] = []
        self.sub_stuff['arg_invals'] = []

        self.sub_stuff['result_inparam'] = False
        self.sub_stuff['result_invalus'] = False

        fin = []
        arg_inpars = []
        arg_invals = []

        config.none_if_empty(self.config)
        invalidparams = self.config['invalid_run_params']
        invalidvalues = self.config['invalid_run_values']

        for inp in invalidparams.split(','):
            arg_inpars.append(inp)

        for inv in invalidvalues.split(','):
            arg_invals.append(inv)

        if self.config['input_docker_tag']:
            fin = DockerImage.full_name_from_defaults(self.config)
            self.sub_stuff['tag'].append(fin)

        self.sub_stuff['arg_inpars'] = arg_inpars
        self.sub_stuff['arg_invals'] = arg_invals
Exemplo n.º 2
0
    def initialize(self):
        super(commit_base, self).initialize()
        config.none_if_empty(self.config)

        name_prefix = self.config["commit_repo_name_prefix"]
        new_img_name = "%s_%s" % (name_prefix,
                                  utils.generate_random_string(8))
        self.sub_stuff["new_image_name"] = new_img_name

        self.sub_stuff['rand_data'] = utils.generate_random_string(8)
        cmd_with_rand = (self.config['docker_data_prepare_cmd']
                         % self.sub_stuff['rand_data'])

        fqin = DockerImage.full_name_from_defaults(self.config)
        prep_changes = DockerCmd(self.parent_subtest, "run",
                                 ["--detach",
                                  fqin,
                                  cmd_with_rand],
                                 self.config['docker_commit_timeout'])

        results = prep_changes.execute()
        if results.exit_status:
            raise xceptions.DockerTestNAError("Problems during "
                                              "initialization of"
                                              " test: %s", results)
        else:
            self.sub_stuff["container"] = results.stdout.strip()
Exemplo n.º 3
0
    def initialize(self):
        super(restart_base, self).initialize()
        none_if_empty(self.config)

        bind_addr = self.config["docker_daemon_bind"]

        self.conts = DockerContainersE(self.parent_subtest)
        self.conts.interface.docker_daemon_bind = bind_addr

        self.dkr_cmd = DkrcmdFactory(self, dkrcmd_class=AsyncDockerCmdSpec)
        self.sub_stuff["image_name"] = None
        self.sub_stuff["container"] = None
        self.sub_stuff["containers"] = []

        # Necessary for avoid conflict with service manager. [docker.socket]
        docker_args = []
        docker_args += get_as_list(self.config["docker_daemon_args"])
        docker_args.append("-H %s" % bind_addr)
        if self.config.get("new_docker_graph_path"):
            self.sub_stuff["graph_path"] = os.path.join(self.tmpdir, "graph")
            docker_args.append("-g %s" % self.sub_stuff["graph_path"])

        self.sub_stuff["dd_args"] = docker_args

        self.loginfo("Starting %s %s", self.config["docker_path"], docker_args)
        dd = docker_daemon.start(self.config["docker_path"],
                                 docker_args)
        if not docker_daemon.output_match(dd):
            raise DockerTestNAError("Unable to start docker daemon:"
                                    "\n**STDOUT**:\n%s\n**STDERR**:\n%s" %
                                    (dd.get_stdout(), dd.get_stderr()))
        self.sub_stuff["docker_daemon"] = dd
Exemplo n.º 4
0
    def initialize(self):
        super(network_base, self).initialize()
        none_if_empty(self.config)

        bind_addr = self.config["docker_daemon_bind"]

        conts = DockerContainersE(self.parent_subtest)
        self.sub_stuff['conts'] = conts
        conts.interface.docker_daemon_bind = bind_addr
        self.dkr_cmd = DkrcmdFactory(self.parent_subtest,
                                     dkrcmd_class=AsyncDockerCmdSpec)
        self.sub_stuff["image_name"] = None
        self.sub_stuff["container"] = None
        self.sub_stuff["containers"] = []

        docker_args = []
        docker_args += get_as_list(self.config["docker_daemon_args"])
        docker_args.append("-H %s" % bind_addr)
        self.loginfo("Starting %s %s", self.config["docker_path"], docker_args)
        dd = docker_daemon.start(self.config["docker_path"],
                                 docker_args)
        if not docker_daemon.output_match(dd):
            raise DockerTestNAError("Unable to start docker daemon:"
                                    "\n**STDOUT**:\n%s\n**STDERR**:\n%s" %
                                    (dd.get_stdout(), dd.get_stderr()))
        self.sub_stuff["docker_daemon"] = dd
Exemplo n.º 5
0
 def initialize(self):
     super(simple, self).initialize()
     config.none_if_empty(self.config)
     # Get free name
     docker_containers = DockerContainers(self)
     name = docker_containers.get_unique_name()
     self.sub_stuff['container_name'] = name
Exemplo n.º 6
0
 def initialize(self):
     super(stop_base, self).initialize()
     # Prepare a container
     docker_containers = DockerContainers(self.parent_subtest)
     prefix = self.config["stop_name_prefix"]
     name = docker_containers.get_unique_name(prefix, length=4)
     self.sub_stuff['container_name'] = name
     config.none_if_empty(self.config)
     if self.config.get('run_options_csv'):
         subargs = [arg for arg in
                    self.config['run_options_csv'].split(',')]
     subargs.append("--name %s" % name)
     fin = DockerImage.full_name_from_defaults(self.config)
     subargs.append(fin)
     subargs.append("bash")
     subargs.append("-c")
     subargs.append(self.config['exec_cmd'])
     container = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['container_cmd'] = container
     container.execute()
     time.sleep(self.config['wait_start'])
     # Prepare the "stop" command
     if self.config.get('stop_options_csv'):
         subargs = [arg for arg in
                    self.config['stop_options_csv'].split(',')]
     subargs.append(name)
     self.sub_stuff['stop_cmd'] = DockerCmd(self, 'stop', subargs)
Exemplo n.º 7
0
    def initialize(self):
        super(history_base, self).initialize()
        config.none_if_empty(self.config)
        dimgs = DockerImages(self.parent_subtest)

        self.sub_stuff["containers"] = []
        self.sub_stuff["images"] = []

        new_img_name = dimgs.get_unique_name('1')
        self.sub_stuff["new_image_name"] = new_img_name

        new_img_name2 = dimgs.get_unique_name('2')
        self.sub_stuff["new_image_name2"] = new_img_name2

        self.sub_stuff['rand_data'] = utils.generate_random_string(8)
        cmd_with_rand = (self.config['docker_data_prepare_cmd']
                         % self.sub_stuff['rand_data'])

        fqin = DockerImage.full_name_from_defaults(self.config)
        # create new image in history
        self.create_image(fqin, new_img_name, cmd_with_rand)
        self.sub_stuff["images"].append(new_img_name)
        # create new image in history
        self.create_image(new_img_name, new_img_name2, cmd_with_rand)
        self.sub_stuff["images"].append(new_img_name2)
Exemplo n.º 8
0
    def initialize(self):
        super(history_base, self).initialize()
        config.none_if_empty(self.config)

        self.sub_stuff["containers"] = []
        self.sub_stuff["images"] = []

        name_prefix = self.config["history_repo_name_prefix"]
        new_img_name = "%s_%s" % (name_prefix,
                                  utils.generate_random_string(8).lower())
        self.sub_stuff["new_image_name"] = new_img_name

        new_img_name2 = "%s_%s" % (name_prefix,
                                   utils.generate_random_string(8).lower())
        self.sub_stuff["new_image_name2"] = new_img_name2

        self.sub_stuff['rand_data'] = utils.generate_random_string(8)
        cmd_with_rand = (self.config['docker_data_prepare_cmd']
                         % self.sub_stuff['rand_data'])

        fqin = DockerImage.full_name_from_defaults(self.config)
        # create new image in history
        self.create_image(fqin, new_img_name, cmd_with_rand)
        self.sub_stuff["images"].append(new_img_name)
        # create new image in history
        self.create_image(new_img_name, new_img_name2, cmd_with_rand)
        self.sub_stuff["images"].append(new_img_name2)
Exemplo n.º 9
0
 def initialize(self):
     """
     Execute 6 variants of the same 'docker run -a' command and store
     the results.
     variants:
       - tty
       - nontty
     variants:
       - stdin (execute bash, put 'ls /\n exit\n' on stdin)
       - stdout (execute ls /)
       - stderr (execute ls /nonexisting/directory/...)
     """
     super(run_attach_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self.parent_subtest)
     self.sub_stuff['containers'] = []
     self._init_test_depenent()
     for tty in (True, False):   # generate matrix of tested variants
         # interactive container
         cont = self._init_container(tty, 'bash', 'ls /\nexit\n')
         self.sub_stuff['res_stdin_%s' % tty] = cont
         # stdout container
         cont = self._init_container(tty, 'ls /')
         self.sub_stuff['res_stdout_%s' % tty] = cont
         # stderr container
         cont = self._init_container(tty,
                                     'ls /I/hope/this/does/not/exist/%s'
                                     % utils.generate_random_string(6))
         self.sub_stuff['res_stderr_%s' % tty] = cont
Exemplo n.º 10
0
 def initialize(self):
     """
     Execute 6 variants of the same 'docker run -a' command and store
     the results.
     variants:
       - tty
       - nontty
     variants:
       - stdin (execute bash, put 'ls /\n exit\n' on stdin)
       - stdout (execute ls /)
       - stderr (execute ls /nonexisting/directory/...)
     """
     super(run_attach_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
     self._init_test_dependent()
     # TODO: Test w/ tty=True when some DockerCmd class supports pty
     # for tty in (True, False):   # generate matrix of tested variants
     tty = False
     # interactive container
     cont = self._init_container(tty, 'bash', 'ls /\nexit\n')
     self.sub_stuff['res_stdin_%s' % tty] = cont
     # stdout container
     cont = self._init_container(tty, 'ls /')
     self.sub_stuff['res_stdout_%s' % tty] = cont
     # stderr container
     cont = self._init_container(
         tty, 'ls /I/hope/this/does/not/exist/%s' %
         utils.generate_random_string(6))
     self.sub_stuff['res_stderr_%s' % tty] = cont
Exemplo n.º 11
0
    def initialize(self):
        super(history_base, self).initialize()
        config.none_if_empty(self.config)
        dimgs = DockerImages(self)

        self.sub_stuff["containers"] = []
        self.sub_stuff["images"] = []

        new_img_name = dimgs.get_unique_name('1')
        self.sub_stuff["new_image_name"] = new_img_name

        new_img_name2 = dimgs.get_unique_name('2')
        self.sub_stuff["new_image_name2"] = new_img_name2

        self.sub_stuff['rand_data'] = utils.generate_random_string(8)
        cmd_with_rand = (self.config['docker_data_prepare_cmd'] %
                         self.sub_stuff['rand_data'])

        fqin = DockerImage.full_name_from_defaults(self.config)
        # create new image in history
        self.create_image(fqin, new_img_name, cmd_with_rand)
        self.sub_stuff["images"].append(new_img_name)
        # create new image in history
        self.create_image(new_img_name, new_img_name2, cmd_with_rand)
        self.sub_stuff["images"].append(new_img_name2)
Exemplo n.º 12
0
    def initialize(self):
        super(tag_base, self).initialize()
        config.none_if_empty(self.config)

        di = DockerImages(self.parent_subtest)
        di.gen_lower_only = self.config['gen_lower_only']
        name_prefix = self.config["tag_repo_name_prefix"]
        new_img_name = di.get_unique_name(name_prefix)
        while self.check_image_exists(new_img_name):
            new_img_name = "%s_%s" % (name_prefix,
                                  utils.generate_random_string(8))

        self.sub_stuff["image"] = new_img_name
        base_image = DockerImage.full_name_from_defaults(self.config)

        prep_changes = DockerCmd(self.parent_subtest, "tag",
                                 [base_image,
                                  self.sub_stuff["image"]],
                                 self.config['docker_tag_timeout'])

        results = prep_changes.execute()
        if results.exit_status:
            raise xceptions.DockerTestNAError("Problems during "
                                              "initialization of"
                                              " test: %s", results)

        im = self.check_image_exists(self.sub_stuff["image"])
        self.sub_stuff['image_list'] = im
Exemplo n.º 13
0
    def initialize(self):
        super(stop_base, self).initialize()
        # Prepare a container
        docker_containers = DockerContainers(self)
        name = docker_containers.get_unique_name()
        self.sub_stuff['container_name'] = name
        config.none_if_empty(self.config)
        if self.config.get('run_options_csv'):
            subargs = [
                arg for arg in self.config['run_options_csv'].split(',')
            ]
        subargs.append("--name %s" % name)
        fin = DockerImage.full_name_from_defaults(self.config)
        subargs.append(fin)
        subargs.append("bash")
        subargs.append("-c")
        subargs.append(self.config['exec_cmd'])

        container = AsyncDockerCmd(self, 'run', subargs)
        self.sub_stuff['container_cmd'] = container
        container.execute()
        container.wait_for_ready()
        # Prepare the "stop" command
        if self.config.get('stop_options_csv'):
            subargs = [
                arg for arg in self.config['stop_options_csv'].split(',')
            ]
        subargs.append(name)
        self.sub_stuff['stop_cmd'] = DockerCmd(self, 'stop', subargs)
Exemplo n.º 14
0
 def initialize(self):
     super(tag_base, self).initialize()
     config.none_if_empty(self.config)
     self.dkrimg.gen_lower_only = self.config['gen_lower_only']
     new_img_name = self.dkrimg.get_unique_name()
     self.sub_stuff["image"] = new_img_name
     base_image = DockerImage.full_name_from_defaults(self.config)
     self.prep_image(base_image)
Exemplo n.º 15
0
 def initialize(self):
     super(tag_base, self).initialize()
     config.none_if_empty(self.config)
     self.dkrimg.gen_lower_only = self.config['gen_lower_only']
     new_img_name = self.dkrimg.get_unique_name()
     self.sub_stuff["image"] = new_img_name
     base_image = DockerImage.full_name_from_defaults(self.config)
     self.prep_image(base_image)
Exemplo n.º 16
0
 def initialize(self):
     super(images_all_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['di'] = DockerImages(self)
     self.sub_stuff['containers'] = []
     self.sub_stuff['images'] = []
Exemplo n.º 17
0
 def initialize(self):
     super(images_all_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self.parent_subtest)
     self.sub_stuff['di'] = DockerImages(self.parent_subtest)
     self.sub_stuff['containers'] = []
     self.sub_stuff['images'] = []
Exemplo n.º 18
0
 def initialize(self):
     """
     Runs one container
     """
     super(basic, self).initialize()
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
     self.sub_stuff['cidfiles'] = set()
Exemplo n.º 19
0
    def initialize(self):
        super(start_base, self).initialize()
        config.none_if_empty(self.config)
        self.sub_stuff["conts_obj"] = DockerContainers(self)
        self.sub_stuff["con_ro_obj"] = DockerContainersRunOnly(self)

        self.sub_stuff["image_name"] = None
        self.sub_stuff["container"] = None
        self.sub_stuff["containers"] = []
Exemplo n.º 20
0
 def initialize(self):
     super(simple, self).initialize()
     self._init_stuff()
     config.none_if_empty(self.config)
     # Get free name
     prefix = self.config["container_name_prefix"]
     docker_containers = DockerContainers(self.parent_subtest)
     name = docker_containers.get_unique_name(prefix, length=4)
     self.sub_stuff['container_name'] = name
Exemplo n.º 21
0
 def initialize(self):
     """
     Runs one container
     """
     super(basic, self).initialize()
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
     self.sub_stuff['cidfiles'] = set()
Exemplo n.º 22
0
    def initialize(self):
        super(start_base, self).initialize()
        config.none_if_empty(self.config)
        self.sub_stuff["conts_obj"] = DockerContainers(self)
        self.sub_stuff["con_ro_obj"] = DockerContainersRunOnly(self)

        self.sub_stuff["image_name"] = None
        self.sub_stuff["container"] = None
        self.sub_stuff["containers"] = []
Exemplo n.º 23
0
    def initialize(self):
        super(start_base, self).initialize()
        config.none_if_empty(self.config)
        dc = DockerContainersCLIWithOutSize(self.parent_subtest)
        self.sub_stuff["conts_obj"] = dc
        dc = DockerContainersCLIRunOnly(self.parent_subtest)
        self.sub_stuff["con_ro_obj"] = dc

        self.sub_stuff["image_name"] = None
        self.sub_stuff["container"] = None
        self.sub_stuff["containers"] = []
Exemplo n.º 24
0
 def initialize(self):
     """
     Runs one container
     """
     super(run_user_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self._init_test_depenent()
     self._init_container(self.sub_stuff['subargs'],
                          self.config['exec_cmd'])
Exemplo n.º 25
0
 def initialize(self):
     """
     Runs one container
     """
     super(run_user_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self._init_test_depenent()
     self._init_container(self.sub_stuff['subargs'],
                          self.config['exec_cmd'])
Exemplo n.º 26
0
 def initialize(self):
     """
     Runs one container
     """
     super(kill_bad_base, self).initialize()
     config.none_if_empty(self.config)
     # Prepare a container
     docker_containers = DockerContainers(self)
     name = docker_containers.get_unique_name()
     self.sub_stuff['container_name'] = name
     self._init_container(name)
     time.sleep(self.config.get('wait_start', 3))
Exemplo n.º 27
0
 def initialize(self):
     """
     Runs one container
     """
     super(kill_bad_base, self).initialize()
     # Prepare a container
     docker_containers = DockerContainers(self.parent_subtest)
     name = docker_containers.get_unique_name()
     self.sub_stuff['container_name'] = name
     config.none_if_empty(self.config)
     self._init_container(name)
     time.sleep(self.config.get('wait_start', 3))
Exemplo n.º 28
0
    def initialize(self):
        super(wait_base, self).initialize()
        config.none_if_empty(self.config)
        self.init_substuff()

        # Container
        for name in self.config['containers'].split():
            self.init_container(name)

        self.init_use_names(self.config.get('use_names', False))

        # Prepare the "wait" command
        self.prep_wait_cmd(self.config.get('wait_options_csv'))
 def initialize(self):
     """
     Runs one container
     """
     super(selinux_base, self).initialize()
     if utils.run("selinuxenabled", 10, True).exit_status:
         raise xceptions.DockerTestNAError("Selinux not enabled on this "
                                           "machine.")
     # Substuff
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
     self.sub_stuff['volumes'] = set()
     self.sub_stuff['fds'] = []
Exemplo n.º 30
0
    def initialize(self):
        super(restart_base, self).initialize()
        config.none_if_empty(self.config)
        self.sub_stuff['container_id'] = None
        self.sub_stuff['restart_cmd'] = None
        self.sub_stuff['stop_cmd'] = None
        self.sub_stuff['restart_result'] = None
        self.sub_stuff['stop_result'] = None

        containers = DockerContainers(self)

        # Container
        if self.config.get('run_options_csv'):
            subargs = [
                arg for arg in self.config['run_options_csv'].split(',')
            ]
        else:
            subargs = []
        image = DockerImage.full_name_from_defaults(self.config)
        subargs.append(image)
        subargs.append("bash")
        subargs.append("-c")
        subargs.append(self.config['exec_cmd'])
        container = DockerCmd(self, 'run', subargs, timeout=240)
        cont_id = mustpass(container.execute()).stdout.strip()
        self.sub_stuff['container_id'] = cont_id
        container = containers.list_containers_with_cid(cont_id)
        if container == []:
            raise xceptions.DockerTestNAError(
                "Fail to get docker with id: %s" % cont_id)

        # Prepare the "restart" command
        if self.config.get('restart_options_csv'):
            subargs = [
                arg for arg in self.config['restart_options_csv'].split(',')
            ]
        else:
            subargs = []
        subargs.append(cont_id)
        self.sub_stuff['restart_cmd'] = DockerCmd(self, 'restart', subargs)

        # Prepare the "stop" command
        if self.config.get('stop_options_csv'):
            subargs = [
                arg for arg in self.config['stop_options_csv'].split(',')
            ]
        else:
            subargs = []
        subargs.append(cont_id)
        self.sub_stuff['stop_cmd'] = DockerCmd(self, 'stop', subargs)
Exemplo n.º 31
0
 def initialize(self):
     """
     Runs one container
     """
     super(selinux_base, self).initialize()
     if utils.run("selinuxenabled", 10, True).exit_status:
         raise xceptions.DockerTestNAError("Selinux not enabled on this "
                                           "machine.")
     # Substuff
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
     self.sub_stuff['volumes'] = set()
     self.sub_stuff['fds'] = []
Exemplo n.º 32
0
    def initialize(self):
        super(restart_base, self).initialize()
        config.none_if_empty(self.config)
        self.sub_stuff['container_id'] = None
        self.sub_stuff['restart_cmd'] = None
        self.sub_stuff['stop_cmd'] = None
        self.sub_stuff['restart_result'] = None
        self.sub_stuff['stop_result'] = None

        containers = DockerContainers(self.parent_subtest)

        # Container
        if self.config.get('run_options_csv'):
            subargs = [arg for arg in
                       self.config['run_options_csv'].split(',')]
        else:
            subargs = []
        image = DockerImage.full_name_from_defaults(self.config)
        subargs.append(image)
        subargs.append("bash")
        subargs.append("-c")
        subargs.append(self.config['exec_cmd'])
        container = NoFailDockerCmd(self, 'run', subargs)
        cont_id = container.execute().stdout.strip()
        self.sub_stuff['container_id'] = cont_id
        container = containers.list_containers_with_cid(cont_id)
        if container == []:
            raise xceptions.DockerTestNAError("Fail to get docker with id: %s"
                                              % cont_id)

        # Prepare the "restart" command
        if self.config.get('restart_options_csv'):
            subargs = [arg for arg in
                       self.config['restart_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(cont_id)
        self.sub_stuff['restart_cmd'] = NoFailDockerCmd(self, 'restart',
                                                        subargs)

        # Prepare the "stop" command
        if self.config.get('stop_options_csv'):
            subargs = [arg for arg in
                       self.config['stop_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(cont_id)
        self.sub_stuff['stop_cmd'] = NoFailDockerCmd(self, 'stop', subargs)
Exemplo n.º 33
0
    def initialize(self):
        super(tls_base, self).initialize()
        none_if_empty(self.config)
        os.chdir(self.parent_subtest.tmpdir)

        bind_addr = self.config["docker_client_bind"]
        dos = " ".join(get_as_list(self.config['docker_options_spec']))

        self.conts = DockerContainersE(self.parent_subtest,
                                       interface_name="cli_spec")
        self.conts.interface.docker_client_bind = bind_addr
        self.conts.interface.docker_options_spec = dos

        self.dkr_cmd = DkrcmdFactory(self, dkrcmd_class=AsyncDockerCmdSpec)
        self.sub_stuff["image_name"] = None
        self.sub_stuff["container"] = None
        self.sub_stuff["containers"] = []
        self.sub_stuff["docker_daemon"] = None
Exemplo n.º 34
0
    def initialize(self):
        super(tag_base, self).initialize()
        config.none_if_empty(self.config)

        di = DockerImages(self.parent_subtest)
        di.gen_lower_only = self.config['gen_lower_only']
        name_prefix = self.config["tag_repo_name_prefix"]
        new_img_name = di.get_unique_name(name_prefix)
        while self.check_image_exists(new_img_name):
            new_img_name = "%s_%s" % (name_prefix,
                                      utils.generate_random_string(8))
        if self.config['gen_lower_only']:
            new_img_name = new_img_name.lower()
        else:
            new_img_name += '_UP'  # guarantee some upper-case
        self.sub_stuff["image"] = new_img_name
        base_image = DockerImage.full_name_from_defaults(self.config)
        self.prep_image(base_image)
Exemplo n.º 35
0
    def initialize(self):
        super(commit_base, self).initialize()
        config.none_if_empty(self.config)
        di = DockerImages(self)
        new_img_name = di.get_unique_name()
        cname = DockerContainers(self).get_unique_name()
        self.sub_stuff["new_image_name"] = new_img_name

        self.sub_stuff["rand_data"] = utils.generate_random_string(8)
        cmd_with_rand = self.config["docker_data_prepare_cmd"] % self.sub_stuff["rand_data"]

        fqin = DockerImage.full_name_from_defaults(self.config)
        prep_changes = DockerCmd(
            self, "run", ["--name=%s" % cname, fqin, cmd_with_rand], self.config["docker_commit_timeout"]
        )

        results = prep_changes.execute()
        if results.exit_status:
            raise xceptions.DockerTestNAError("Problems during " "initialization of" " test: %s", results)
        self.sub_stuff["container"] = cname
Exemplo n.º 36
0
    def initialize(self):
        super(kill_base, self).initialize()
        # Prepare a container
        docker_containers = DockerContainers(self)
        name = docker_containers.get_unique_name("test", length=4)
        self.sub_stuff["container_name"] = name
        config.none_if_empty(self.config)
        if self.config.get("run_container_attached"):
            self._init_container_attached(name)
        else:
            self._init_container_normal(name)

        time.sleep(self.config["wait_start"])

        # Prepare the "kill" command
        if self.config.get("kill_options_csv"):
            subargs = [arg for arg in self.config["kill_options_csv"].split(",")]
        else:
            subargs = []
        subargs.append(name)
        self._populate_kill_cmds(subargs)
Exemplo n.º 37
0
 def initialize(self):
     super(sigproxy_base, self).initialize()
     self.init_test_specific_variables()
     self.sub_stuff['container_name'] = None     # tested container name
     self.sub_stuff['container_cmd'] = None      # tested container cmd
     self.sub_stuff['kill_signals'] = None        # testing kill signal
     self.sub_stuff['negative_test'] = None      # sigproxy enabled/disabled
     self.sub_stuff['check_stdout'] = self.config['check_stdout']
     config.none_if_empty(self.config)
     # Prepare a container
     docker_containers = DockerContainers(self)
     name = docker_containers.get_unique_name()
     self.sub_stuff['container_name'] = name
     if self.sub_stuff['attached']:
         self._init_container_attached(name)
     else:
         self._init_container_normal(name)
     time.sleep(self.config['wait_start'])
     # Prepare the "sigproxy" command
     kill_sigs = [int(sig) for sig in self.config['kill_signals'].split()]
     self.sub_stuff['kill_signals'] = kill_sigs
     self.sub_stuff['negative_test'] = self.config.get('negative_test')
Exemplo n.º 38
0
 def initialize(self):
     super(sigproxy_base, self).initialize()
     self.init_test_specific_variables()
     self.sub_stuff['container_name'] = None  # tested container name
     self.sub_stuff['container_cmd'] = None  # tested container cmd
     self.sub_stuff['kill_signals'] = None  # testing kill signal
     self.sub_stuff['negative_test'] = None  # sigproxy enabled/disabled
     self.sub_stuff['check_stdout'] = self.config['check_stdout']
     config.none_if_empty(self.config)
     # Prepare a container
     docker_containers = DockerContainers(self)
     name = docker_containers.get_unique_name()
     self.sub_stuff['container_name'] = name
     if self.sub_stuff['attached']:
         self._init_container_attached(name)
     else:
         self._init_container_normal(name)
     time.sleep(self.config['wait_start'])
     # Prepare the "sigproxy" command
     kill_sigs = [int(sig) for sig in self.config['kill_signals'].split()]
     self.sub_stuff['kill_signals'] = kill_sigs
     self.sub_stuff['negative_test'] = self.config.get('negative_test')
Exemplo n.º 39
0
 def initialize(self):
     super(sigproxy_base, self).initialize()
     self.init_test_specific_variables()
     self.sub_stuff["container_name"] = None  # tested container name
     self.sub_stuff["container_cmd"] = None  # tested container cmd
     self.sub_stuff["kill_signals"] = None  # testing kill signal
     self.sub_stuff["negative_test"] = None  # sigproxy enabled/disabled
     self.sub_stuff["check_stdout"] = self.config["check_stdout"]
     config.none_if_empty(self.config)
     # Prepare a container
     docker_containers = DockerContainers(self)
     name = docker_containers.get_unique_name()
     self.sub_stuff["container_name"] = name
     if self.sub_stuff["attached"]:
         self._init_container_attached(name)
     else:
         self._init_container_normal(name)
     self._wait_for_ready()
     # Prepare the "sigproxy" command
     kill_sigs = [int(sig) for sig in self.config["kill_signals"].split()]
     self.sub_stuff["kill_signals"] = kill_sigs
     self.sub_stuff["negative_test"] = self.config.get("negative_test")
Exemplo n.º 40
0
    def initialize(self):
        super(kill_base, self).initialize()
        # Prepare a container
        docker_containers = DockerContainers(self)
        name = docker_containers.get_unique_name("test", length=4)
        self.sub_stuff['container_name'] = name
        config.none_if_empty(self.config)
        if self.config.get('run_container_attached'):
            self._init_container_attached(name)
        else:
            self._init_container_normal(name)

        cmd = self.sub_stuff['container_cmd']
        cmd.wait_for_ready()

        # Prepare the "kill" command
        if self.config.get('kill_options_csv'):
            subargs = [arg for arg in
                       self.config['kill_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(name)
        self._populate_kill_cmds(subargs)
Exemplo n.º 41
0
    def initialize(self):
        super(commit_base, self).initialize()
        config.none_if_empty(self.config)
        di = DockerImages(self)
        new_img_name = di.get_unique_name()
        self.sub_stuff["new_image_name"] = new_img_name

        self.sub_stuff['rand_data'] = utils.generate_random_string(8)
        cmd_with_rand = (self.config['docker_data_prepare_cmd'] %
                         self.sub_stuff['rand_data'])

        fqin = DockerImage.full_name_from_defaults(self.config)
        prep_changes = DockerCmd(self, "run",
                                 ["--detach", fqin, cmd_with_rand],
                                 self.config['docker_commit_timeout'])

        results = prep_changes.execute()
        if results.exit_status:
            raise xceptions.DockerTestNAError(
                "Problems during "
                "initialization of"
                " test: %s", results)
        else:
            self.sub_stuff["container"] = results.stdout.strip()
Exemplo n.º 42
0
 def initialize(self):
     super(top, self).initialize()
     self._init_stuff()
     config.none_if_empty(self.config)
     self._init_container()
Exemplo n.º 43
0
 def initialize(self):
     super(run_env_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
Exemplo n.º 44
0
 def initialize(self):
     super(ps_size_base, self).initialize()
     # Prepare a container
     config.none_if_empty(self.config)
     self.sub_stuff['dc'] = DockerContainers(self)
     self.sub_stuff['containers'] = []
Exemplo n.º 45
0
 def initialize(self):
     super(rmi_base, self).initialize()
     config.none_if_empty(self.config)
     self.sub_stuff["image_name"] = None
     self.sub_stuff["containers"] = []
Exemplo n.º 46
0
 def initialize(self):
     super(rmi_base, self).initialize()
     config.none_if_empty(self.config)
     self.sub_stuff["image_name"] = None
     self.sub_stuff["containers"] = []