From a6eb2d438fc486eb4bb6018e6ac038fa447fb7e2 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Sun, 29 Jan 2017 11:18:30 -0700
Subject: [PATCH] Fix some tests for Cray

---
 testsuite/expect/test1.14  | 23 ++++++++++++++++-------
 testsuite/expect/test1.74  |  4 ++++
 testsuite/expect/test12.2  |  4 ++--
 testsuite/expect/test14.10 |  1 +
 testsuite/expect/test21.36 |  4 ++++
 testsuite/expect/test5.9   |  4 ++++
 testsuite/expect/test7.13  |  2 +-
 7 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/testsuite/expect/test1.14 b/testsuite/expect/test1.14
index 886e252e24d..28e62b48856 100755
--- a/testsuite/expect/test1.14
+++ b/testsuite/expect/test1.14
@@ -39,7 +39,6 @@ set file_in2        "test$test_id.input2"
 set file_out        "test$test_id.output"
 set file_out2       "test$test_id.output2"
 set job_id           0
-set sleep_secs       10
 
 
 print_header $test_id
@@ -64,10 +63,15 @@ if {[test_launch_poe]} {
 exec $bin_rm -f $file_in $file_in2 $file_out $file_out2
 make_bash_script $file_in "
   echo tasks_per_node=\$SLURM_TASKS_PER_NODE
+  if \[ \$SLURM_TASKS_PER_NODE -gt 32 \]; then
+    sleep_secs=45
+  else
+    sleep_secs=10
+  fi
   inx=0
   while \[ \$inx -lt \$SLURM_TASKS_PER_NODE \]
   do
-    $srun --exclusive -n1 $bin_sleep $sleep_secs &
+    $srun --exclusive -n1 $bin_sleep \$sleep_secs &
     inx=\$((inx+1))
   done
   $bin_sleep 4
@@ -81,7 +85,7 @@ make_bash_script $file_in2 "
 #
 # Spawn a job via sbatch
 #
-spawn $sbatch -N1 -t1 --gres=craynetwork:0 --output=$file_out $file_in
+spawn $sbatch -N1 -t2 --gres=craynetwork:0 --output=$file_out $file_in
 expect {
 	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
@@ -149,25 +153,30 @@ if {$exit_code == 0} {
 # Delete left-over input script
 # Build another input script file
 # Run one more step than allocated CPUs with immediate option and make aborts
-# The "sleep 4" is meant to insure the earlier job steps start first
+# The "sleep" is meant to insure the earlier job steps start first
 #
 exec $bin_rm -f $file_in $file_out
 make_bash_script $file_in "
   inx=0
+  if \[ \$SLURM_TASKS_PER_NODE -gt 32 \]; then
+    sleep_secs=45
+  else
+    sleep_secs=10
+  fi
   while \[ \$inx -lt \$SLURM_TASKS_PER_NODE \]
   do
-    $srun --exclusive -n1 $bin_sleep $sleep_secs &
+    $srun --exclusive -n1 --mem=0 $bin_sleep \$sleep_secs &
     inx=\$((inx+1))
   done
   $bin_sleep 4
-  $srun -v --exclusive -n1 --immediate $file_in2 &
+  $srun -v --exclusive -n1 --mem=0 --immediate $file_in2 &
   wait
 "
 
 #
 # Spawn a job via sbatch
 #
-spawn $sbatch -N1 -t1 --gres=craynetwork:0 --output=$file_out2 $file_in
+spawn $sbatch -N1 -t2 --gres=craynetwork:0 --output=$file_out2 $file_in
 expect {
 	-re "Submitted batch job ($number)" {
 		set job_id $expect_out(1,string)
diff --git a/testsuite/expect/test1.74 b/testsuite/expect/test1.74
index 43ec18c74fa..d527593c902 100755
--- a/testsuite/expect/test1.74
+++ b/testsuite/expect/test1.74
@@ -65,6 +65,10 @@ if { [test_using_slurmdbd] == 0 } {
 	send_user "\nWARNING: This test is incompatible with serial systems\n"
 	exit $exit_code
 }
+if {[string compare [check_accounting_admin_level] "Administrator"]} {
+	send_user "\nThis test can't be run without being an Accounting administrator.\n"
+	exit $exit_code
+}
 
 spawn $bin_id -u -n
 expect {
diff --git a/testsuite/expect/test12.2 b/testsuite/expect/test12.2
index a7e59cfc30e..dd8c2a8fd04 100755
--- a/testsuite/expect/test12.2
+++ b/testsuite/expect/test12.2
@@ -186,7 +186,7 @@ proc _get_file_size {prog} {
 	# Compute error in MB
 	set diff_io [expr $max_disk_write - $max_disk_read]
 	set error_io [expr abs($diff_io)]
-	if { $error_io > 0.05 } {
+	if { $error_io > 0.3 } {
 		send_user "\nFAILURE: written file size does not match read size "
 		send_user "file_size:$mb_file_size MB "
 		send_user "max_disk_write:$max_disk_write MB "
@@ -196,7 +196,7 @@ proc _get_file_size {prog} {
 
 	set diff_io [expr $ave_disk_write - $ave_disk_read]
 	set error_io [expr abs($diff_io)] 
-	if { $error_io > 0.05 } {
+	if { $error_io > 0.3 } {
 		send_user "\nFAILURE: average written file size "
 		send_user "does not match average read size "
 		send_user "file_size:$mb_file_size MB "
diff --git a/testsuite/expect/test14.10 b/testsuite/expect/test14.10
index 9d117ae9028..99d53974280 100755
--- a/testsuite/expect/test14.10
+++ b/testsuite/expect/test14.10
@@ -107,6 +107,7 @@ $sbcast -f -j\$SLURM_JOBID.\$SLURM_STEPID $srun /tmp/\$SLURMD_NODENAME/test$test
 "
 
 # Make allocations
+set timeout $max_job_delay
 set matches 0
 spawn $salloc -N2 -w$hostlist -t1 ./$file_in1
 expect {
diff --git a/testsuite/expect/test21.36 b/testsuite/expect/test21.36
index c0ebf722318..b91c25d7dbe 100755
--- a/testsuite/expect/test21.36
+++ b/testsuite/expect/test21.36
@@ -81,6 +81,10 @@ if {[test_using_slurmdbd] == 0} {
 	send_user "\nThis test can't be run without AccountStorageType=slurmdbd\n"
 	exit 0
 }
+if {[string compare [check_accounting_admin_level] "Administrator"]} {
+	send_user "\nThis test can't be run without being an Accounting administrator.\n"
+	exit 0
+}
 
 # Remove pre-existing items
 cleanup
diff --git a/testsuite/expect/test5.9 b/testsuite/expect/test5.9
index 12266727bc6..cb77af1cea3 100755
--- a/testsuite/expect/test5.9
+++ b/testsuite/expect/test5.9
@@ -98,6 +98,10 @@ if { [test_using_slurmdbd] == 0 } {
 	send_user "\nWARNING: This test is incompatible with serial systems\n"
 	exit $exit_code
 }
+if {[string compare [check_accounting_admin_level] "Administrator"]} {
+	send_user "\nThis test can't be run without being an Accounting administrator.\n"
+	exit $exit_code
+}
 set available [available_nodes $partition idle]
 if {$available < 2} {
     send_user "\nWARNING: not enough nodes currently available ($available avail, 2 needed)\n"
diff --git a/testsuite/expect/test7.13 b/testsuite/expect/test7.13
index 8ba353cd4dd..5c6ba8b9af5 100755
--- a/testsuite/expect/test7.13
+++ b/testsuite/expect/test7.13
@@ -166,7 +166,7 @@ if { [test_account_storage] == 1 } {
 		}
 	}
 	if {$matches != 4} {
-		send_user "\nFAILURE: sacct of $job_id failed ($matches != 5)\n"
+		send_user "\nFAILURE: sacct of $job_id failed ($matches != 4)\n"
 		exit 1
 	}
 }
-- 
GitLab