Repository: lanl/BEE (language: python)

Issue:
Add test (ci) when slurmrestd is not available
We have a path for systems that do not have slurmrestd. We need to test it and make sure it doesn't break.


Discussion / hints:
Do we just want to set use_commands to True in the bee.conf file to test this.
We might be able to test this with the integration CI. We would need to update `.github/workflows/integration.yml` to also test a slurm+commands instance. Right now that workflow runs two instances of the integration tests, one for slurm+slurmrestd and one for flux.

Fix patch:
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 97acbf926..4dc3a5b07 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -18,9 +18,9 @@ jobs:
     name: BEE Integration Test
     strategy:
       matrix:
-        batch_scheduler: [Slurm, Flux]
+        bee_worker: [Slurmrestd, SlurmCommands, Flux]
     env:
-      BATCH_SCHEDULER: ${{ matrix.batch_scheduler }}
+      BEE_WORKER: ${{ matrix.bee_worker }}
     # Note: Needs to run on 22.04 or later since slurmrestd doesn't seem to be
     # available on 20.04
     runs-on: ubuntu-22.04
diff --git a/ci/README.md b/ci/README.md
index 028a6bd58..ee811b045 100644
--- a/ci/README.md
+++ b/ci/README.md
@@ -1,9 +1,8 @@
 # CI code
 
 This directory contains all the scripts that are needed for configuring and
-running BEE on a CI machine. `BATCH_SCHEDULER` is set in the environment by the
-workflow to either `Slurm` or `Flux`, which is then used in various places in
-these scripts. The scripts are as follows:
+running BEE on a CI machine. `BEE_WORKER` must be set in the environment by the
+workflow to `Slurmrestd`, `SlurmCommands`, or `Flux`. The scripts are as follows:
 
 * `env.sh`: CI environment set up
 * `batch_scheduler.sh`: Install and set up a batch scheduler
diff --git a/ci/batch_scheduler.sh b/ci/batch_scheduler.sh
index a89e4c275..e92aa119b 100755
--- a/ci/batch_scheduler.sh
+++ b/ci/batch_scheduler.sh
@@ -1,14 +1,15 @@
 #!/bin/sh
 # Set up and start the batch scheduler
 
-case $BATCH_SCHEDULER in
-Slurm)
+case $BEE_WORKER in
+Slurmrestd|SlurmCommands)
     ./ci/slurm_start.sh
     ;;
 Flux)
     ./ci/flux_install.sh
     ;;
 *)
-    printf "ERROR: Invalid batch scheduler '%s'\n" "$BATCH_SCHEDULER"
+    printf "ERROR: Invalid worker type '%s'\n" "$BEE_WORKER"
+    exit 1
     ;;
 esac
diff --git a/ci/bee_config.sh b/ci/bee_config.sh
index 2241d34f1..2a1e8bd6a 100755
--- a/ci/bee_config.sh
+++ b/ci/bee_config.sh
@@ -1,12 +1,21 @@
 #!/bin/sh
 # BEE Configuration
 
+case $BEE_WORKER in
+Slurm*)
+    export WORKLOAD_SCHEDULER=Slurm
+    ;;
+Flux)
+    export WORKLOAD_SCHEDULER=Flux
+    ;;
+esac
+
 mkdir -p $(dirname $BEE_CONFIG)
 cat >> $BEE_CONFIG <<EOF
 # BEE CONFIGURATION FILE #
 [DEFAULT]
 bee_workdir = $BEE_WORKDIR
-workload_scheduler = $BATCH_SCHEDULER
+workload_scheduler = $WORKLOAD_SCHEDULER
 use_archive = False
 neo4j_image = $NEO4J_CONTAINER
 redis_image = $REDIS_CONTAINER
@@ -49,14 +58,22 @@ container_type = charliecloud
 container_archive = $BEE_WORKDIR/container_archive
 EOF
 
-if [ "$BATCH_SCHEDULER" = "Slurm" ]; then
+case $BEE_WORKER in
+Slurmrestd)
     cat >> $BEE_CONFIG <<EOF
 [slurm]
-# Just test slurmrestd in CI for now
 use_commands = False
 openapi_version = $OPENAPI_VERSION
 EOF
-fi
+    ;;
+SlurmCommands)
+    cat >> $BEE_CONFIG <<EOF
+[slurm]
+use_commands = True
+openapi_version = $OPENAPI_VERSION
+EOF
+    ;;
+esac
 
 printf "\n\n"
 printf "#### %s ####\n" $BEE_CONFIG
diff --git a/ci/env.sh b/ci/env.sh
index 642ddd359..8a725fab4 100644
--- a/ci/env.sh
+++ b/ci/env.sh
@@ -17,8 +17,6 @@ export MUNGE_LOG=/tmp/munge.log
 export MUNGE_PID=/tmp/munge.pid
 mkdir -p /tmp/munge
 export MUNGE_KEY=/tmp/munge/munge.key
-# Determine config of CI host
-export NODE_CONFIG=`slurmd -C | head -n 1`
 export BEE_WORKDIR=$HOME/.beeflow
 export NEO4J_CONTAINER=$HOME/img/neo4j.tar.gz
 export REDIS_CONTAINER=$HOME/img/redis.tar.gz
diff --git a/ci/slurm_start.sh b/ci/slurm_start.sh
index e0895a051..6221277d5 100755
--- a/ci/slurm_start.sh
+++ b/ci/slurm_start.sh
@@ -7,6 +7,9 @@ printf "#### SLURM VERSION ####\n"
 srun -V
 printf "#######################\n"
 
+# Determine config of CI host
+export NODE_CONFIG=`slurmd -C | head -n 1`
+
 # Dump a new slurm.conf
 cat >> $SLURM_CONF <<EOF
 ClusterName=bee-ci


Test patch:
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index fc219666a..f85bd3bd6 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -17,8 +17,8 @@ jobs:
     if: ${{ !(contains(github.event.pull_request.labels.*.name, 'WIP (no-ci)')) && !(contains(github.event.pull_request.labels.*.name, 'WIP (lint-only)')) }}
     name: BEE Unit Tests
     env:
-      # Unit tests are only run with Slurm right now
-      BATCH_SCHEDULER: Slurm
+      # Unit tests are only run with slurmrestd right now
+      BEE_WORKER: Slurmrestd
     # Note: Needs to run on 22.04 or later since slurmrestd doesn't seem to be
     # available on 20.04
     runs-on: ubuntu-22.04
diff --git a/ci/inner_integration_test.sh b/ci/inner_integration_test.sh
index a4e257106..2a55c2ee8 100755
--- a/ci/inner_integration_test.sh
+++ b/ci/inner_integration_test.sh
@@ -7,12 +7,15 @@
 set +e
 
 # BEE needs to be started here in order to access batch scheduler resources
-if [ "$BATCH_SCHEDULER" = "Slurm" ]; then
+case $BEE_WORKER in
+Slurmrestd)
     # Slurmrestd will fail by default when running as `SlurmUser`
     SLURMRESTD_SECURITY=disable_user_check beeflow core start
-else
+    ;;
+*)
     beeflow core start
-fi
+    ;;
+esac
 sleep 4
 
 # Start the actual integration tests
diff --git a/ci/integration_test.sh b/ci/integration_test.sh
index ab2b6af16..f58e68c88 100755
--- a/ci/integration_test.sh
+++ b/ci/integration_test.sh
@@ -4,8 +4,8 @@
 
 set +e
 
-case $BATCH_SCHEDULER in
-Slurm)
+case $BEE_WORKER in
+Slurm*)
     ./ci/inner_integration_test.sh
     EXIT_CODE=$?
     ;;
@@ -14,7 +14,7 @@ Flux)
     EXIT_CODE=$?
     ;;
 *)
-    printf "ERROR: Invalid batch scheduler '%s'\n" "$BATCH_SCHEDULER"
+    printf "ERROR: Invalid batch scheduler option '%s'\n" "$BEE_WORKER"
     ;;
 esac