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
|
#!/usr/bin/env expect
############################################################################
# Purpose: Test federation functionality
# Test scontrol show federations
# Test that persistent connections are made
#
# 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.
# federation/slurm/ (src)
# federation/fed1/bin
# federation/fed1/sbin
# federation/fed1/etc
# federation/fed1/...
# federation/fed2/...
# federation/fed3/...
# 3. controllers are up and running.
############################################################################
# Copyright (C) 2016 SchedMD LLC.
# Written by Brian Christiansen <brian@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 timeout 5
#
# 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 cleanup { } {
global fed_name
delete_federations $fed_name
}
proc test_fed_status {cname fed_flags cluster_list} {
# Match db info with what cluster has.
global fed_slurm_base fed_name eol
array set clusters $cluster_list
set matches 0
set lines 0
set my_scontrol "${fed_slurm_base}/$cname/bin/scontrol"
spawn $my_scontrol show federation
set expected_matches [array size clusters]
if {$expected_matches} {
# Match the fedname line
incr expected_matches
}
expect {
-re "$eol" {
incr lines
set line $expect_out(buffer)
log_debug "Line: $line"
if {[regexp "Federation: $fed_name" $line match]} {
log_debug "Matched: $match"
incr matches
} elseif {[regexp {Self:\s+(\S+):(\S+):(\d+) ID:(\d+) FedState:(\S*) Features:(\S*)} \
$line match name host port id state features]} {
log_debug "Matched: $match"
if {$expected_matches &&
[dict get $clusters($name) host] eq $host &&
[dict get $clusters($name) state] eq $state &&
[dict get $clusters($name) features] eq $features] &&
[dict get $clusters($name) conn] eq Self &&
[dict get $clusters($name) port] == $port &&
[dict get $clusters($name) id] == $id} {
log_debug "Matched self: $name"
incr matches
}
} elseif {[regexp {Sibling:\s+(\S+):(\S+):(\d+) ID:(\d+) FedState:(\S*) Features:(\S*) PersistConnSend/Recv:(\S+)} \
$line match name host port id state features conn]} {
log_debug "Matched: $match"
if {$expected_matches &&
[dict get $clusters($name) host] eq $host &&
[dict get $clusters($name) state] eq $state &&
[dict get $clusters($name) features] eq $features &&
[dict get $clusters($name) conn] eq $conn &&
[dict get $clusters($name) port] == $port &&
[dict get $clusters($name) id] == $id} {
log_debug "Matched sibling: $name"
incr matches
}
}
exp_continue
}
timeout {
fail "scontrol not responding"
}
eof {
wait
}
}
if {$lines != $expected_matches} {
fail "Line count and expected matches don't match ($lines != $expected_matches)"
}
if {$matches != $expected_matches} {
fail "Failed to match ($matches != $expected_matches)"
}
}
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"
}
# Remove existing setup
cleanup
# add clusters to federation
if [setup_federation $fed_name] {
fail "Failed to setup federation"
}
# Get cluster/fed info from db
array set clusters [get_clusterfed_info $fed_name]
set fed_flags "None"
log_info "Test from $fedc1"
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Test from $fedc2"
dict set clusters($fedc1) conn "Yes/Yes"
dict set clusters($fedc2) conn Self
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc2 $fed_flags [array get clusters]
log_info "Test from $fedc3"
dict set clusters($fedc1) conn "Yes/Yes"
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn Self
test_fed_status $fedc3 $fed_flags [array get clusters]
log_info "Remove $fedc3 and test from $fedc1 and $fedc2"
if [remove_cluster_from_fed $fedc3 $fed_name] {
fail "Unable to remove cluster 3 ($fedc3) from federation ($fed_name)"
}
array unset clusters $fedc3
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
dict set clusters($fedc1) conn "Yes/Yes"
dict set clusters($fedc2) conn Self
test_fed_status $fedc2 $fed_flags [array get clusters]
log_info "Remove $fedc1 and test from $fedc2"
if [remove_cluster_from_fed $fedc1 $fed_name] {
fail "Unable to remove cluster 1 ($fedc1) from federation ($fed_name)"
}
array unset clusters $fedc1
dict set clusters($fedc2) conn Self
test_fed_status $fedc2 $fed_flags [array get clusters]
log_info "Remove $fedc2 and test from $fedc2"
array unset clusters
if [remove_cluster_from_fed $fedc2 $fed_name] {
fail "Unable to remove cluster 2 ($fedc2) from federation ($fed_name)"
}
test_fed_status $fedc2 $fed_flags [array get clusters]
log_info "Add $fedc1 and test from $fedc1"
if [add_cluster_to_fed $fedc1 $fed_name] {
fail "Unable to add cluster 1 ($fedc1) to federation ($fed_name)"
}
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Add $fedc2 and test from $fedc1"
if [add_cluster_to_fed $fedc2 $fed_name] {
fail "Unable to add cluster 2 ($fedc2) to federation ($fed_name)"
}
sleep 5
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Add $fedc3 and test from $fedc1"
if [add_cluster_to_fed $fedc3 $fed_name] {
fail "Unable to add cluster 3 ($fedc3) to federation ($fed_name)"
}
sleep 5
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
#log_info "Test federation flags (LLC)"
#set matches 0
#spawn $sacctmgr -i modify federation $fed_name set flags+=LLC
#expect {
# -re "Setting$eol" {
# incr matches
# exp_continue
# }
# -re "^\\s+Flags\\s+\\+=\\s+LLC$eol" {
# incr matches
# exp_continue
# }
# -re "^\\s+Modified federation...$eol" {
# incr matches
# exp_continue
# }
# -re "^\\s+$fed_name$eol" {
# incr matches
# exp_continue
# }
# timeout {
# fail "sacctmgr add not responding"
# }
# eof {
# wait
# }
#}
#if {$matches != 4} {
# fail "Setting LLC flag"
#}
#
#set fed_flags "LLC"
#array set clusters [get_clusterfed_info $fed_name]
#dict set clusters($fedc1) conn Self
#dict set clusters($fedc2) conn "Yes/Yes"
#dict set clusters($fedc3) conn "Yes/Yes"
#test_fed_status $fedc1 $fed_flags [array get clusters]
#
#
#log_info "Test removal of federation flags (LLC)"
#set matches 0
#spawn $sacctmgr -i modify federation $fed_name set flags-=LLC
#expect {
# -re "Setting$eol" {
# incr matches
# exp_continue
# }
# -re "^\\s+Flags\\s+\\-=\\s+LLC$eol" {
# incr matches
# exp_continue
# }
# -re "^\\s+Modified federation...$eol" {
# incr matches
# exp_continue
# }
# -re "^\\s+$fed_name$eol" {
# incr matches
# exp_continue
# }
# timeout {
# fail "sacctmgr add not responding"
# }
# eof {
# wait
# }
#}
#if {$matches != 4} {
# fail "Removing federation flags (got $matches)"
#}
#
#set fed_flags "None"
#array set clusters [get_clusterfed_info $fed_name]
#dict set clusters($fedc1) conn Self
#dict set clusters($fedc2) conn "Yes/Yes"
#dict set clusters($fedc3) conn "Yes/Yes"
#test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Test setting of cluster features"
set matches 0
spawn $sacctmgr -i modify cluster $fedc3 set features=fb,fa
expect {
-re "Setting$eol" {
incr matches
exp_continue
}
-re "\\s+Feature\\s+=\\s+fb$eol" {
incr matches
exp_continue
}
-re "\\s+Feature\\s+=\\s+fa$eol" {
incr matches
exp_continue
}
-re "Modified cluster...$eol" {
incr matches
exp_continue
}
-re "^\\s+$fedc3$eol" {
incr matches
exp_continue
}
timeout {
fail "sacctmgr add not responding"
}
eof {
wait
}
}
if {$matches != 5} {
fail "Unexpected error (got $matches)"
}
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Test modifying/add of cluster features"
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$eol" {
incr matches
exp_continue
}
-re "Modified cluster...$eol" {
incr matches
exp_continue
}
-re "^\\s+$fedc3$eol" {
incr matches
exp_continue
}
timeout {
fail "sacctmgr add not responding"
}
eof {
wait
}
}
if {$matches != 4} {
fail "Unexpected error (got $matches)"
}
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Test modifying/remove of cluster features"
set matches 0
spawn $sacctmgr -i modify cluster $fedc3 set features-=fb
expect {
-re "Setting$eol" {
incr matches
exp_continue
}
-re "\\s+Feature\\s+-=\\s+fb$eol" {
incr matches
exp_continue
}
-re "Modified cluster...$eol" {
incr matches
exp_continue
}
-re "^\\s+$fedc3$eol" {
incr matches
exp_continue
}
timeout {
fail "sacctmgr add not responding"
}
eof {
wait
}
}
if {$matches != 4} {
fail "Unexpected error (got $matches)"
}
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Test clearing of cluster features"
set matches 0
spawn $sacctmgr -i modify cluster $fedc3 set features=
expect {
-re "Setting$eol" {
incr matches
exp_continue
}
-re "\\s+Feature\\s+=\\s+$eol" {
incr matches
exp_continue
}
-re "Modified cluster...$eol" {
incr matches
exp_continue
}
-re "^\\s+$fedc3$eol" {
incr matches
exp_continue
}
timeout {
fail "sacctmgr add not responding"
}
eof {
wait
}
}
if {$matches != 4} {
fail "Unexpected error (got $matches)"
}
array set clusters [get_clusterfed_info $fed_name]
dict set clusters($fedc1) conn Self
dict set clusters($fedc2) conn "Yes/Yes"
dict set clusters($fedc3) conn "Yes/Yes"
test_fed_status $fedc1 $fed_flags [array get clusters]
log_info "Delete federation and test from $fedc1"
delete_federations $fed_name
array unset clusters
test_fed_status $fedc2 $fed_flags [array get clusters]
|