From 169946c2bd5b1cf413a38e72efe66aadf791d8e1 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Fri, 16 Apr 2010 16:34:24 +0000
Subject: [PATCH] temporary change for handling the lag for jobs being started
 in the dbd

---
 testsuite/expect/globals   | 33 +++++++++++++++++++++++++++++++++
 testsuite/expect/test12.4  | 12 +++++++++++-
 testsuite/expect/test21.23 | 16 ++++++++++++++++
 3 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/testsuite/expect/globals b/testsuite/expect/globals
index 0493f7f8b5c..85b20c9b075 100755
--- a/testsuite/expect/globals
+++ b/testsuite/expect/globals
@@ -822,6 +822,39 @@ proc test_account_storage { } {
 	return $account_storage
 }
 
+################################################################
+#
+# Proc: test_using_slurmdbd
+#
+# Purpose: Since there is a lag at which the slurmdbd processes a job start
+# we need to wait a bit to make sure the data has been set before proceeding.
+# This is based upon
+# the value of AccountingStorageType in the slurm.conf.
+#
+# Returns 1 if the system is running with slurmdbd, 0 otherwise
+#
+################################################################
+
+proc test_using_slurmdbd { } {
+	global scontrol
+
+	log_user 0
+	set account_storage 0
+	spawn $scontrol show config
+	expect {
+		-re "(accounting_storage/slurmdbd)" {
+			set account_storage 1
+			exp_continue
+		}
+		eof {
+			wait
+		}
+	}
+	log_user 1
+
+	return $account_storage
+}
+
 ################################################################
 #
 # Proc: priority_type
diff --git a/testsuite/expect/test12.4 b/testsuite/expect/test12.4
index efc4c6eee7b..56f6a6e247d 100755
--- a/testsuite/expect/test12.4
+++ b/testsuite/expect/test12.4
@@ -51,6 +51,9 @@ if { [string compare [check_accounting_admin_level] "Administrator"] } {
 	send_user "\nWARNING: This test can't be run without being an Accounting administrator.\nUse sacctmgr mod user \$USER_NAME set admin=admin.\n"
 	exit 0
 }
+
+set using_slurmdbd [test_using_slurmdbd]
+
 set cluster [get_cluster_name]
 #
 # Identify the user and his current default account
@@ -185,6 +188,12 @@ if {$job_id == 0} {
 		set exit_code 1
 	}
 }
+
+if {$using_slurmdbd} {
+	sleep 30
+}
+
+
 ################################################################
 #
 # Proc: sacct_job
@@ -198,11 +207,12 @@ if {$job_id == 0} {
 ################################################################
 
 proc sacct_job { soption job_id} {
-	global sacct
+	global sacct using_slurmdbd
 	set debug       0
 	set exit_code   0
 	set matches     0
 	set not_support 0
+
 	send_user "sacct -$soption -p -j $job_id\n"
 
 	if { $soption == "-brief" || $soption == "b" } {
diff --git a/testsuite/expect/test21.23 b/testsuite/expect/test21.23
index b8fd364ad6c..8cc5f50d45d 100755
--- a/testsuite/expect/test21.23
+++ b/testsuite/expect/test21.23
@@ -38,6 +38,7 @@ set file_in     "test.$test_id.input"
 set test_acct   "test_acct"
 set wk          21test
 set timeout 60
+
 print_header $test_id
 
 #
@@ -57,6 +58,8 @@ if { [string compare [check_accounting_admin_level] "Administrator"] } {
 	exit 0
 }
 
+set using_slurmdbd [test_using_slurmdbd]
+
 set cn [get_cluster_name]
 
 #
@@ -161,6 +164,10 @@ expect {
 	}
 }
 
+if {$using_slurmdbd} {
+	sleep 30
+}
+
 spawn $sacct -j $job_id --fields=wckey
 	expect {
 		-re "$wk" {
@@ -221,6 +228,10 @@ if {$job_id == 0} {
 			wait
 		}
 	}
+	if {$using_slurmdbd} {
+		sleep 30
+	}
+
 	spawn $sacct -j $job_id --fields=wckey
 	expect {
 		-re "$wk" {
@@ -278,6 +289,11 @@ if {$job_id == 0} {
 			wait
 		}
 	}
+
+	if {$using_slurmdbd} {
+		sleep 30
+	}
+
 	spawn $sacct -j $job_id --fields=wckey
 	expect {
 		-re "$wk" {
-- 
GitLab