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

Test uninstalled source execution #57

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
test:
name: Test Omnistat client
runs-on: ubuntu-22.04
strategy:
matrix:
execution: [ source, package ]
steps:
- name: Check out repository code
uses: actions/checkout@v4
Expand All @@ -19,6 +22,8 @@ jobs:
run: >
sed -i "s/enable_rocm_smi = True/enable_rocm_smi = False/" \
test/docker/slurm/omnistat.slurm
- name: Set execution type
run: export TEST_OMNISTAT_EXECUTION=${{ matrix.execution }}
- name: Start containerized environment
run: docker compose -f test/docker/slurm/compose.yaml up -d
- name: Wait for Prometheus
Expand Down
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-rms-env
# Default repository and execution path
path=/source/

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

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