From eabfd80e8d8b6d1d502d7e0ffab427ad77a3a00f Mon Sep 17 00:00:00 2001
From: "Joseph P. Donaghy" <donaghy1@llnl.gov>
Date: Wed, 30 Jul 2008 23:32:31 +0000
Subject: [PATCH] Test of slurmdbd add account.

---
 testsuite/expect/test21.10 | 233 +++++++++++++++++++++++++++++++++++++
 1 file changed, 233 insertions(+)
 create mode 100755 testsuite/expect/test21.10

diff --git a/testsuite/expect/test21.10 b/testsuite/expect/test21.10
new file mode 100755
index 00000000000..c35e8cc5328
--- /dev/null
+++ b/testsuite/expect/test21.10
@@ -0,0 +1,233 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          sacctmgr add an account
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2008 Lawrence Livermore National Security.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Joseph Donaghy <donaghy1@llnl.gov>
+# LLNL-CODE-402394.
+# 
+# This file is part of SLURM, a resource management program.
+# For details, see <http://www.llnl.gov/linux/slurm/>.
+#  
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+# 
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals
+
+set test_id     "21.10"
+set exit_code   0
+set acmatches   0
+set aamatches   0
+set lmatches    0
+set damatches   0
+set dcmatches   0
+set not_support 0
+set add		add
+set lis		list
+set del		delete
+set mod		modify
+set nams	Names
+set nam		Name
+set fs		Fairshare
+set mc		MaxCPUSecs
+set mj		MaxJobs
+set mn		MaxNodes
+set mw		MaxWall
+set clu		cluster
+set tc1		tcluster1
+set fs1		2500
+set mc1		1000000
+set mj1		50
+set mn1		300
+set mw1		01:00:00
+set acc		account
+set ass		associations
+set nm1		testaccta1
+set des		Description
+set ds1		"Test Account A1"
+set org		Organization
+set or1		"Account Org A1"
+set qs		QosLevel
+set qs1		normal
+
+
+
+print_header $test_id
+
+#
+# Use sacctmgr to create a cluster
+#
+set sadd_pid [spawn $sacctmgr -i add $clu $nams=$tc1 $fs=$fs1 $mc=$mc1 $mj=$mj1 $mn=$mn1 $mw=$mw1]
+expect {
+	-re "Adding Cluster" {
+		incr acmatches
+		exp_continue
+	}
+		timeout {
+		send_user "\nFAILURE: sacctmgr add not responding\n"
+		slow_kill $sadd_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$acmatches != 1} {
+	send_user "\nFAILURE:  sacctmgr had a problem adding clusters
+	got $acmatches\n"
+	set exit_code 1
+}
+
+if { ![check_acct_associations] } {
+	send_user "\nFAILURE:  Our associations don't line up\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to add an account
+#
+set sadel_pid [spawn $sacctmgr -i $add $acc $clu=$tc1 $des="$ds1" $fs=$fs1 $mc=$mc1 $mj=$mj1 $mn=$mn1 $mw=$mw1 $nams=$nm1 $org="$or1" $qs=$qs1]
+expect {
+	-re "Adding Account" {
+		incr aamatches
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr add not responding\n"
+		slow_kill $sadd_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$aamatches != 1} {
+	send_user "\nFAILURE:  sacctmgr had a problem adding account.
+	got $aamatches\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to list the test associations
+#
+set as_list_pid [spawn $sacctmgr list $ass $acc=$nm1 ]
+expect {
+	-re "$tc1 *$nm1" {
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr list associations not responding\n"
+		slow_kill $as_list_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if { ![check_acct_associations] } {
+	send_user "\nFAILURE:  Our associations don't line up\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to delete the test account
+#
+set sadel_pid [spawn $sacctmgr -i $del $acc $nm1]
+expect {
+	-re "Deleting account" {
+		incr damatches
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr delete not responding\n"
+		slow_kill $sadel_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$damatches != 1} {
+	send_user "\nFAILURE: sacctmgr had a problem deleting cluster got $damatches\n"
+	set exit_code 1
+}
+
+if { ![check_acct_associations] } {
+	send_user "\nFAILURE:  Our associations don't line up\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to delete the test cluster
+#
+set sadel_pid [spawn $sacctmgr -i $del $clu $tc1]
+expect {
+	-re "Deleting clusters" {
+		incr dcmatches
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sacctmgr delete not responding\n"
+		slow_kill $sadel_pid
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+if {$dcmatches != 1} {
+	send_user "\nFAILURE: sacctmgr had a problem deleting cluster got $dcmatches\n"
+	set exit_code 1
+}
+
+#
+# Use sacctmgr to list the test associations
+#
+set as2_list_pid [spawn $sacctmgr list $ass $acc=$nm1 ]
+expect {
+	-re "$tc1 *$nm1" {
+		exp_continue
+		send_user "\nFAILURE: test associations still exist.\n"
+		set exit_code 1
+	}
+	timeout {
+		send_user "\nTest associations delete verified.\n"
+		slow_kill $as2_list_pid
+	}
+	eof {
+		wait
+	}
+}
+
+if { ![check_acct_associations] } {
+	send_user "\nFAILURE:  Our associations don't line up\n"
+	set exit_code 1
+}
+
+if {$exit_code == 0} {
+	send_user "\nSUCCESS\n"
+}
+
+exit $exit_code
-- 
GitLab