~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to testsuite/expect/test6.14

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/expect
 
2
############################################################################
 
3
# Purpose: Test of SLURM functionality
 
4
#          Test scancel --nodelist option.
 
5
#
 
6
# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
 
7
#          "FAILURE: ..." otherwise with an explanation of the failure, OR
 
8
#          anything else indicates a failure mode that must be investigated.
 
9
############################################################################
 
10
# Copyright (C) 2008 Lawrence Livermore National Security
 
11
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 
12
# Written by David Bremer <dbremer@llnl.gov>
 
13
# CODE-OCEC-09-009. All rights reserved.
 
14
 
15
# This file is part of SLURM, a resource management program.
 
16
# For details, see <https://computing.llnl.gov/linux/slurm/>.
 
17
# Please also read the included file: DISCLAIMER.
 
18
#  
 
19
# SLURM is free software; you can redistribute it and/or modify it under
 
20
# the terms of the GNU General Public License as published by the Free
 
21
# Software Foundation; either version 2 of the License, or (at your option)
 
22
# any later version.
 
23
 
24
# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
 
25
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
26
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
27
# details.
 
28
 
29
# You should have received a copy of the GNU General Public License along
 
30
# with SLURM; if not, write to the Free Software Foundation, Inc.,
 
31
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 
32
############################################################################
 
33
source ./globals
 
34
 
 
35
set test_id        "6.14"
 
36
set exit_code      0
 
37
set file_in        "test$test_id.input"
 
38
set num_procs      10
 
39
set ii             0
 
40
set job_id         ""
 
41
set job_map        {}
 
42
set found          0
 
43
set tmp_job_list   {}
 
44
set tmp_map_entry  {}
 
45
set submitted_jobs {}
 
46
set job_list       {}
 
47
set job_index      -1
 
48
 
 
49
print_header $test_id
 
50
 
 
51
#
 
52
# Build input script file
 
53
#
 
54
make_bash_script $file_in "$srun $bin_sleep 600"
 
55
 
 
56
#
 
57
# Submit some jobs so we have something to work with
 
58
#
 
59
set timeout 20
 
60
for {set ii 0} {$ii < $num_procs} {incr ii} {
 
61
        set sbatch_pid [spawn $sbatch --output=/dev/null --error=/dev/null -n1 -N1 $file_in]
 
62
        expect {
 
63
                -re "Submitted batch job ($number)" {
 
64
                        set job_id $expect_out(1,string)
 
65
                        lappend submitted_jobs $job_id
 
66
                        exp_continue
 
67
                }
 
68
                timeout {
 
69
                        send_user "\nFAILURE: sbatch not responding\n"
 
70
                        slow_kill $sbatch_pid
 
71
                        set exit_code 1
 
72
                }
 
73
                eof {
 
74
                        wait
 
75
                }
 
76
        }
 
77
        if {$job_id == 0} {
 
78
                send_user "\nFAILURE: job submit failure\n"
 
79
                exit 1
 
80
        }
 
81
}
 
82
 
 
83
#
 
84
# Run squeue and build a map, implemented as a list of list of lists, like so:
 
85
# { {node1  {job1 job2 job3}}
 
86
#   {node2  {job4 job5}}
 
87
# }
 
88
#
 
89
# Only put jobs into the map if they were submitted by this test.
 
90
#
 
91
 
 
92
spawn $squeue -h -t running -u $env(USER) -o "%10i %40N"
 
93
expect {
 
94
        -re "($number) *($alpha_numeric) *\r\n" {
 
95
                set job_id $expect_out(1,string)
 
96
                set node_name $expect_out(2,string)
 
97
                
 
98
                #This test doesn't need to track jobs that it didn't submit.
 
99
                if { [lsearch $submitted_jobs $job_id] == -1 } {
 
100
                        exp_continue
 
101
                }
 
102
                #send_user "job $job_id: node $node_name\n"
 
103
                #Insert into a table with node_name as the key, job_id as the value
 
104
                set found 0
 
105
                for {set ii 0} {$ii < [llength $job_map]} {incr ii} {
 
106
                        if { [lindex [lindex $job_map $ii] 0] == $node_name } {
 
107
                                set tmp_map_entry [list $node_name [concat [lindex [lindex $job_map $ii] 1] $job_id]]
 
108
                                set job_map [lreplace $job_map $ii $ii $tmp_map_entry]
 
109
                                set found 1
 
110
                                break
 
111
                        }
 
112
                }
 
113
                if {$found == 0} {
 
114
                        lappend job_map [list $node_name [list $job_id] ]
 
115
                }
 
116
                exp_continue
 
117
        }
 
118
}
 
119
#send_user "job map: $job_map\n"
 
120
 
 
121
 
 
122
#
 
123
# Issue an scancel command against each node in the map described above.
 
124
# Remove entries from the internal list, and ensure that the list is
 
125
# empty at the end of the scancel call.
 
126
#
 
127
 
 
128
for {set ii 0} {$ii < [llength $job_map]} {incr ii} {
 
129
        set node_name [lindex [lindex $job_map $ii] 0]
 
130
        set job_list  [lindex [lindex $job_map $ii] 1]
 
131
 
 
132
        if {$ii == 0} {
 
133
                spawn $scancel -v -u $env(USER) --nodelist $node_name
 
134
        } else {
 
135
                spawn $scancel -v -u $env(USER) -w $node_name
 
136
        }
 
137
        expect {
 
138
                -re "scancel: Terminating job ($number)" {
 
139
                        #Search for the terminated job in the list recently
 
140
                        #returned from squeue. Don't worry if an unknown job
 
141
                        #gets cancelled, because maybe one of our submitted
 
142
                        #jobs will start running while we cancel other jobs
 
143
                        #Issue cancel commands node by node until all the 
 
144
                        #jobs submitted for this test are gone.
 
145
 
 
146
                        set job_id $expect_out(1,string)
 
147
                        set job_index [lsearch $job_list $job_id]
 
148
                        if {$job_index != -1} {
 
149
                                set job_list [lreplace $job_list $job_index $job_index]
 
150
                        } 
 
151
                        set job_index [lsearch $submitted_jobs $job_id]
 
152
                        if {$job_index != -1} {
 
153
                                set submitted_jobs [lreplace $submitted_jobs $job_index $job_index]
 
154
                        }
 
155
                        exp_continue
 
156
                }
 
157
                timeout {
 
158
                        send_user "\nFAILURE: scancel not responding while cancelling for node $node_name\n"
 
159
                        set exit_code 1
 
160
                }
 
161
                eof {
 
162
                        wait
 
163
                }
 
164
        }
 
165
        if { [llength $job_list] != 0 } {
 
166
                send_user "\nFAILURE: scancel did not remove jobs $job_list from node $node_name\n"
 
167
                set exit_code 1
 
168
        }
 
169
}
 
170
 
 
171
#
 
172
# Clean up any jobs submitted by this test, which were not mapped to a node,
 
173
# and thus not cancelled in the previous block of code
 
174
#
 
175
 
 
176
foreach job_id $submitted_jobs {
 
177
        spawn $scancel $job_id
 
178
        expect {
 
179
                timeout {
 
180
                        send_user "\nFAILURE: scancel not responding while cancelling job $job_id\n"
 
181
                        set exit_code 1
 
182
                }
 
183
                eof {
 
184
                        wait
 
185
                }
 
186
        }
 
187
}
 
188
 
 
189
 
 
190
 
 
191
if {$exit_code == 0} {
 
192
        send_user "\nSUCCESS\n"
 
193
}
 
194
exit $exit_code
 
195