Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage test hook files in /var/lib/irods/scripts #229

Open
alanking opened this issue Aug 15, 2024 · 0 comments
Open

Stage test hook files in /var/lib/irods/scripts #229

alanking opened this issue Aug 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@alanking
Copy link
Contributor

Here's the place where we put test hook script files into test containers:

if path_to_test_hook_on_host:
path_to_test_hook_in_container = self.stage_custom_test_hook_file(path_to_test_hook_on_host)
else:
path_to_test_hook_in_container = self.stage_test_hook_file_from_repo(plugin_repo_name, plugin_branch)

And here are the definitions for the functions called there:

# TODO: this could likely just be implemented in yet another subclass
def stage_test_hook_file_from_repo(self, repo_name, branch=None):
"""Run the test hook from the specified git repository.
Arguments:
repo_name -- name of the git repo
branch -- name of the branch to checkout in cloned git repo
options -- list of strings representing script options to pass to the run_tests.py script
"""
from . import services
return os.path.join(
services.clone_repository_to_container(self.executor, repo_name, branch=branch),
'irods_consortium_continuous_integration_test_hook.py')
# TODO: this could likely just be implemented in yet another subclass
def stage_custom_test_hook_file(self, path_to_test_hook_on_host):
"""Run the local test hook in the container.
Arguments:
path_to_test_hook_on_host -- local filesystem path on host machine to test hook
options -- list of strings representing script options to pass to the run_tests.py script
"""
from . import archive
f = os.path.abspath(path_to_test_hook_on_host)
archive.copy_archive_to_container(self.executor, archive.create_archive([f]))
return f

As you can see, this is done rather lazily - the path is just replicating what is on the host machine (for local files) or going into a temporary directory for files coming from a remote Git repository.

If we were more deliberate about where we put these test hook files (and how they are named, for that matter), we could take advantage of the tools in /var/lib/irods/scripts in the test hooks. This approach carries with it a disadvantage: The test hooks would be dependent on existing in a specific location whereas they are now independent of a specific location in the filesystem. Arguably, the test hooks should just be packaged with the plugins and placed in the right spot if we wanted to do that, but doing this in the testing environment could be a good start.

This issue was spawned from this: irods/irods_auth_plugin_pam_interactive#48 (comment) Being able to use irods.paths would allow us to get away from hard-coded paths in the test hooks. As mentioned in that comment, an alternative solution would be to make a library of tools in irods_python_ci_utilities which perform similar functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant