Exemplo n.º 1
0
    def make_runpath_dirs(self):
        """
        Creates runpath related directories.
        """
        if self._runpath is None:
            raise RuntimeError(
                "{} runpath cannot be None".format(self.__class__.__name__)
            )

        self.logger.test_info(
            f"Testplan has runpath: {self._runpath} and pid {os.getpid()}"
        )

        self._scratch = os.path.join(self._runpath, "scratch")

        if self.cfg.path_cleanup is False:
            makedirs(self._runpath)
            makedirs(self._scratch)
        else:
            makeemptydirs(self._runpath)
            makeemptydirs(self._scratch)

        with open(
            os.path.join(self._runpath, self.runid_filename), "wb"
        ) as fp:
            pass
Exemplo n.º 2
0
 def pre_start(self):
     super(KafkaStandalone, self).pre_start()
     self.log_path = os.path.join(self.runpath, "log")
     self.etc_path = os.path.join(self.runpath, "etc")
     for directory in (self.log_path, self.etc_path):
         if self.cfg.path_cleanup is False:
             makedirs(directory)
         else:
             makeemptydirs(directory)
     self.config = os.path.join(self.runpath, "etc", "server.properties")
     instantiate(self.cfg.cfg_template, self.context_input(), self.config)
Exemplo n.º 3
0
    def test_attach_dir(self, tmpdir):
        """UT for result.attach method."""
        path_utils.makeemptydirs(str(tmpdir.join("subdir")))

        tmpfile1 = str(tmpdir.join("1.txt"))
        with open(tmpfile1, "w") as f:
            f.write("testplan\n" * 10)

        tmpfile2 = str(tmpdir.join("2.txt"))
        with open(tmpfile2, "w") as f:
            f.write("testplan\n")

        tmpfile3 = str(tmpdir.join("subdir").join("3.txt"))
        with open(tmpfile3, "w") as f:
            f.write("testplan\n" * 100)

        tmpfile4 = str(tmpdir.join("subdir").join("4.txt"))
        with open(tmpfile4, "w") as f:
            f.write("testplan\n" * 1000)

        result = result_mod.Result()

        assert result.attach(str(tmpdir), description="Attach a directory")
        assert len(result.entries) == 1
        directory_entry = result.entries[0]

        assert directory_entry.source_path == str(tmpdir)
        assert (directory_entry.dst_path == hashlib.md5(
            directory_entry.source_path.encode("utf-8")).hexdigest())
        assert sorted(directory_entry.file_list) == ["1.txt", "2.txt"]

        assert result.attach(
            str(tmpdir),
            description="Attach a directory with filters",
            ignore=["2.*"],
            only=["*.txt"],
            recursive=True,
        )
        assert len(result.entries) == 2
        directory_entry = result.entries[1]

        assert directory_entry.source_path == str(tmpdir)
        assert (directory_entry.dst_path == hashlib.md5(
            directory_entry.source_path.encode("utf-8")).hexdigest())
        assert sorted([
            file.replace("\\", "/") for file in directory_entry.file_list
        ]) == [
            "1.txt",
            "subdir/3.txt",
            "subdir/4.txt",
        ]
Exemplo n.º 4
0
    def make_runpath_dirs(self):
        """
        Creates runpath related directories.
        """
        self._runpath = self.generate_runpath()
        self._scratch = os.path.join(self._runpath, "scratch")
        if self.runpath is None:
            raise RuntimeError("{} runpath cannot be None".format(
                self.__class__.__name__))
        self.logger.debug("{} has {} runpath and pid {}".format(
            self.__class__.__name__, self.runpath, os.getpid()))

        if self.cfg.path_cleanup is False:
            makedirs(self._runpath)
            makedirs(self._scratch)
        else:
            makeemptydirs(self._runpath)
            makeemptydirs(self._scratch)
Exemplo n.º 5
0
 def pre_start(self):
     """
     Create mandatory directories and install files from given templates
     using the drivers context before starting zookeeper.
     """
     super(ZookeeperStandalone, self).pre_start()
     self.zkdata_path = os.path.join(self.runpath, "zkdata")
     self.zklog_path = os.path.join(self.runpath, "zklog")
     self.etc_path = os.path.join(self.runpath, "etc")
     self.env["ZOO_LOG_DIR"] = self.zklog_path
     for directory in (self.zkdata_path, self.zklog_path, self.etc_path):
         if self.cfg.path_cleanup is False:
             makedirs(directory)
         else:
             makeemptydirs(directory)
     self.config = os.path.join(self.runpath, "etc", "zookeeper.cfg")
     if self.port == 0:
         raise RuntimeError("Zookeeper doesn't support random port")
     instantiate(self.cfg.cfg_template, self.context_input(), self.config)
Exemplo n.º 6
0
    def make_runpath_dirs(self):
        """
        Creates runpath related directories.
        """
        self.define_runpath()
        if self._runpath is None:
            raise RuntimeError(
                f"{self.__class__.__name__} runpath cannot be None")

        self._scratch = os.path.join(self._runpath, "scratch")

        self.logger.debug("%s has %s runpath and pid %d", self, self.runpath,
                          os.getpid())

        if self.cfg.path_cleanup is False:
            makedirs(self._runpath)
            makedirs(self._scratch)
        else:
            makeemptydirs(self._runpath)
            makeemptydirs(self._scratch)