From 8d247047469210494286261be954313594021aa8 Mon Sep 17 00:00:00 2001 From: Robert Nemes Date: Thu, 6 Jun 2024 09:29:15 +0100 Subject: [PATCH 1/2] Made install_files invoked automatically for Driver objects --- doc/newsfragments/2878_changed.driver_install_files.rst | 1 + testplan/testing/multitest/driver/base.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 doc/newsfragments/2878_changed.driver_install_files.rst diff --git a/doc/newsfragments/2878_changed.driver_install_files.rst b/doc/newsfragments/2878_changed.driver_install_files.rst new file mode 100644 index 000000000..a780e7838 --- /dev/null +++ b/doc/newsfragments/2878_changed.driver_install_files.rst @@ -0,0 +1 @@ +Users can now use :py:meth:`install_files ` method with Driver objects to copy files over to a specified location during environment startup. \ No newline at end of file diff --git a/testplan/testing/multitest/driver/base.py b/testplan/testing/multitest/driver/base.py index 23e0c2db9..b4f2c4a48 100644 --- a/testplan/testing/multitest/driver/base.py +++ b/testplan/testing/multitest/driver/base.py @@ -215,6 +215,9 @@ def pre_start(self) -> None: """Steps to be executed right before resource starts.""" self.make_runpath_dirs() + if self.cfg.install_files: + self.install_files() + @property def started_check_interval(self) -> PollInterval: """ From 77792c78fab9e5e432040eb58032d23102ac292b Mon Sep 17 00:00:00 2001 From: Robert Nemes Date: Fri, 7 Jun 2024 08:54:18 +0100 Subject: [PATCH 2/2] Moved runpath directory creation to make_runpath_dirs() --- testplan/testing/multitest/driver/app.py | 25 +++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/testplan/testing/multitest/driver/app.py b/testplan/testing/multitest/driver/app.py index 88a7279b3..d8325653a 100644 --- a/testplan/testing/multitest/driver/app.py +++ b/testplan/testing/multitest/driver/app.py @@ -310,20 +310,6 @@ def hostname(self) -> str: """ return socket.gethostname() - def pre_start(self) -> None: - """ - Create mandatory directories and install files from given templates - using the drivers context before starting the application binary. - """ - super(App, self).pre_start() - - self._make_dirs() - makedirs(self.app_path) - self.std = StdFiles(self.app_path) - - if self.cfg.install_files: - self.install_files() - def starting(self) -> None: """Starts the application binary.""" super(App, self).starting() @@ -411,13 +397,20 @@ def stopping(self) -> None: ) raise RuntimeError(err_msg) - def _make_dirs(self) -> None: + def make_runpath_dirs(self) -> None: + """ + Create mandatory directories and install files from given templates + using the drivers context before starting the application binary. + """ + super(App, self).make_runpath_dirs() + bin_dir = os.path.join(self.runpath, "bin") etc_dir = os.path.join(self.runpath, "etc") - for directory in (bin_dir, etc_dir): + for directory in (bin_dir, etc_dir, self.app_path): makedirs(directory) self._binpath = bin_dir self._etcpath = etc_dir + self.std = StdFiles(self.app_path) def _install_target(self) -> str: return self.etcpath