File: test37.6

package info (click to toggle)
slurm-wlm 22.05.8-4%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 48,492 kB
  • sloc: ansic: 475,246; exp: 69,020; sh: 8,862; javascript: 6,528; python: 6,444; makefile: 4,185; perl: 4,069; pascal: 131
file content (676 lines) | stat: -rwxr-xr-x 23,480 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
#!/usr/bin/env expect
############################################################################
# Purpose: Test federated job updates
#
# Reqs:    1. Using slurmdbd accounting storage type and is up
#          2. fed_slurm_base is defined in globals.local - set to directory that
#          has access to each federation configure (fedc1, fedc2, fedc3).
#          Eg.
#          fedr/slurm/ (src)
#          fedr/fed1/bin
#          fedr/fed1/sbin
#          fedr/fed1/etc
#          fedr/fed1/...
#          fedr/fed2/...
#          fedr/fed3/...
#          3. controllers are up and running.
############################################################################
# Copyright (C) 2017 SchedMD LLC.
# Written by Isaac Hartung <ihartung@schedmd.com>
#
# This file is part of Slurm, a resource management program.
# For details, see <https://slurm.schedmd.com/>.
# Please also read the included file: DISCLAIMER.
#
# 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
source ./globals_accounting
source ./globals_federation

set fed_name    "feda"
set user_name   ""
set srun_job_cnt 0

#
# Check accounting config and bail if not found.
#
if {[get_config_param "AccountingStorageType"] ne "accounting_storage/slurmdbd"} {
	skip "This test can't be run without a usable AccountStorageType"
}

if {[get_admin_level] ne "Administrator"} {
	skip "This test can't be run without being an Accounting administrator. Use: sacctmgr mod user \$USER set admin=admin"
}

proc modify {job_id constraint reg_ex error_message} {
	global fedc1 fed_slurm_base bin_sleep

	set my_scontrol "${fed_slurm_base}/$fedc1/bin/scontrol"
	set matches 0

	spawn $my_scontrol update jobid=$job_id clusterfeatures=$constraint
	expect {
		-re "$reg_ex" {
			incr matches
		}
		timeout {
			fail "scontrol not responding"
		}
		eof {
			wait
		}
	}
	if {![string match "" $reg_ex] && $matches != 1} {
		fail "Didn't match regex ($reg_ex: $matches)"
	}

	sleep 3
}

proc modify_with_clusters {job_id constraint reg_ex error_message} {
	global fedc1 fed_slurm_base bin_sleep

	set my_scontrol "${fed_slurm_base}/$fedc1/bin/scontrol"
	set matches 0

	spawn $my_scontrol update jobid=$job_id clusters=$constraint
	expect {
		-re "$reg_ex" {
			incr matches
		}
		timeout {
			fail "scontrol not responding"
		}
		eof {
			wait
		}
	}
	if {![string match "" $reg_ex] && $matches != 1} {
		fail "Didn't match regex ($reg_ex: $matches)"
	}

	sleep 3
}

proc sbatch {my_sbatch script constraint args} {

	global number bin_sleep node_count

	set job_id 0
	set command "$my_sbatch -N$node_count --exclusive --output=/dev/null \
		--error=/dev/null -t5 --wrap $script --cluster-constraint=$constraint"

	if {$args ne ""} {
		append command " $args"
	}
	spawn {*}$command
	expect {
		-re "Submitted batch job ($number)" {
			set job_id $expect_out(1,string)
		}
		timeout {
			fail "sbatch not responding"
		}
		eof {
			wait
		}
	}
	if {$job_id == 0} {
		fail "Batch submit failure"
	}

	sleep 3
	return $job_id
}

proc verify {fed job_id pattern error_message} {
	global fed_slurm_base

	set matches 0
	set my_squeue "${fed_slurm_base}/$fed/bin/squeue"
	spawn $my_squeue -a --local -j $job_id --noheader \
		-Ostatecompact:.5,siblingsviable:.20,siblingsactive:.20
	expect {
		-re "\\s+$pattern" {
			incr matches
		}
		eof {
			wait
		}
	}
	if {$matches != 1} {
		fail "$error_message"
	}
}

proc cancel_federation_jobs { } {
	global scancel user_name fedc1 fedc2 fedc3

	spawn $scancel -M$fedc1,$fedc2,$fedc3 --user $user_name
	expect {
		eof {
			wait
		}
	}
	sleep 5
}

proc cleanup { } {
	global fed_name bin_bash bin_rm test_name

	cancel_federation_jobs
	delete_federations $fed_name
	exec $bin_bash -c "$bin_rm -f $test_name*.out"
}

# Start test

if {![check_federation_setup]} {
	skip "This test can't be run without fed_slurm_base, fedc1, fedc2, fedc3 setup in globals.local"
}

if {![check_federation_up]} {
	skip "This test can't be run without all clusters up"
}

set user_name [get_my_user_name]

# Remove existing setup
cleanup

# Add clusters to federation
if [setup_federation $fed_name] {
	fail "Failed to setup federation"
}

# Get number of nodes per cluster
set node_count [llength [get_nodes_by_state]]

log_info "################################################################"
log_info "Setup cluster features"
log_info "################################################################"

set matches 0
spawn $sacctmgr -i modify cluster $fedc1 set features=fa
expect {
	-re "Setting$eol" {
		incr matches
		exp_continue
	}
	-re "^\\s+Feature\\s+=\\s+fa" {
		incr matches
		exp_continue
	}
	-re "Modified cluster...$eol" {
		incr matches
		exp_continue
	}
	-re "^\\s+$fedc1$eol" {
		incr matches
		exp_continue
	}
	timeout {
		fail "sacctmgr mod not responding"
	}
	eof {
		wait
	}
}
if {$matches != 4} {
	fail "Unexpected error (got $matches)"
}

set matches 0
spawn $sacctmgr -i modify cluster $fedc2 set features=fb
expect {
	-re "Setting$eol" {
		incr matches
		exp_continue
	}
	-re "^\\s+Feature\\s+=\\s+fb" {
		incr matches
		exp_continue
	}
	-re "Modified cluster...$eol" {
		incr matches
		exp_continue
	}
	-re "^\\s+$fedc2$eol" {
		incr matches
		exp_continue
	}
	timeout {
		fail "sacctmgr mod not responding"
	}
	eof {
		wait
	}
}
if {$matches != 4} {
	fail "Unexpected error (got $matches)"
}

set matches 0
spawn $sacctmgr -i modify cluster $fedc3 set features=fc
expect {
	-re "Setting$eol" {
		incr matches
		exp_continue
	}
	-re "^\\s+Feature\\s+=\\s+fc" {
		incr matches
		exp_continue
	}
	-re "Modified cluster...$eol" {
		incr matches
		exp_continue
	}
	-re "^\\s+$fedc3$eol" {
		incr matches
		exp_continue
	}
	timeout {
		fail "sacctmgr mod not responding"
	}
	eof {
		wait
	}
}
if {$matches != 4} {
	fail "Unexpected error (got $matches)"
}

set my_scontrol "${fed_slurm_base}/$fedc1/bin/scontrol"

set job_id 0
set script "\"sleep 300\""
set my_sbatch "${fed_slurm_base}/$fedc1/bin/sbatch"

log_info "################################################################"
log_info "Modify Feature of Running Job"
log_info "################################################################"
cancel_federation_jobs

# First job

set job_id [sbatch $my_sbatch $script fa]

verify $fedc1 $job_id "R\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"

modify $job_id fb "Job is no longer pending execution for job $job_id" "allowed user to modify features of running job"

log_info "################################################################"
log_info "Test invalid feature"
log_info "################################################################"
# Second job

set job_id [sbatch $my_sbatch $script fa]

verify $fedc1 $job_id "PD\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"

# Invalid feature

modify $job_id invalid "Invalid cluster feature specification for job" "allowed invalid feature"

log_info "################################################################"
log_info "Move pending job to $fedc2 with feature fb"
log_info "################################################################"
modify $job_id fb "" "did not allow user to modify features of pending job"

set run_cluster [wait_for_fed_job $job_id RUNNING ""]
if {$run_cluster ne $fedc2} {
	fail "Job not running on cluster 2 ($fedc2)"
}
verify $fedc1 $job_id "RV\\s+$fedc2\\s+$fedc2" "Job not revoked"
verify $fedc2 $job_id "R\\s+$fedc2\\s+$fedc2" "Job not running on designated cluster"

log_info "################################################################"
log_info "New job to fa, then move job to $fedc2,$fedc3. Runs on $fedc3"
log_info "################################################################"
# Third job

set job_id [sbatch $my_sbatch $script fa]

modify $job_id "fb,fc" "" "did not allow user to modify features of pending job"

set run_cluster [wait_for_fed_job $job_id RUNNING ""]
if {$run_cluster ne $fedc3} {
	fail "Job not running on cluster 3 ($fedc3)"
}
verify $fedc1 $job_id "RV\\s+$fedc2,$fedc3\\s+$fedc3" "Job not revoked"
verify $fedc3 $job_id "R\\s+$fedc2,$fedc3\\s+$fedc3" "Job not running on designated cluster"

log_info "################################################################"
log_info "New job to fa, then move job to $fedc3"
log_info "################################################################"
# Fourth job

set job_id [sbatch $my_sbatch $script fa]

modify $job_id "fc" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "RV\\s+$fedc3\\s+$fedc3" "Job not revoked"
verify $fedc3 $job_id "PD\\s+$fedc3\\s+NA" "Job not running on designated cluster"

log_info "################################################################"
log_info "Move job to $fedc1,$fedc3"
log_info "################################################################"
modify $job_id "fa,fc" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc3\\s+$fedc1,$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc3\\s+NA" "Job found on wrong cluster"

log_info "################################################################"
log_info "Move job to $fedc1"
log_info "################################################################"
modify $job_id "fa" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

log_info "################################################################"
log_info "Clear features. Should go to pending on $fedc1,$fedc2,$fedc3"
log_info "################################################################"
# Clear Features

modify $job_id "" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

log_info "################################################################"
log_info "Modify Feature of Held Job"
log_info "################################################################"
cancel_federation_jobs

set job_id [sbatch $my_sbatch $script fa -H]

verify $fedc1 $job_id "PD\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify $job_id "fb,fc" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "RV\\s+$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify $job_id "" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify $job_id "fc" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

set my_scontrol "${fed_slurm_base}/$fedc1/bin/scontrol"

log_debug "Releasing job"

exec $my_scontrol release $job_id

sleep 3

set run_cluster [wait_for_fed_job $job_id RUNNING ""]
if {$run_cluster ne $fedc3} {
	fail "Job not running on cluster 3 ($fedc3)"
}
verify $fedc1 $job_id "RV\\s+$fedc3\\s+$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id "R\\s+$fedc3\\s+$fedc3" "Job found on wrong cluster"

log_info "################################################################"
log_info "Test Clearing Features"
log_info "################################################################"

cancel_federation_jobs

# Fill up clusters with jobs

sbatch $my_sbatch $script fa
sbatch $my_sbatch $script fb
sbatch $my_sbatch $script fc

# Add pending job

set job_id [sbatch $my_sbatch $script "" --requeue]

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

modify $job_id "fa" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify $job_id "" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

log_info "################################################################"
log_info "Modify Federation Cluster Features"
log_info "################################################################"
cancel_federation_jobs

sbatch $my_sbatch $script fa
sbatch $my_sbatch $script fb
sbatch $my_sbatch $script fc

set job_id [sbatch $my_sbatch $script ""]

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

modify_with_clusters $job_id "$fedc1" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc2 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify_with_clusters $job_id "$fedc1,$fedc2" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2\\s+$fedc1,$fedc2" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify_with_clusters $job_id "$fedc2" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "RV\\s+$fedc2\\s+$fedc2" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc2\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify_with_clusters $job_id "" "" "did not allow user to modify features of pending job"

verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

# This one shows that the $fedc1 is routing the update from $fedc1 to $fedc2

log_info "################################################################"
log_info "$fedc1 routing the update from $fedc1 to $fedc2"
log_info "################################################################"

set job_id [sbatch $my_sbatch $script "" -M$fedc2]

verify $fedc2 $job_id "PD\\s+$fedc2\\s+$fedc2" "Job not running on designated cluster"
verify $fedc1 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify_with_clusters $job_id "$fedc1" "" "did not allow user to modify features of pending job"

verify $fedc2 $job_id "RV\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc1 $job_id "PD\\s+$fedc1\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify_with_clusters $job_id "" "" "did not allow user to modify features of pending job"

verify $fedc2 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc1 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

# Federations and clusterfeatures ($fedc1 and fb - so the job is not eligible
#				  anywhere beacause it can't have both)

log_info "################################################################"
log_info "Federations and ClusterFeatures"
log_info "################################################################"

modify_with_clusters $job_id "$fedc1" "" "did not allow user to modify features of pending job"

verify $fedc2 $job_id "RV\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc1 $job_id "PD\\s+$fedc1\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify $job_id "fb" "" "did not allow user to modify features of pending job"

verify $fedc2 $job_id "RV\\s+NA\\s+NA" "Job not running on designated cluster"
verify $fedc1 $job_id ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

modify $job_id "fa" "" "did not allow user to modify features of pending job"

verify $fedc2 $job_id "RV\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc1 $job_id "PD\\s+$fedc1\\s+NA" "Job not running on designated cluster"
verify $fedc3 $job_id ".+Invalid.+" "Job found on wrong cluster"

log_info "################################################################"
log_info "Federations and Negative ClusterFeatures"
log_info "################################################################"

cancel_federation_jobs

set jid(0) [sbatch $my_sbatch $script !fc,fb]
set jid(1) [sbatch $my_sbatch $script !fa,fc]
set jid(2) [sbatch $my_sbatch $script !fb,fa]

verify $fedc1 $jid(0) "R\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc2 $jid(1) "R\\s+$fedc2\\s+$fedc2" "Job not running on designated cluster"
verify $fedc3 $jid(2) "R\\s+$fedc3\\s+$fedc3" "Job not running on designated cluster"

# Submit pending job on all clusters then move around using negative constraints

set jid(4) [sbatch $my_sbatch $script ""]

verify $fedc1 $jid(4) "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $jid(4) "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $jid(4) "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

modify $jid(4) "!fb" "" "did not allow user to modify features of pending job"

verify $fedc2 $jid(4) ".+Invalid.+" "Job found on wrong cluster"
verify $fedc1 $jid(4) "PD\\s+$fedc1,$fedc3\\s+" "Job not running on designated cluster"
verify $fedc3 $jid(4) "PD\\s+$fedc1,$fedc3\\s+" "Job not running on designated cluster"

modify $jid(4) "!fc" "" "did not allow user to modify features of pending job"

verify $fedc2 $jid(4) "PD\\s+$fedc1,$fedc2\\s+" "Job not running on designated cluster"
verify $fedc1 $jid(4) "PD\\s+$fedc1,$fedc2\\s+" "Job not running on designated cluster"
verify $fedc3 $jid(4) ".+Invalid.+" "Job found on wrong cluster"

modify $jid(4) "!fa" "" "did not allow user to modify features of pending job"

verify $fedc1 $jid(4) "RV\\s+$fedc2,$fedc3\\s+" "Job found on wrong cluster"
verify $fedc2 $jid(4) "PD\\s+$fedc2,$fedc3\\s+" "Job not running on designated cluster"
verify $fedc3 $jid(4) "PD\\s+$fedc2,$fedc3\\s+" "Job not running on designated cluster"

modify $jid(4) "!fb,fc" "" "did not allow user to modify features of pending job"

verify $fedc2 $jid(4) ".+Invalid.+" "Job found on wrong cluster"
verify $fedc1 $jid(4) "PD\\s+$fedc1\\s+" "Job not running on designated cluster"
verify $fedc3 $jid(4) ".+Invalid.+" "Job found on wrong cluster"

modify $jid(4) "!fa,fc" "" "did not allow user to modify features of pending job"

verify $fedc1 $jid(4) "RV\\s+$fedc2\\s+$fedc2" "Job found on wrong cluster"
verify $fedc2 $jid(4) "PD\\s+$fedc2\\s+" "Job not running on designated cluster"
verify $fedc3 $jid(4) ".+Invalid.+" "Job found on wrong cluster"

modify $jid(4) "!fb,fa" "" "did not allow user to modify features of pending job"

verify $fedc2 $jid(4) ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $jid(4) "PD\\s+$fedc3\\s+" "Job not running on designated cluster"
verify $fedc1 $jid(4) "RV\\s+$fedc3\\s+$fedc3" "Job found on wrong cluster"

# Clear features again

modify $jid(4) "" "" "did not allow user to modify features of pending job"

verify $fedc1 $jid(4) "PD\\s+$fedc1,$fedc2,$fedc3\\s+$fedc1,$fedc2,$fedc3" "Job not running on designated cluster"
verify $fedc2 $jid(4) "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc3 $jid(4) "PD\\s+$fedc1,$fedc2,$fedc3\\s+NA" "Job not running on designated cluster"

# Submit pending jobs to single cluster using negative constraints

set jid(0) [sbatch $my_sbatch $script !fc,fb]

wait_for_fed_job $jid(0) PENDING $fedc1

verify $fedc2 $jid(0) ".+Invalid.+" "Job found on wrong cluster"
verify $fedc1 $jid(0) "PD\\s+$fedc1\\s+$fedc1" "Job not running on designated cluster"
verify $fedc3 $jid(0) ".+Invalid.+" "Job found on wrong cluster"

set jid(0) [sbatch $my_sbatch $script !fa,fb]

sleep 5

verify $fedc2 $jid(0) ".+Invalid.+" "Job found on wrong cluster"
verify $fedc3 $jid(0) "PD\\s+$fedc3\\s+NA" "Job not running on designated cluster"
verify $fedc1 $jid(0) "RV\\s+$fedc3\\s+$fedc3" "Job found on wrong cluster"

set jid(0) [sbatch $my_sbatch $script !fc,fa]

sleep 5

verify $fedc1 $jid(0) "RV\\s+$fedc2\\s+$fedc2" "Job found on wrong cluster"
verify $fedc2 $jid(0) "PD\\s+$fedc2\\s+NA" "Job not running on designated cluster"
verify $fedc3 $jid(0) ".+Invalid.+" "Job found on wrong cluster"

# Error test--negate all clusters

set matches 0

set command "$my_sbatch -N$node_count --exclusive --output=/dev/null \
	--error=/dev/null -t5 --wrap $script --cluster-constraint=!fa,fb,fc"
spawn {*}$command
expect {
	-re ".+Invalid cluster feature specification" {
		incr matches
	}
	timeout {
		fail "sbatch not responding"
	}
	eof {
		wait
	}
}

if {$matches != 1} {
	fail "Batch submit failure"
}