From 095fb3ef1962fa198ba33cd31a18de5320293810 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Mon, 5 Dec 2005 18:05:43 +0000
Subject: [PATCH] Fix code to test proper functionality and add a bunch more
 comments for clarity.

---
 testsuite/expect/test13.1 | 61 ++++++++++++++++++++++++---------------
 1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/testsuite/expect/test13.1 b/testsuite/expect/test13.1
index 48ea98fa162..9bf3114b3ad 100755
--- a/testsuite/expect/test13.1
+++ b/testsuite/expect/test13.1
@@ -1,7 +1,7 @@
 #!/usr/bin/expect
 ############################################################################
 # Purpose: Test of SLURM functionality
-#          Test that elan switch contexts are not re-used.
+#          Test that switch windows in uses are not re-used.
 #
 # Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 #          "FAILURE: ..." otherwise with an explanation of the failure, OR
@@ -37,14 +37,37 @@ set exit_code   0
 print_header $test_id
 
 #
-# Report the slurm configuration
+# Report the slurm network and use it to establish window parameters
+# 
+# windows_per_node    - switch windows available per node
+# windows_interations - job steps to run after initial switch window allocation
+#                       for a persistent job step
+# windows_used        - switch windows to use per job step
+# step_delay          - run time of persistent job step (seconds)
 #
-set matches 0
 log_user 0
+set step_delay 0
 spawn $scontrol show config
 expect {
-	-re "switch/((elan)|(none))" {
-		incr matches
+	-re "switch/elan" {
+		set windows_per_node 2048
+		set windows_interations 50
+		set windows_used 48
+		set step_delay 10
+		exp_continue
+	}
+	-re "switch/federation" {
+		set windows_per_node 16
+		set windows_interations 32
+		set windows_used 2
+		set step_delay 10
+		exp_continue
+	}
+	-re "switch/none" {
+		set windows_per_node 0
+		set windows_interations 5
+		set windows_used 4
+		set step_delay 5
 		exp_continue
 	}
 	timeout {
@@ -56,8 +79,8 @@ expect {
 	}
 }
 log_user 1
-if {$matches != 1} {
-	send_user "\nWARNING: not running elan switch, this test is not applicable\n"
+if {$step_delay == 0} {
+	send_user "\nWARNING: not running compatable switch, this test is not applicable\n"
 	exit 0
 }
 
@@ -68,29 +91,21 @@ if {$matches != 1} {
 set timeout $max_job_delay
 set job_id 0
 set matches 0
-
 spawn $srun --allocate -N1 --verbose -t2
-
 expect -re "jobid ($number).*"
 set job_id $expect_out(1,string)
-#send_user "SLURM_JOBID is $job_id\n"
 
-expect -re $prompt
+# start initial job step to claim some switch windows
+send "$srun -N1 -O -n$windows_used $bin_sleep $step_delay &\n"
 
-for {set inx 0} {$inx < 50} {incr inx} {
-	#sleep 0.001
-	send "$srun -N1 -O -n32 true\n"
-
-	expect {
-		-re "error" {
-			send_user "\nFAILURE: some error occurred\n"
-			set exit_code 1
-			exp_continue
-		}
-		-re $prompt {}
-	}
+# start more job steps to check see if any switch window conflicts occur
+for {set inx 0} {$inx < $windows_interations} {incr inx} {
+	#exec $bin_usleep 1000
+	send "$srun -N1 -O -n$windows_used true\n"
 }
 
+# wait for initial job step to complete
+send "$bin_sleep $step_delay\n"
 send "exit\n"
 
 expect {
-- 
GitLab