Skip to content

Commit

Permalink
Make install_files invoked automatically for Driver object startup (#…
Browse files Browse the repository at this point in the history
…1099)

* Made install_files invoked automatically for Driver objects
  • Loading branch information
rnemes authored Jun 12, 2024
1 parent 826509c commit 5132c85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions doc/newsfragments/2878_changed.driver_install_files.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Users can now use :py:meth:`install_files <testplan.testing.multitest.driver.base.Driver.install_files>` method with Driver objects to copy files over to a specified location during environment startup.
25 changes: 9 additions & 16 deletions testplan/testing/multitest/driver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions testplan/testing/multitest/driver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down

0 comments on commit 5132c85

Please sign in to comment.