Skip to content

Commit

Permalink
Test uninstalled execution
Browse files Browse the repository at this point in the history
This enables testing with uninstalled executions, while still allowing
testing the installed package.
  • Loading branch information
jordap committed Jul 9, 2024
1 parent 46ef198 commit 1148b6f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
7 changes: 7 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ From the root directory of the project:
```
docker compose -f test/docker/slurm/compose.yaml up -d
```
By default the containers will be launched with an uninstalled deployment,
executing directly from a working copy of the Omnistat repository. In order
to test the Omnistat package and its installation, set the
`TEST_OMNISTAT_EXECUTION` variable as follows:
```
TEST_OMNISTAT_EXECUTION=package docker compose -f test/docker/slurm/compose.yaml up -d
```

2. Submit a SLURM job.
```
Expand Down
2 changes: 2 additions & 0 deletions test/docker/slurm/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ services:
- controller
links:
- controller
environment:
- TEST_OMNISTAT_EXECUTION

volumes:
jobs_dir:
42 changes: 31 additions & 11 deletions test/docker/slurm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

TEST_OMNISTAT_EXECUTION=${TEST_OMNISTAT_EXECUTION:-source}

if [ "$1" = "controller" ]; then
service munge start
service slurmctld start
Expand All @@ -16,25 +18,43 @@ if [ "$1" = "node" ]; then

# Install omnistat based on the current working copy of the repository;
# this docker compose environment is meant to be used for development and
# testing.
python3 -m venv /opt/omnistat

# Copy omnistat source to /tmp avoid polluting the host with files
# testing. Copy entire directory to avoid polluting the host with files
# generated in the container.
cp -R /host-source /tmp/omnistat
cd /tmp/omnistat
/opt/omnistat/bin/python -m pip install .[query]
cd
rm -rf /tmp/omnistat
cp -R /host-source /source

# Enable access from the controller container, which is running the
# prometheus scraper.
ip=$(dig +short controller)
sed "s/127.0.0.1/127.0.0.1, $ip/" \
/host-source/test/docker/slurm/omnistat.slurm > /etc/omnistat.config

OMNISTAT_CONFIG=/etc/omnistat.config /opt/omnistat/bin/python -m \
omnistat.node_monitoring
# Create a Python virtual environment to install Omnistat and/or its
# dependencies.
python3 -m venv /opt/omnistat
. /opt/omnistat/bin/activate

cd /source

case "$TEST_OMNISTAT_EXECUTION" in
"source")
echo "Executing Omnistat from uninstalled source"
path=.
pip install -r requirements.txt
pip install -r requirements-query.txt
;;
"package")
echo "Executing Omnistat from installed package"
path=/opt/omnistat/bin
pip install .[query]
cd # Change directory to avoid loading uninstalled module
;;
*)
echo "Unknown TEST_OMNISTAT_EXECUTION value"
exit 1
;;
esac

OMNISTAT_CONFIG=/etc/omnistat.config $path/omnistat-monitor
fi

sleep infinity
10 changes: 9 additions & 1 deletion test/docker/slurm/slurm-prolog.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/bin/bash

/opt/omnistat/bin/omnistat-slurm-env
# Default repository and execution path
path=/source/

# Run packaged script When Omnistat is installed as a package
if [[ -f /opt/omnistat/bin/omnistat-slurm-env ]]; then
path=/opt/omnistat/bin/
fi

cd $path && ./omnistat-slurm-env

0 comments on commit 1148b6f

Please sign in to comment.