File: test1.52

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 (155 lines) | stat: -rwxr-xr-x 4,646 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
#!/usr/bin/env expect
############################################################################
# Purpose: Test of srun functionality
#          Test of hostfile option (-hostfile).
############################################################################
# Copyright (C) 2002-2007 The Regents of the University of California.
# Copyright (C) 2008-2009  Lawrence Livermore National Security.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Danny Auble <da@llnl.gov>
# CODE-OCEC-09-009. All rights reserved.
#
# 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

set num_nodes   2
set num_tasks   2
set idle_nodes  0
set max_nodes   0
set task_count  0
set hostfile    "$test_dir/hostfile"

if {[get_config_param "FrontendName"] ne "MISSING"} {
	skip "This test incompatible with front-end systems"
}

# Determine if we have enough nodes to test functionality
spawn $scontrol show partition [default_partition]
expect {
	-re "not found" {
		fail "Default partition doesn't exist"
	}
	-re "MaxNodes=($number)" {
		set max_nodes $expect_out(1,string)
		exp_continue
	}
	-re "MaxNodes=UNLIMITED" {
		set max_nodes 999999
		exp_continue
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}

set idle_nodes [llength [get_nodes_by_state]]
if { ($idle_nodes < 3) || ($max_nodes < 3) } {
	if { $max_nodes == 999999 } {
		skip "Default partition must have at least 3 idle nodes and MaxNodes >= 3 to run this test on. IDLE:$idle_nodes MaxNodes:UNLIMITED"
	} else {
		skip "Default partition must have at least 3 idle nodes and MaxNodes >= 3 to run this test on. IDLE:$idle_nodes MaxNodes:$max_nodes"
	}
}

exec $bin_rm -f %hostfile
set node0       0
set node1       0
set node2       0
set timeout $max_job_delay
for {set i 0} {$i<3} {incr i} {
	if { $i==1 } {
		if { $node0 == 0 || $node1 == 0 || $node2 == 0 } {
			fail "Node names not set from previous srun"
		}
		set env(SLURM_HOSTFILE) $hostfile
		set 1node0 $node2
		set 1node1 $node0
		set 1node2 $node1
		set file [open $hostfile "w"]
		puts $file "$node2\n$node0\n$node1"
		close $file
	} elseif { $i==2 } {
		if { $node0 == 0 || $node1 == 0 || $node2 == 0 } {
			fail "Node names not set from previous srun"
		}
		set env(SLURM_HOSTFILE) $hostfile
		set 2node0 $node1
		set 2node1 $node0
		set 2node2 $node2
		set file [open $hostfile "w"]
		puts $file "$node1\n$node0\n$node2"
		close $file
	}

	#
	# execute srun with a specific node count
	#
	set node0  0
	set node1  0
	set node2  0
	set task_cnt 0
	if { $i == 0} {
		spawn $srun -N3 -t1 -l $bin_printenv SLURMD_NODENAME
	} else {
		spawn $srun -N3 -t1 -l --distribution=arbitrary $bin_printenv SLURMD_NODENAME
	}
	expect {
		-re "($number): ($re_word_str)" {
			incr task_cnt
			set task_id $expect_out(1,string)
			if {$task_id == 0} {
				set node0 $expect_out(2,string)
			} elseif {$task_id == 1} {
				set node1 $expect_out(2,string)
			} else {
				set node2 $expect_out(2,string)
			}
			exp_continue
		}
		timeout {
			fail "srun not responding"
		}
		eof {
			wait
		}
	}
	if { $task_cnt != 3 } {
		log_warn "No worries, test just can not run here"
	} elseif { $i == 1 } {
		if {$node0 ne $1node0} {
			fail "Task 0 not distributed by hostfile ($node0 != $1node0)"
		} elseif {$node1 ne $1node1} {
			fail "Task 1 not distributed by hostfile ($node1 != $1node1)"
		} elseif {$node2 ne $1node2} {
			fail "Task 2 not distributed by hostfile ($node2 != $1node2)"
		}
	} elseif { $i == 2 } {
		if {$node0 ne $2node0} {
			fail "Task 0 not distributed by hostfile ($node0 != $2node0)"
		} elseif {$node1 ne $2node1} {
			fail "Task 1 not distributed by hostfile ($node1 != $2node1)"
		} elseif {$node2 ne $2node2} {
			fail "Task 2 not distributed by hostfile ($node2 != $2node2)"
		}
	}
}