File: test2.19

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 (176 lines) | stat: -rwxr-xr-x 4,730 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
#!/usr/bin/env expect
############################################################################
# Purpose: Test of Slurm functionality
#          Validate that Allow/Deny Qos are enforced.
############################################################################
# Copyright (C) 2013 SchedMD LLC
# Written by Nathan Yee <nyee32@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

set user_name      ""
set node_name      ""
set host_name      ""
set cluster_name   ""
set acct1          "test${test_id}_acct_1"
set acct2          "test${test_id}_acct_2"
set qos_good       "test${test_id}_qos_good"
set qos_bad        "test${test_id}_qos_bad"
set part_name      "test${test_id}_part"

# TODO: Remove this precondition check once Slurm 22.05 is no longer supported
regexp {(\d+).(\d+).(\S+)} [get_config_param SLURM_VERSION] - major minor release
if {$major < 23} {
        skip "This test is disabled in Slurm versions older than 23.02 (see bugs 11979 and 14864)"
}

#
# 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 set_part_val {part_type part_val} {
	global scontrol part_name

	run_command -fail "$scontrol update partitionname=$part_name $part_type=$part_val"
}

proc cleanup { } {
	global scontrol sacctmgr part_name qos_good qos_bad acct1 acct2

	log_debug "Cleaning up, if there are errors they may be ignored..."
	wait_for_part_done $part_name

	run_command "$scontrol delete partition=$part_name"

	run_command "$sacctmgr -i delete qos $qos_good $qos_bad"
	run_command "$sacctmgr -i delete account $acct1 $acct2"
	log_debug "Cleanup done"
}

proc create_qos { acct qos } {
	global sacctmgr user_name cluster_name

	run_command -fail "$sacctmgr -i create qos $qos"
	run_command -fail "$sacctmgr -i create account $acct qos=$qos cluster=$cluster_name"
	run_command -fail "$sacctmgr -i create user $user_name account=$acct cluster=$cluster_name"
}


proc test_part {acct qos part qos_con } {
	global srun part_name

	set sub_job 0

	spawn $srun -I5 -A $acct --qos $qos -p $part true
	expect {
		-re "error" {
			if { $qos_con == 1 } {
				log_debug "This error is expected"
			} else {
				log_error "This error should not have occurred"
				return $::RETURN_ERROR
			}
			exp_continue
		}
		timeout {
			fail "srun is not responding"
		}
		eof {
			wait
		}
	}
	return $::RETURN_SUCCESS
}

# Delete any vestigial qos or accounts
cleanup

# Setup
set user_name [get_my_user_name]
set node_name [lindex [get_nodes_by_state] 0]
set cluster_name [get_config_param "ClusterName"]

# NOTE: qos_good should always work and
# qos_bad should always cause an error

#
# Create good QOS
#
create_qos $acct1 $qos_good

#
# Create bad QOS
#
create_qos $acct2 $qos_bad


# Create partition
run_command -fail "$scontrol create partition=$part_name nodes=$node_name"

#
# Set Allow Qos to good value
#
set_part_val allowqos $qos_good

######Testing AllowQos######
log_info "Testing AllowQos"

#
# Test partition with good Qos
# 0 = good test / 1 = bad test
#
test_part $acct1 $qos_good $part_name 0

#
# Test partition with bad Qos
# 0 = good test / 1 = bad test
#
test_part $acct2 $qos_bad $part_name 1

#
# Set Allow Qos back to all and set
# Deny Qos to bad value
#
set_part_val allowqos ALL
set_part_val denyqos $qos_bad

######Testing DenyQos#####
log_info "Testing DenyQos"

#
# Test partition with good Qos
# 0 = good test / 1 = bad test
#
test_part $acct1 $qos_good $part_name 0

#
# Test partition with bad Qos
# 0 = good test / 1 = bad test
#
test_part $acct2 $qos_bad $part_name 1

sleep 5