File: test3.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 (219 lines) | stat: -rwxr-xr-x 4,705 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
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
#          Testing of hidden partitions.
############################################################################
# Copyright (C) 2002 The Regents of the University of California.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Morris Jette <jette1@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 authorized     1
set part_name      "QA_TEST"

#
# This test can only be run on a development build. If this is not a development
# build, then exit with a warning, but don't fail the test.
# We know it's a development build if the slurm_testsuite_dev_build variable is
# set in globals.local to a nonzero value.
#
if { ![info exists slurm_testsuite_dev_build] || !$slurm_testsuite_dev_build } {
	skip "Cannot run this test on a non-development build. If you are on a development build, set slurm_testsuite_dev_build in globals.local in order to run this test"
}

#
# Set the environment variable to drop privileges for the current test.
#
set ::env(SLURM_TESTSUITE_DROP_PRIV) 1

#
# We only reach this point if a hidden partition must be
# created to test this feature, which only super users can do
#
if {![is_super_user]} {
	skip "Can not test more unless SlurmUser"
}

proc cleanup {} {
	global scontrol part_name

	run_command "$scontrol delete PartitionName=$part_name"
}
cleanup

#
# Confirm that no hidden partition is seen by default
#
spawn  $scontrol show part
expect {
	-re "Hidden=YES" {
		fail "scontrol hidden partition seen"
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}

#
# Check if any hidden partitions exist
#
set found 0
spawn  $scontrol -a show part
expect {
	-re "Hidden=YES" {
		set found 1
		exp_continue
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}
if {$found == 1} {
	fail "Hidden partitions were found"
}

#
# Confirm the partition name does not already exist
#
set found -1
spawn $scontrol -a show part $part_name
expect {
	-re "not found" {
		log_debug "This error was expected, no worries"
		set found 0
		exp_continue
	}
	-re "PartitionName" {
		set found 1
		exp_continue
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}
if {$found == -1} {
	fail "scontrol output format error"
}
if {$found == 1} {
	fail "Partition ($part_name) already exists"
}

#
# Unset the drop privileges environment variable so a partition can be created.
#
unset ::env(SLURM_TESTSUITE_DROP_PRIV)

#
# Create a new partition
#
spawn $scontrol create PartitionName=$part_name Hidden=YES
expect {
	-re "error" {
		fail "Something bad happened on partition create"
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}

#
# Confirm the partition now exists
#
set found -1
set hidden 0
spawn $scontrol -a show part $part_name
expect {
	-re "not found" {
		set found 0
		exp_continue
	}
	-re "PartitionName" {
		set found 1
		exp_continue
	}
	-re "Hidden=YES" {
		set hidden 1
		exp_continue
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}
if {$found != 1} {
	fail "Partition not created"
}
subtest {$hidden != 0} "Partition should be hidden"

#
# Now delete the partition
#
spawn $scontrol delete PartitionName=$part_name
expect {
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}

#
# Confirm the partition is now gone
#
set found -1
spawn $scontrol -a show part $part_name
expect {
	-re "not found" {
		log_debug "This error was expected, no worries"
		set found 0
		exp_continue
	}
	-re "PartitionName" {
		set found 1
		exp_continue
	}
	timeout {
		fail "scontrol not responding"
	}
	eof {
		wait
	}
}
if {$found != 0} {
	fail "Partition not deleted"
}