From 571bd950896c61333562d52988aa9dffd3537131 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 14 Sep 2006 18:20:17 +0000
Subject: [PATCH] Add poe checkpoint test

---
 testsuite/expect/test11.6 | 145 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100755 testsuite/expect/test11.6

diff --git a/testsuite/expect/test11.6 b/testsuite/expect/test11.6
new file mode 100755
index 00000000000..d8424ae455f
--- /dev/null
+++ b/testsuite/expect/test11.6
@@ -0,0 +1,145 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of POE functionality
+#          Test of checkpoint logic (with poe)
+#
+# 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) 2006 The Regents of the University of California.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Morris Jette <jette1@llnl.gov>
+# UCRL-CODE-217948.
+# 
+# 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     "11.6"
+set exit_code   0
+set file_in    "test$test_id.input"
+set job_id     0
+
+print_header $test_id
+
+if { ![file exists $poe] } {
+	send_user "WARNING: poe must be installed on the "
+	send_user "system to run this test.\n"
+	exit $exit_code
+}
+if { ![test_super_user] != 0 } {
+	send_user "WARNING: Test can only be run as SlurmUser\n"
+	exit $exit_code
+}
+
+if { [string length $partition] == 0 } {
+	set partition [default_partition]
+}
+
+#
+# Build input script file
+#
+global env
+set env(CHECKPOINT) "yes"
+make_bash_script $file_in "
+  echo BEGIN=\$SLURM_JOBID
+  $bin_sleep 30
+  echo FINI
+"
+
+#
+# Spawn the job
+#
+set timeout    $max_job_delay
+spawn $poe $file_in -rmpool $partition -procs 1
+set poe_id $spawn_id
+expect {
+	-re "BEGIN=($number)" {
+		set job_id $expect_out(1,string)
+	}
+	timeout {
+		send_user "\nFAILURE: poe not responding\n"
+		if {$job_id != 0}  {
+			exec $scancel --quiet $job_id
+		}
+		exit 1
+	}
+	eof {
+		wait
+	}
+}
+if {$job_id == 0} {
+	send_user "\nFAILURE: SLURM_JOBID missing\n"
+	exit 0
+}
+
+#
+# Checkpoint the job
+#
+set ckpt_success 1
+set timeout      10
+spawn $scontrol checkpoint vacate $job_id
+expect {
+	-re "not supported" {
+		set ckpt_success 0
+		exp_continue
+	}
+	-re "error" {
+		send_user "\nFAILURE: could not checkpoint the job\n"
+		set ckpt_success 0
+		set exit_code 1
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: scontrol not responding\n"
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+#
+# Make sure the job does not finish if checkpoint completes
+#
+set timeout 40
+set spawn_id $poe_id 
+expect {
+	-re "FINI" {
+		if {$ckpt_success == 1} {
+			send_user "\nFAILURE: checkpoint failed\n"
+			set exit_code 1
+		}
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: poe not responding\n"
+		exec $scancel --quiet $job_id
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+		
+if {$exit_code == 0} {
+	exec rm -f $file_in
+	send_user "\nSUCCESS\n"
+}
+exit $exit_code
-- 
GitLab