1#!/usr/bin/env expect 2############################################################################ 3# Purpose: Test of Slurm functionality 4# sacctmgr federation functionality 5############################################################################ 6# Copyright (C) 2016 SchedMD LLC. 7# Written by Brian Christiansen <brian@schedmd.com> 8# 9# This file is part of Slurm, a resource management program. 10# For details, see <https://slurm.schedmd.com/>. 11# Please also read the included file: DISCLAIMER. 12# 13# Slurm is free software; you can redistribute it and/or modify it under 14# the terms of the GNU General Public License as published by the Free 15# Software Foundation; either version 2 of the License, or (at your option) 16# any later version. 17# 18# Slurm is distributed in the hope that it will be useful, but WITHOUT ANY 19# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21# details. 22# 23# You should have received a copy of the GNU General Public License along 24# with Slurm; if not, write to the Free Software Foundation, Inc., 25# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 26############################################################################ 27 28source ./globals 29source ./globals_accounting 30 31set test_id_2 "37_1" 32set max_federations 64 33 34# Test Clusters 35set tc1 "tc1_$test_id_2" 36set tc2 "tc2_$test_id_2" 37set tc3 "tc3_$test_id_2" 38set tc4 "tc4_$test_id_2" 39set tc5 "tc5_$test_id_2" 40 41set fed1 "fed1_$test_id_2" 42set fed2 "fed2_$test_id_2" 43set fed3 "fed3_$test_id_2" 44 45set timeout 60 46 47# 48# Check accounting config and bail if not found. 49# 50if {[get_config_param "AccountingStorageType"] ne "accounting_storage/slurmdbd"} { 51 skip "This test can't be run without a usable AccountStorageType" 52} 53 54if {[string compare [get_admin_level] "Administrator"]} { 55 skip "This test can't be run without being an Accounting administrator. Use: sacctmgr mod user \$USER set admin=admin" 56} 57 58proc delete_object { object names } { 59 global sacctmgr 60 set matches 0 61 set rc 0 62 set my_pid [spawn $sacctmgr -i delete $object $names] 63 expect { 64 -re "privilege to perform this action" { 65 log_error "Don't have privileges" 66 incr rc 67 exp_continue 68 } 69 -re "(There was a problem|Unknown condition|Bad format on|Bad MaxWall|Unknown option)" { 70 log_error "There was a problem with the sacctmgr command" 71 incr rc 72 exp_continue 73 } 74 -re "Problem getting" { 75 log_error "There was a problem getting information from the database" 76 incr rc 77 exp_continue 78 } 79 -re "Problem adding" { 80 log_error "There was an unknown problem" 81 incr rc 82 exp_continue 83 } 84 -re "No associations" { 85 log_error "Your command didn't return anything" 86 incr rc 87 exp_continue 88 } 89 -re "Deleting $object" { 90 incr matches 91 exp_continue 92 } 93 -re " Nothing deleted" { 94 incr matches 95 exp_continue 96 } 97 timeout { 98 log_error "sacctmgr delete not responding" 99 slow_kill $my_pid 100 incr rc 101 } 102 eof { 103 wait 104 } 105 } 106 107 if {$matches != 1} { 108 log_error "sacctmgr had a problem deleting $object got $matches" 109 incr rc 110 } 111 112 return $rc 113} 114 115proc delete_clusters { names } { 116 return [delete_object "cluster" $names] 117} 118 119proc delete_federations { names } { 120 return [delete_object "federation" $names] 121} 122 123proc cleanup { } { 124 global tc1 tc2 tc3 tc4 tc5 fed1 fed2 fed3 test_id_2 max_federations 125 126 set tmp_clusters "" 127 for {set i 0} {$i <= $max_federations} {incr i} { 128 append tmp_clusters "max${i}_$test_id_2," 129 } 130 131 if [delete_clusters "$tc1,$tc2,$tc3,$tc4,$tc5,${tmp_clusters}"] { 132 log_error "Unable to delete clusters ($tc1,$tc2,$tc3,$tc4,$tc5,${tmp_clusters})" 133 } 134 if [delete_federations "$fed1,$fed2,$fed3"] { 135 log_error "Unable to delete federations ($fed1,$fed2,$fed3)" 136 } 137} 138 139# 140# Use sacctmgr to delete the test cluster 141# 142set nothing 0 143set matches 0 144 145######MAIN###### 146##################################### 147# TEST: add federation with non-existant cluster(s) 148##################################### 149set matches 0 150set my_pid [spawn $sacctmgr -i add federation $fed1 cluster=$tc1] 151expect { 152 -re "The cluster $tc1 doesn't exist\\. Please add first\\." { 153 incr matches 154 exp_continue 155 } 156 timeout { 157 slow_kill $my_pid 158 fail "sacctmgr add not responding" 159 } 160 eof { 161 wait 162 } 163} 164if {$matches == 0} { 165 fail "Adding invalid federation failed unexpectedly" 166} 167 168set matches 0 169set my_pid [spawn $sacctmgr -i add federation $fed1 cluster=$tc1,$tc2] 170expect { 171 -re "The cluster $tc1 doesn't exist\\. Please add first\\." { 172 incr matches 173 exp_continue 174 } 175 -re "The cluster $tc2 doesn't exist\\. Please add first\\." { 176 incr matches 177 exp_continue 178 } 179 timeout { 180 slow_kill $my_pid 181 fail "sacctmgr add not responding" 182 } 183 eof { 184 wait 185 } 186} 187if {$matches != 2} { 188 fail "Adding invalid federation failed unexpectedly" 189} 190 191##################################### 192# TEST: add cluster to non-existant federation 193##################################### 194set matches 0 195set my_pid [spawn $sacctmgr -i add cluster $tc1 federation=$fed1] 196expect { 197 -re "The federation $fed1 doesn't exist\\." { 198 incr matches 199 exp_continue 200 } 201 timeout { 202 slow_kill $my_pid 203 fail "sacctmgr add not responding" 204 } 205 eof { 206 wait 207 } 208} 209if {$matches != 1} { 210 fail "Unexpected error" 211} 212 213##################################### 214# TEST: add new federation 215##################################### 216set matches 0 217set my_pid [spawn $sacctmgr -i add federation $fed1] 218expect { 219 -re "Adding Federation\\(s\\)$eol" { 220 incr matches 221 exp_continue 222 } 223 -re "$fed1$eol" { 224 incr matches 225 exp_continue 226 } 227 timeout { 228 slow_kill $my_pid 229 fail "sacctmgr add not responding" 230 } 231 eof { 232 wait 233 } 234} 235if {$matches != 2} { 236 fail "Adding federation failed unexpectedly" 237} 238 239set matches 0 240set my_pid [spawn $sacctmgr show federation $fed1 format=federation%20] 241expect { 242 -re "Federation $eol" { 243 incr matches 244 exp_continue 245 } 246 -re "\\s+$fed1 $eol" { 247 incr matches 248 exp_continue 249 } 250 timeout { 251 slow_kill $my_pid 252 fail "sacctmgr add not responding" 253 } 254 eof { 255 wait 256 } 257} 258if {$matches != 2} { 259 fail "Adding federation failed unexpectedly. Got $matches" 260} 261 262##################################### 263# TEST: add new federation - already exists 264##################################### 265set matches 0 266set my_pid [spawn $sacctmgr -i add federation $fed1] 267expect { 268 -re "This federation $fed1 already exists\\. Not adding\\.$eol" { 269 incr matches 270 exp_continue 271 } 272 timeout { 273 slow_kill $my_pid 274 fail "sacctmgr add not responding" 275 } 276 eof { 277 wait 278 } 279} 280if {$matches != 1} { 281 fail "Adding federation failed unexpectedly" 282} 283 284##################################### 285# TEST: add second federation and make sure that you can select only one federation 286##################################### 287set matches 0 288set my_pid [spawn $sacctmgr -i add federation $fed2] 289expect { 290 -re "Adding Federation\\(s\\)$eol" { 291 incr matches 292 exp_continue 293 } 294 -re "\\s+$fed2$eol" { 295 incr matches 296 exp_continue 297 } 298 timeout { 299 slow_kill $my_pid 300 fail "sacctmgr add not responding" 301 } 302 eof { 303 wait 304 } 305} 306if {$matches != 2} { 307 fail "Adding federation failed unexpectedly" 308} 309 310set matches 0 311set my_pid [spawn $sacctmgr show federation format=federation%20] 312expect { 313 -re "Federation $eol" { 314 incr matches 315 exp_continue 316 } 317 -re "\\s+$fed1 $eol" { 318 incr matches 319 exp_continue 320 } 321 -re "\\s+$fed2 $eol" { 322 incr matches 323 exp_continue 324 } 325 timeout { 326 slow_kill $my_pid 327 fail "sacctmgr add not responding" 328 } 329 eof { 330 wait 331 } 332} 333if {$matches != 3} { 334 fail "Adding federation failed unexpectedly" 335} 336 337set matches 0 338set my_pid [spawn $sacctmgr show federation $fed1 format=federation%20] 339expect { 340 -re "Federation $eol" { 341 incr matches 342 exp_continue 343 } 344 -re "\\s+$fed1 $eol" { 345 incr matches 346 exp_continue 347 } 348 -re "\\s+$fed2 $eol" { 349 incr matches 350 exp_continue 351 } 352 timeout { 353 slow_kill $my_pid 354 fail "sacctmgr add not responding" 355 } 356 eof { 357 wait 358 } 359} 360if {$matches != 2} { 361 fail "Adding federation failed unexpectedly" 362} 363 364##################################### 365# TEST: add new cluster to existing federation 366# TEST: add new cluster with state 367##################################### 368set matches 0 369set my_pid [spawn $sacctmgr -i add cluster $tc1 federation=$fed1 fedstate=drain] 370expect { 371 -re "Adding Cluster\\(s\\)$eol" { 372 incr matches 373 exp_continue 374 } 375 -re "\\s+$tc1$eol" { 376 incr matches 377 exp_continue 378 } 379 -re "\\s+Setting$eol" { 380 incr matches 381 exp_continue 382 } 383 -re "\\s+Federation\\s+=\\s+$fed1$eol" { 384 incr matches 385 exp_continue 386 } 387 -re "\\s+FedState\\s+=\\s+DRAIN$eol" { 388 incr matches 389 exp_continue 390 } 391 timeout { 392 slow_kill $my_pid 393 fail "sacctmgr add not responding" 394 } 395 eof { 396 wait 397 } 398} 399if {$matches != 5} { 400 fail "Unexpected error" 401} 402 403##################################### 404# TEST: add multiple new clusters to single federation 405##################################### 406set matches 0 407set my_pid [spawn $sacctmgr -i add cluster $tc2 $tc3 federation=$fed2] 408expect { 409 -re "Adding Cluster\\(s\\)$eol" { 410 incr matches 411 exp_continue 412 } 413 -re "\\s+$tc2$eol" { 414 incr matches 415 exp_continue 416 } 417 -re "\\s+$tc3$eol" { 418 incr matches 419 exp_continue 420 } 421 -re "\\s+Setting$eol" { 422 incr matches 423 exp_continue 424 } 425 -re "\\s+Federation\\s+=\\s+$fed2$eol" { 426 incr matches 427 exp_continue 428 } 429 timeout { 430 slow_kill $my_pid 431 fail "sacctmgr add not responding" 432 } 433 eof { 434 wait 435 } 436} 437if {$matches != 5} { 438 fail "Unexpected error" 439} 440 441set matches 0 442set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 format="cluster%20,federation%20,fedstate%20,id"] 443expect { 444 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 445 incr matches 446 exp_continue 447 } 448 -re "\\s+$tc1\\s+$fed1\\s+DRAIN\\s+1 $eol" { 449 incr matches 450 exp_continue 451 } 452 -re "\\s+$tc2\\s+$fed2\\s+ACTIVE\\s+1 $eol" { 453 incr matches 454 exp_continue 455 } 456 -re "\\s+$tc3\\s+$fed2\\s+ACTIVE\\s+2 $eol" { 457 incr matches 458 exp_continue 459 } 460 timeout { 461 slow_kill $my_pid 462 fail "sacctmgr add not responding" 463 } 464 eof { 465 wait 466 } 467} 468if {$matches != 4} { 469 fail "Unexpected error" 470} 471 472 473#Test show cluster WithFed 474set matches 0 475set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 WithFed] 476expect { 477 -re "Cluster\\s+.*?Federation\\s+ID\\s+Features\\s+FedState $eol" { 478 incr matches 479 exp_continue 480 } 481 -re "\\s+$tc1\\s+.*?$fed1\\s+1\\s+DRAIN $eol" { 482 incr matches 483 exp_continue 484 } 485 -re "\\s+$tc2\\s+.*?$fed2\\s+1\\s+ACTIVE $eol" { 486 incr matches 487 exp_continue 488 } 489 -re "\\s+$tc3\\s+.*?$fed2\\s+2\\s+ACTIVE $eol" { 490 incr matches 491 exp_continue 492 } 493 timeout { 494 slow_kill $my_pid 495 fail "sacctmgr add not responding" 496 } 497 eof { 498 wait 499 } 500} 501if {$matches != 4} { 502 fail "Unexpected error" 503} 504 505set matches 0 506set my_pid [spawn $sacctmgr show federation $fed1 $fed2 format="federation%20,cluster%20"] 507expect { 508 -re "Federation\\s+Cluster $eol" { 509 incr matches 510 exp_continue 511 } 512 -re "\\s+$fed1\\s+$tc1 $eol" { 513 incr matches 514 exp_continue 515 } 516 -re "\\s+$fed2\\s+$tc2 $eol" { 517 incr matches 518 exp_continue 519 } 520 -re "\\s+$fed2\\s+$tc3 $eol" { 521 incr matches 522 exp_continue 523 } 524 timeout { 525 slow_kill $my_pid 526 fail "sacctmgr add not responding" 527 } 528 eof { 529 wait 530 } 531} 532if {$matches != 4} { 533 fail "Unexpected error" 534} 535 536# TEST tree option - shows one federation line per federation. 537set matches 0 538set my_pid [spawn $sacctmgr show federation $fed1 $fed2 format="federation%20,cluster%20" tree] 539expect { 540 -re "Federation\\s+Cluster $eol" { 541 incr matches 542 exp_continue 543 } 544 -re "\\s+$fed1\\s+$eol" { 545 incr matches 546 exp_continue 547 } 548 -re "^\\s+$tc1 $eol" { 549 incr matches 550 exp_continue 551 } 552 -re "\\s+$fed2\\s+$eol" { 553 incr matches 554 exp_continue 555 } 556 -re "^\\s+$tc2 $eol" { 557 incr matches 558 exp_continue 559 } 560 -re "^\\s+$tc3 $eol" { 561 incr matches 562 exp_continue 563 } 564 timeout { 565 slow_kill $my_pid 566 fail "sacctmgr add not responding" 567 } 568 eof { 569 wait 570 } 571} 572if {$matches != 6} { 573 fail "Unexpected error" 574} 575 576 577##################################### 578# TEST: attempt to set clusters to multiple federations 579##################################### 580set matches 0 581set my_pid [spawn $sacctmgr -i modify federation $fed1 $fed2 set clusters=$tc1] 582expect { 583 -re "Can't assign clusters to multiple federations\\." { 584 incr matches 585 exp_continue 586 } 587 timeout { 588 slow_kill $my_pid 589 fail "sacctmgr add not responding" 590 } 591 eof { 592 wait 593 } 594} 595if {$matches != 1} { 596 fail "Unexpected error" 597} 598 599##################################### 600# TEST: attempt to set clusters with no where clause 601##################################### 602set matches 0 603set my_pid [spawn $sacctmgr -i modify federation set clusters=$tc1] 604expect { 605 -re "Can't assign clusters to multiple federations\\." { 606 incr matches 607 exp_continue 608 } 609 timeout { 610 slow_kill $my_pid 611 fail "sacctmgr add not responding" 612 } 613 eof { 614 wait 615 } 616} 617if {$matches != 1} { 618 fail "Unexpected error" 619} 620 621set matches 0 622set my_pid [spawn $sacctmgr -i modify federation set clusters=$tc1 where cluster=$tc1] 623expect { 624 -re "Can't assign clusters to multiple federations\\." { 625 incr matches 626 exp_continue 627 } 628 timeout { 629 slow_kill $my_pid 630 fail "sacctmgr add not responding" 631 } 632 eof { 633 wait 634 } 635} 636if {$matches != 1} { 637 fail "Unexpected error" 638} 639 640##################################### 641# TEST: modify clusters with fed options 642##################################### 643set matches 0 644set my_pid [spawn $sacctmgr -i modify cluster $tc1 $tc3 set fedstate=DRAIN] 645expect { 646 -re "Setting$eol" { 647 incr matches 648 exp_continue 649 } 650 -re "^\\s+FedState\\s+=\\s+DRAIN$eol" { 651 incr matches 652 exp_continue 653 } 654 -re "Modified cluster...$eol" { 655 incr matches 656 exp_continue 657 } 658 -re "^\\s+$tc1$eol" { 659 incr matches 660 exp_continue 661 } 662 -re "^\\s+$tc3$eol" { 663 incr matches 664 exp_continue 665 } 666 timeout { 667 slow_kill $my_pid 668 fail "sacctmgr add not responding" 669 } 670 eof { 671 wait 672 } 673} 674if {$matches != 5} { 675 fail "Unexpected error" 676} 677 678set matches 0 679set my_pid [spawn $sacctmgr -i modify cluster $tc2 set fedstate=DRAIN+REMOVE] 680expect { 681 -re "Setting$eol" { 682 incr matches 683 exp_continue 684 } 685 -re "^\\s+FedState\\s+=\\s+DRAIN\\+REMOVE$eol" { 686 incr matches 687 exp_continue 688 } 689 -re "Modified cluster...$eol" { 690 incr matches 691 exp_continue 692 } 693 -re "^\\s+$tc2$eol" { 694 incr matches 695 exp_continue 696 } 697 timeout { 698 slow_kill $my_pid 699 fail "sacctmgr add not responding" 700 } 701 eof { 702 wait 703 } 704} 705if {$matches != 4} { 706 fail "Unexpected error" 707} 708 709set matches 0 710set my_pid [spawn $sacctmgr -i modify cluster $tc1 set fedstate=ACTIVE] 711expect { 712 -re "Setting$eol" { 713 incr matches 714 exp_continue 715 } 716 -re "^\\s+FedState\\s+=\\s+ACTIVE$eol" { 717 incr matches 718 exp_continue 719 } 720 -re "Modified cluster...$eol" { 721 incr matches 722 exp_continue 723 } 724 -re "^\\s+$tc1$eol" { 725 incr matches 726 exp_continue 727 } 728 timeout { 729 slow_kill $my_pid 730 fail "sacctmgr add not responding" 731 } 732 eof { 733 wait 734 } 735} 736if {$matches != 4} { 737 fail "Unexpected error" 738} 739 740set matches 0 741set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 format="cluster%20,federation%20,fedstate%20"] 742expect { 743 -re "Cluster\\s+Federation\\s+FedState $eol" { 744 incr matches 745 exp_continue 746 } 747 -re "\\s+$tc1\\s+$fed1\\s+ACTIVE $eol" { 748 incr matches 749 exp_continue 750 } 751 -re "\\s+$tc2\\s+$fed2\\s+DRAIN\\+REMOVE $eol" { 752 incr matches 753 exp_continue 754 } 755 -re "\\s+$tc3\\s+$fed2\\s+DRAIN $eol" { 756 incr matches 757 exp_continue 758 } 759 timeout { 760 slow_kill $my_pid 761 fail "sacctmgr add not responding" 762 } 763 eof { 764 wait 765 } 766} 767if {$matches != 4} { 768 fail "Unexpected error" 769} 770 771###################################### 772## TEST: modify federation with flags 773###################################### 774#set matches 0 775#set my_pid [spawn $sacctmgr -i modify federation $fed1 $fed2 set flags+=LLC] 776#expect { 777# -re "Setting$eol" { 778# incr matches 779# exp_continue 780# } 781# -re "^\\s+Flags\\s+\\+=\\s+LLC$eol" { 782# incr matches 783# exp_continue 784# } 785# -re "^\\s+Modified federation...$eol" { 786# incr matches 787# exp_continue 788# } 789# -re "^\\s+$fed1$eol" { 790# incr matches 791# exp_continue 792# } 793# -re "^\\s+$fed2$eol" { 794# incr matches 795# exp_continue 796# } 797# timeout { 798# slow_kill $my_pid 799# fail "sacctmgr add not responding" 800# } 801# eof { 802# wait 803# } 804#} 805#if {$matches != 5} { 806# fail "Unexpected error" 807#} 808# 809#set matches 0 810#set my_pid [spawn $sacctmgr show federation $fed1 $fed2 format="federation%20,flags,cluster%20,fedstate%20"] 811#expect { 812# -re "Federation\\s+Flags\\s+Cluster\\s+FedState $eol" { 813# incr matches 814# exp_continue 815# } 816# -re "\\s+$fed1\\s+LLC\\s+$tc1\\s+ACTIVE $eol" { 817# incr matches 818# exp_continue 819# } 820# -re "\\s+$fed2\\s+LLC\\s+$tc2\\s+DRAIN\\+REMOVE $eol" { 821# incr matches 822# exp_continue 823# } 824# -re "\\s+$fed2\\s+LLC\\s+$tc3\\s+DRAIN $eol" { 825# incr matches 826# exp_continue 827# } 828# timeout { 829# slow_kill $my_pid 830# fail "sacctmgr add not responding" 831# } 832# eof { 833# wait 834# } 835#} 836#if {$matches != 4} { 837# fail "Unexpected error" 838#} 839# 840#set matches 0 841#set my_pid [spawn $sacctmgr show federation $fed1 $fed2 format="federation%20,flags,cluster%20,fedstate%20" tree] 842#expect { 843# -re "Federation\\s+Flags\\s+Cluster\\s+FedState $eol" { 844# incr matches 845# exp_continue 846# } 847# -re "\\s+$fed1\\s+LLC\\s+ $eol" { 848# incr matches 849# exp_continue 850# } 851# -re "\\s+$tc1\\s+ACTIVE $eol" { 852# incr matches 853# exp_continue 854# } 855# -re "\\s+$fed2\\s+LLC\\s+ $eol" { 856# incr matches 857# exp_continue 858# } 859# -re "\\s+$tc2\\s+DRAIN\\+REMOVE $eol" { 860# incr matches 861# exp_continue 862# } 863# -re "\\s+$tc3\\s+DRAIN $eol" { 864# incr matches 865# exp_continue 866# } 867# timeout { 868# slow_kill $my_pid 869# fail "sacctmgr add not responding" 870# } 871# eof { 872# wait 873# } 874#} 875#if {$matches != 6} { 876# fail "Unexpected error" 877#} 878# 879###################################### 880## TEST: modify federation clear flags 881###################################### 882#set matches 0 883#set my_pid [spawn $sacctmgr -i modify federation $fed1 $fed2 set flags-=LLC] 884#expect { 885# -re "Setting$eol" { 886# incr matches 887# exp_continue 888# } 889# -re "^\\s+Flags\\s+-=\\s+LLC$eol" { 890# incr matches 891# exp_continue 892# } 893# -re "^\\s+Modified federation...$eol" { 894# incr matches 895# exp_continue 896# } 897# -re "^\\s+$fed1$eol" { 898# incr matches 899# exp_continue 900# } 901# -re "^\\s+$fed2$eol" { 902# incr matches 903# exp_continue 904# } 905# timeout { 906# slow_kill $my_pid 907# fail "sacctmgr add not responding" 908# } 909# eof { 910# wait 911# } 912#} 913#if {$matches != 5} { 914# fail "Unexpected error" 915#} 916# 917## Verify that LLC is removed and that only the federations are listed since no 918## cluster print fields are requested. 919#set matches 0 920#set my_pid [spawn $sacctmgr show federation $fed1 $fed2 format="federation%20,flags"] 921#expect { 922# -re "Federation\\s+Flags $eol" { 923# incr matches 924# exp_continue 925# } 926# -re "\\s+$fed1\\s+ $eol" { 927# incr matches 928# exp_continue 929# } 930# -re "\\s+$fed2\\s+ $eol" { 931# incr matches 932# exp_continue 933# } 934# timeout { 935# slow_kill $my_pid 936# fail "sacctmgr add not responding" 937# } 938# eof { 939# wait 940# } 941#} 942#if {$matches != 3} { 943# fail "Unexpected error" 944#} 945 946##################################### 947# TEST: mod cluster to federation -- check ids 948# create hole in fed2 ids 949##################################### 950set matches 0 951set my_pid [spawn $sacctmgr -i modify cluster $tc2 set federation=$fed1] 952expect { 953 -re "The cluster $tc2 is assigned to federation $fed2$eol" { 954 incr matches 955 exp_continue 956 } 957 -re "Setting$eol" { 958 incr matches 959 exp_continue 960 } 961 -re "^\\s+Federation\\s+=\\s+$fed1$eol" { 962 incr matches 963 exp_continue 964 } 965 -re "Modified cluster...$eol" { 966 incr matches 967 exp_continue 968 } 969 -re "^\\s+$tc2$eol" { 970 incr matches 971 exp_continue 972 } 973 timeout { 974 slow_kill $my_pid 975 fail "sacctmgr add not responding" 976 } 977 eof { 978 wait 979 } 980} 981if {$matches != 5} { 982 fail "Unexpected error" 983} 984 985set matches 0 986set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 format="cluster%20,federation%20,fedstate%20,id"] 987expect { 988 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 989 incr matches 990 exp_continue 991 } 992 -re "\\s+$tc1\\s+$fed1\\s+ACTIVE\\s+1 $eol" { 993 incr matches 994 exp_continue 995 } 996 -re "\\s+$tc2\\s+$fed1\\s+ACTIVE\\s+2 $eol" { 997 incr matches 998 exp_continue 999 } 1000 -re "\\s+$tc3\\s+$fed2\\s+DRAIN\\s+2 $eol" { 1001 incr matches 1002 exp_continue 1003 } 1004 timeout { 1005 slow_kill $my_pid 1006 fail "sacctmgr add not responding" 1007 } 1008 eof { 1009 wait 1010 } 1011} 1012if {$matches != 4} { 1013 fail "Unexpected error" 1014} 1015 1016# move tc1 into whole. 1017set matches 0 1018set my_pid [spawn $sacctmgr -i modify cluster $tc1 set federation=$fed2] 1019expect { 1020 -re "The cluster $tc1 is assigned to federation $fed1$eol" { 1021 incr matches 1022 exp_continue 1023 } 1024 -re "Setting$eol" { 1025 incr matches 1026 exp_continue 1027 } 1028 -re "^\\s+Federation\\s+=\\s+$fed2$eol" { 1029 incr matches 1030 exp_continue 1031 } 1032 -re "Modified cluster...$eol" { 1033 incr matches 1034 exp_continue 1035 } 1036 -re "^\\s+$tc1$eol" { 1037 incr matches 1038 exp_continue 1039 } 1040 timeout { 1041 slow_kill $my_pid 1042 fail "sacctmgr add not responding" 1043 } 1044 eof { 1045 wait 1046 } 1047} 1048if {$matches != 5} { 1049 fail "Unexpected error" 1050} 1051 1052set matches 0 1053set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 format="cluster%20,federation%20,fedstate%20,id"] 1054expect { 1055 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1056 incr matches 1057 exp_continue 1058 } 1059 -re "\\s+$tc1\\s+$fed2\\s+ACTIVE\\s+1 $eol" { 1060 incr matches 1061 exp_continue 1062 } 1063 -re "\\s+$tc2\\s+$fed1\\s+ACTIVE\\s+2 $eol" { 1064 incr matches 1065 exp_continue 1066 } 1067 -re "\\s+$tc3\\s+$fed2\\s+DRAIN\\s+2 $eol" { 1068 incr matches 1069 exp_continue 1070 } 1071 timeout { 1072 slow_kill $my_pid 1073 fail "sacctmgr add not responding" 1074 } 1075 eof { 1076 wait 1077 } 1078} 1079if {$matches != 4} { 1080 fail "Unexpected error" 1081} 1082 1083# move tc2 back to fed2 and get new id -- 3. 1084set matches 0 1085set my_pid [spawn $sacctmgr -i modify cluster $tc2 set federation=$fed2] 1086expect { 1087 -re "The cluster $tc2 is assigned to federation $fed1$eol" { 1088 incr matches 1089 exp_continue 1090 } 1091 -re "Setting$eol" { 1092 incr matches 1093 exp_continue 1094 } 1095 -re "^\\s+Federation\\s+=\\s+$fed2$eol" { 1096 incr matches 1097 exp_continue 1098 } 1099 -re "Modified cluster...$eol" { 1100 incr matches 1101 exp_continue 1102 } 1103 -re "^\\s+$tc2$eol" { 1104 incr matches 1105 exp_continue 1106 } 1107 timeout { 1108 slow_kill $my_pid 1109 fail "sacctmgr add not responding" 1110 } 1111 eof { 1112 wait 1113 } 1114} 1115if {$matches != 5} { 1116 fail "Unexpected error" 1117} 1118 1119set matches 0 1120set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 format="cluster%20,federation%20,fedstate%20,id"] 1121expect { 1122 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1123 incr matches 1124 exp_continue 1125 } 1126 -re "\\s+$tc1\\s+$fed2\\s+ACTIVE\\s+1 $eol" { 1127 incr matches 1128 exp_continue 1129 } 1130 -re "\\s+$tc2\\s+$fed2\\s+ACTIVE\\s+3 $eol" { 1131 incr matches 1132 exp_continue 1133 } 1134 -re "\\s+$tc3\\s+$fed2\\s+DRAIN\\s+2 $eol" { 1135 incr matches 1136 exp_continue 1137 } 1138 timeout { 1139 slow_kill $my_pid 1140 fail "sacctmgr add not responding" 1141 } 1142 eof { 1143 wait 1144 } 1145} 1146if {$matches != 4} { 1147 fail "Unexpected error" 1148} 1149 1150 1151##################################### 1152# TEST: add federation with existing clusters 1153##################################### 1154set matches 0 1155set my_pid [spawn $sacctmgr add federation $fed3 clusters=$tc1,$tc2] 1156expect { 1157 -re "The cluster $tc1 is assigned to federation $fed2$eol" { 1158 incr matches 1159 exp_continue 1160 } 1161 -re "The cluster $tc2 is assigned to federation $fed2$eol" { 1162 incr matches 1163 exp_continue 1164 } 1165 "Are you sure" { 1166 incr matches 1167 exp_continue 1168 } 1169 "(N/y):" { 1170 incr matches 1171 send "y" 1172 } 1173 timeout { 1174 slow_kill $my_pid 1175 fail "sacctmgr add not responding" 1176 } 1177 eof { 1178 wait 1179 } 1180} 1181if {$matches != 4} { 1182 fail "Adding invalid federation failed unexpectedly" 1183} 1184 1185set matches 0 1186expect { 1187 -re "Adding Federation\\(s\\)$eol" { 1188 incr matches 1189 exp_continue 1190 } 1191 -re "$fed3$eol" { 1192 incr matches 1193 exp_continue 1194 } 1195 -re "Settings$eol" { 1196 incr matches 1197 exp_continue 1198 } 1199 -re "\\s+Cluster\\s+=\\s+$tc1$eol" { 1200 incr matches 1201 exp_continue 1202 } 1203 -re "\\s+Cluster\\s+=\\s+$tc2$eol" { 1204 incr matches 1205 exp_continue 1206 } 1207 "Would you like" { 1208 incr matches 1209 exp_continue 1210 } 1211 "(N/y):" { 1212 incr matches 1213 send "y" 1214 } 1215 timeout { 1216 slow_kill $my_pid 1217 fail "sacctmgr add not responding" 1218 } 1219 eof { 1220 wait 1221 } 1222} 1223expect { 1224 timeout { 1225 slow_kill $my_pid 1226 fail "sacctmgr add not responding" 1227 } 1228 eof { 1229 wait 1230 } 1231} 1232if {$matches != 7} { 1233 fail "Adding invalid federation failed unexpectedly" 1234} 1235 1236set matches 0 1237set my_pid [spawn $sacctmgr show federation $fed1 $fed2 $fed3 format="federation%20,cluster%20,fedstate%20,id"] 1238expect { 1239 -re "Federation\\s+Cluster\\s+FedState\\s+ID $eol" { 1240 incr matches 1241 exp_continue 1242 } 1243 -re "\\s+$fed1\\s+$eol" { 1244 incr matches 1245 exp_continue 1246 } 1247 -re "\\s+$fed2\\s+$tc3\\s+DRAIN\\s+2 $eol" { 1248 incr matches 1249 exp_continue 1250 } 1251 -re "\\s+$fed3\\s+$tc1\\s+ACTIVE\\s+1 $eol" { 1252 incr matches 1253 exp_continue 1254 } 1255 -re "\\s+$fed3\\s+$tc2\\s+ACTIVE\\s+2 $eol" { 1256 incr matches 1257 exp_continue 1258 } 1259 timeout { 1260 slow_kill $my_pid 1261 fail "sacctmgr add not responding" 1262 } 1263 eof { 1264 wait 1265 } 1266} 1267if {$matches != 5} { 1268 fail "Unexpected error" 1269} 1270 1271##################################### 1272# modify cluster, clear federation 1273##################################### 1274set matches 0 1275set my_pid [spawn $sacctmgr -i modify cluster $tc3 set federation=] 1276expect { 1277 -re "Setting" { 1278 incr matches 1279 exp_continue 1280 } 1281 -re "^\\s+Federation\\s+=\\s+$eol" { 1282 incr matches 1283 exp_continue 1284 } 1285 -re "Modified cluster...$eol" { 1286 incr matches 1287 exp_continue 1288 } 1289 -re "^\\s+$tc3$eol" { 1290 incr matches 1291 exp_continue 1292 } 1293 timeout { 1294 slow_kill $my_pid 1295 fail "sacctmgr add not responding" 1296 } 1297 eof { 1298 wait 1299 } 1300} 1301if {$matches != 4} { 1302 fail "Unexpected error. Got $matches" 1303} 1304 1305set matches 0 1306set my_pid [spawn $sacctmgr show cluster $tc3 format="cluster%20,federation%20,fedstate%20,id"] 1307expect { 1308 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1309 incr matches 1310 exp_continue 1311 } 1312 -re "\\s+$tc3\\s+NA\\s+0 $eol" { 1313 incr matches 1314 exp_continue 1315 } 1316 timeout { 1317 slow_kill $my_pid 1318 fail "sacctmgr add not responding" 1319 } 1320 eof { 1321 wait 1322 } 1323} 1324if {$matches != 2} { 1325 fail "Unexpected error. Got $matches" 1326} 1327 1328##################################### 1329# TEST: test selecting clusters by federations 1330##################################### 1331set matches 0 1332set my_pid [spawn $sacctmgr show cluster where fed=$fed3 format="cluster%20,federation%20,id"] 1333expect { 1334 -re "Cluster\\s+Federation\\s+ID $eol" { 1335 incr matches 1336 exp_continue 1337 } 1338 -re "\\s+$tc1\\s+$fed3\\s+1 $eol" { 1339 incr matches 1340 exp_continue 1341 } 1342 -re "\\s+$tc2\\s+$fed3\\s+2 $eol" { 1343 incr matches 1344 exp_continue 1345 } 1346 timeout { 1347 slow_kill $my_pid 1348 fail "sacctmgr add not responding" 1349 } 1350 eof { 1351 wait 1352 } 1353} 1354if {$matches != 3} { 1355 fail "Unexpected error. Got $matches" 1356} 1357 1358 1359 1360##################################### 1361# TEST: test adding new cluster and verify state and change states 1362##################################### 1363set matches 0 1364set my_pid [spawn $sacctmgr -i add cluster $tc4] 1365expect { 1366 -re "Adding Cluster\\(s\\)$eol" { 1367 incr matches 1368 exp_continue 1369 } 1370 -re "\\s+$tc4$eol" { 1371 incr matches 1372 exp_continue 1373 } 1374 timeout { 1375 slow_kill $my_pid 1376 fail "sacctmgr add not responding" 1377 } 1378 eof { 1379 wait 1380 } 1381} 1382if {$matches != 2} { 1383 fail "Unexpected error. Got $matches" 1384} 1385 1386# New clusters should have fed_id=0, federation="", fed_state=NA 1387set matches 0 1388set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1389expect { 1390 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1391 incr matches 1392 exp_continue 1393 } 1394 -re "\\s+$tc4\\s+NA\\s+0 $eol" { 1395 incr matches 1396 exp_continue 1397 } 1398 timeout { 1399 slow_kill $my_pid 1400 fail "sacctmgr add not responding" 1401 } 1402 eof { 1403 wait 1404 } 1405} 1406if {$matches != 2} { 1407 fail "Unexpected error. Got $matches" 1408} 1409 1410# Test adding cluster to federation sets state to ACTIVE 1411set matches 0 1412set my_pid [spawn $sacctmgr -i modify cluster $tc4 set federation=$fed3] 1413expect { 1414 -re "Setting" { 1415 incr matches 1416 exp_continue 1417 } 1418 -re "^\\s+Federation\\s+=\\s+$fed3$eol" { 1419 incr matches 1420 exp_continue 1421 } 1422 -re "Modified cluster...$eol" { 1423 incr matches 1424 exp_continue 1425 } 1426 -re "^\\s+$tc4$eol" { 1427 incr matches 1428 exp_continue 1429 } 1430 timeout { 1431 slow_kill $my_pid 1432 fail "sacctmgr add not responding" 1433 } 1434 eof { 1435 wait 1436 } 1437} 1438if {$matches != 4} { 1439 fail "Unexpected error. Got $matches" 1440} 1441 1442set matches 0 1443set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1444expect { 1445 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1446 incr matches 1447 exp_continue 1448 } 1449 -re "\\s+$tc4\\s+$fed3\\s+ACTIVE\\s+3 $eol" { 1450 incr matches 1451 exp_continue 1452 } 1453 timeout { 1454 slow_kill $my_pid 1455 fail "sacctmgr add not responding" 1456 } 1457 eof { 1458 wait 1459 } 1460} 1461if {$matches != 2} { 1462 fail "Unexpected error. Got $matches" 1463} 1464 1465 1466# Modifying cluster to same federation shouldln't change fed_id or fed_state 1467set matches 0 1468# set state to something other than ACTIVE, it should stay the same. 1469set my_pid [spawn $sacctmgr -i modify cluster $tc4 set fedstate=DRAIN] 1470expect { 1471 timeout { 1472 slow_kill $my_pid 1473 fail "sacctmgr add not responding" 1474 } 1475 eof { 1476 wait 1477 } 1478} 1479 1480set my_pid [spawn $sacctmgr -i modify cluster $tc4 set federation=$fed3] 1481expect { 1482 -re "The cluster $tc4 is already assigned to federation $fed3" { 1483 incr matches 1484 exp_continue 1485 } 1486 "Nothing to change" { 1487 incr matches 1488 exp_continue 1489 } 1490 timeout { 1491 slow_kill $my_pid 1492 fail "sacctmgr add not responding" 1493 } 1494 eof { 1495 wait 1496 } 1497} 1498if {$matches != 2} { 1499 fail "Unexpected error. Got $matches" 1500} 1501 1502set matches 0 1503set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1504expect { 1505 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1506 incr matches 1507 exp_continue 1508 } 1509 -re "\\s+$tc4\\s+$fed3\\s+DRAIN\\s+3 $eol" { 1510 incr matches 1511 exp_continue 1512 } 1513 timeout { 1514 slow_kill $my_pid 1515 fail "sacctmgr add not responding" 1516 } 1517 eof { 1518 wait 1519 } 1520} 1521if {$matches != 2} { 1522 fail "Unexpected error. Got $matches" 1523} 1524 1525#same thing for modifying the federaiton. 1526set matches 0 1527set my_pid [spawn $sacctmgr -i modify federation $fed3 set clusters+=$tc4] 1528expect { 1529 -re "The cluster $tc4 is already assigned to federation $fed3" { 1530 incr matches 1531 exp_continue 1532 } 1533 "Nothing to change" { 1534 incr matches 1535 exp_continue 1536 } 1537 timeout { 1538 slow_kill $my_pid 1539 fail "sacctmgr add not responding" 1540 } 1541 eof { 1542 wait 1543 } 1544} 1545if {$matches != 2} { 1546 fail "Unexpected error. Got $matches" 1547} 1548 1549set matches 0 1550set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1551expect { 1552 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1553 incr matches 1554 exp_continue 1555 } 1556 -re "\\s+$tc4\\s+$fed3\\s+DRAIN\\s+3 $eol" { 1557 incr matches 1558 exp_continue 1559 } 1560 timeout { 1561 slow_kill $my_pid 1562 fail "sacctmgr add not responding" 1563 } 1564 eof { 1565 wait 1566 } 1567} 1568if {$matches != 2} { 1569 fail "Unexpected error. Got $matches" 1570} 1571 1572# changing from one federation to another should set the state to active 1573set matches 0 1574set my_pid [spawn $sacctmgr -i modify cluster $tc4 set federation=$fed2] 1575expect { 1576 -re "The cluster $tc4 is assigned to federation $fed3$eol" { 1577 incr matches 1578 exp_continue 1579 } 1580 -re "Setting" { 1581 incr matches 1582 exp_continue 1583 } 1584 -re "^\\s+Federation\\s+=\\s+$fed2$eol" { 1585 incr matches 1586 exp_continue 1587 } 1588 -re "Modified cluster...$eol" { 1589 incr matches 1590 exp_continue 1591 } 1592 -re "^\\s+$tc4$eol" { 1593 incr matches 1594 exp_continue 1595 } 1596 timeout { 1597 slow_kill $my_pid 1598 fail "sacctmgr add not responding" 1599 } 1600 eof { 1601 wait 1602 } 1603} 1604if {$matches != 5} { 1605 fail "Unexpected error. Got $matches" 1606} 1607 1608set matches 0 1609set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1610expect { 1611 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1612 incr matches 1613 exp_continue 1614 } 1615 -re "\\s+$tc4\\s+$fed2\\s+ACTIVE\\s+1 $eol" { 1616 incr matches 1617 exp_continue 1618 } 1619 timeout { 1620 slow_kill $my_pid 1621 fail "sacctmgr add not responding" 1622 } 1623 eof { 1624 wait 1625 } 1626} 1627if {$matches != 2} { 1628 fail "Unexpected error. Got $matches" 1629} 1630 1631 1632# same thing for modifying federation - state should go to active 1633set my_pid [spawn $sacctmgr -i modify cluster $tc4 set fedstate=DRAIN] 1634expect { 1635 timeout { 1636 slow_kill $my_pid 1637 fail "sacctmgr add not responding" 1638 } 1639 eof { 1640 wait 1641 } 1642} 1643 1644set matches 0 1645set my_pid [spawn $sacctmgr -i modify federation $fed3 set clusters+=$tc4] 1646expect { 1647 -re "The cluster $tc4 is assigned to federation $fed2$eol" { 1648 incr matches 1649 exp_continue 1650 } 1651 -re "Setting$eol" { 1652 incr matches 1653 exp_continue 1654 } 1655 -re "Cluster\\s+ \\+= $tc4$eol" { 1656 incr matches 1657 exp_continue 1658 } 1659 -re "^\\s+Modified federation...$eol" { 1660 incr matches 1661 exp_continue 1662 } 1663 -re "\\s+$fed3$eol" { 1664 incr matches 1665 exp_continue 1666 } 1667 timeout { 1668 slow_kill $my_pid 1669 fail "sacctmgr add not responding" 1670 } 1671 eof { 1672 wait 1673 } 1674} 1675if {$matches != 5} { 1676 fail "Unexpected error. Got $matches" 1677} 1678 1679set matches 0 1680set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1681expect { 1682 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1683 incr matches 1684 exp_continue 1685 } 1686 -re "\\s+$tc4\\s+$fed3\\s+ACTIVE\\s+3 $eol" { 1687 incr matches 1688 exp_continue 1689 } 1690 timeout { 1691 slow_kill $my_pid 1692 fail "sacctmgr add not responding" 1693 } 1694 eof { 1695 wait 1696 } 1697} 1698if {$matches != 2} { 1699 fail "Unexpected error. Got $matches" 1700} 1701 1702# Test setting state to INACTIVE 1703set matches 0 1704set my_pid [spawn $sacctmgr -i modify cluster $tc4 set fedstate=INACTIVE] 1705expect { 1706 -re "Setting$eol" { 1707 incr matches 1708 exp_continue 1709 } 1710 -re "^\\s+FedState\\s+=\\s+INACTIVE$eol" { 1711 incr matches 1712 exp_continue 1713 } 1714 -re "Modified cluster...$eol" { 1715 incr matches 1716 exp_continue 1717 } 1718 -re "^\\s+$tc4$eol" { 1719 incr matches 1720 exp_continue 1721 } 1722 timeout { 1723 slow_kill $my_pid 1724 fail "sacctmgr add not responding" 1725 } 1726 eof { 1727 wait 1728 } 1729} 1730if {$matches != 4} { 1731 fail "Unexpected error. Got $matches" 1732} 1733 1734set matches 0 1735set my_pid [spawn $sacctmgr show cluster $tc4 format="cluster%20,federation%20,fedstate%20,id"] 1736expect { 1737 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 1738 incr matches 1739 exp_continue 1740 } 1741 -re "\\s+$tc4\\s+$fed3\\s+INACTIVE\\s+3 $eol" { 1742 incr matches 1743 exp_continue 1744 } 1745 timeout { 1746 slow_kill $my_pid 1747 fail "sacctmgr add not responding" 1748 } 1749 eof { 1750 wait 1751 } 1752} 1753if {$matches != 2} { 1754 fail "Unexpected error. Got $matches" 1755} 1756 1757# Test invalid state 1758set matches 0 1759set my_pid [spawn $sacctmgr -i modify cluster $tc4 set fedstate=abcdefg] 1760expect { 1761 -re "Invalid FedState abcdefg" { 1762 incr matches 1763 exp_continue 1764 } 1765 timeout { 1766 slow_kill $my_pid 1767 fail "sacctmgr add not responding" 1768 } 1769 eof { 1770 wait 1771 } 1772} 1773if {$matches != 1} { 1774 fail "Unexpected error. Got $matches" 1775} 1776 1777##################################### 1778# TEST: modify federation change clusters - must remove others 1779##################################### 1780#sacctmgr modify federation fed set clusters=test3,test4 1781#sacctmgr modify federation fed set clusters=test1,test2 1782#sacctmgr modify federation fed set clusters+=test1,test2 1783#sacctmgr modify federation fed set clusters-=test1,test2 1784# unset clusters 1785set my_pid [spawn $sacctmgr -i modify cluster $tc1 $tc2 $tc3 set federation=] 1786expect { 1787 timeout { 1788 slow_kill $my_pid 1789 fail "sacctmgr add not responding" 1790 } 1791 eof { 1792 wait 1793 } 1794} 1795 1796set matches 0 1797set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters=$tc1,$tc2] 1798expect { 1799 -re "Setting$eol" { 1800 incr matches 1801 exp_continue 1802 } 1803 -re "Cluster\\s+ \\+= $tc1$eol" { 1804 incr matches 1805 exp_continue 1806 } 1807 -re "Cluster\\s+ \\+= $tc2$eol" { 1808 incr matches 1809 exp_continue 1810 } 1811 -re "^\\s+Modified federation...$eol" { 1812 incr matches 1813 exp_continue 1814 } 1815 -re "\\s+$fed1$eol" { 1816 incr matches 1817 exp_continue 1818 } 1819 timeout { 1820 slow_kill $my_pid 1821 fail "sacctmgr add not responding" 1822 } 1823 eof { 1824 wait 1825 } 1826} 1827if {$matches != 5} { 1828 fail "Unexpected error. Got $matches" 1829} 1830 1831set matches 0 1832set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20,fedstate%20"] 1833expect { 1834 -re "Federation\\s+Cluster\\s+FedState $eol" { 1835 incr matches 1836 exp_continue 1837 } 1838 -re "\\s+$fed1\\s+(\\S+)\\s+ACTIVE $eol" { 1839 set match $expect_out(1,string) 1840 if {[string equal $match $tc1] || 1841 [string equal $match $tc2]} { 1842 incr matches 1843 } 1844 exp_continue 1845 } 1846 timeout { 1847 slow_kill $my_pid 1848 fail "sacctmgr add not responding" 1849 } 1850 eof { 1851 wait 1852 } 1853} 1854if {$matches != 3} { 1855 fail "Unexpected error. Got $matches" 1856} 1857 1858set matches 0 1859set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters=$tc1,$tc3] 1860expect { 1861 -re "The cluster $tc1 is already assigned to federation $fed1" { 1862 incr matches 1863 exp_continue 1864 } 1865 -re "Setting$eol" { 1866 incr matches 1867 exp_continue 1868 } 1869 -re "Cluster\\s+ \\+= $tc3$eol" { 1870 incr matches 1871 exp_continue 1872 } 1873 -re "Cluster\\s+ -= $tc2$eol" { 1874 incr matches 1875 exp_continue 1876 } 1877 -re "^\\s+Modified federation...$eol" { 1878 incr matches 1879 exp_continue 1880 } 1881 -re "\\s+$fed1$eol" { 1882 incr matches 1883 exp_continue 1884 } 1885 timeout { 1886 slow_kill $my_pid 1887 fail "sacctmgr add not responding" 1888 } 1889 eof { 1890 wait 1891 } 1892} 1893if {$matches != 6} { 1894 fail "Unexpected error. Got $matches" 1895} 1896 1897set matches 0 1898set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20,fedstate%20"] 1899expect { 1900 -re "Federation\\s+Cluster\\s+FedState $eol" { 1901 incr matches 1902 exp_continue 1903 } 1904 -re "\\s+$fed1\\s+(\\S+)\\s+ACTIVE $eol" { 1905 set match $expect_out(1,string) 1906 if {[string equal $match $tc1] || 1907 [string equal $match $tc3]} { 1908 incr matches 1909 } 1910 exp_continue 1911 } 1912 timeout { 1913 slow_kill $my_pid 1914 fail "sacctmgr add not responding" 1915 } 1916 eof { 1917 wait 1918 } 1919} 1920if {$matches != 3} { 1921 fail "Unexpected error. Got $matches" 1922} 1923 1924set matches 0 1925set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters+=$tc2] 1926expect { 1927 -re "Setting$eol" { 1928 incr matches 1929 exp_continue 1930 } 1931 -re "Cluster\\s+ \\+= $tc2$eol" { 1932 incr matches 1933 exp_continue 1934 } 1935 -re "^\\s+Modified federation...$eol" { 1936 incr matches 1937 exp_continue 1938 } 1939 -re "\\s+$fed1$eol" { 1940 incr matches 1941 exp_continue 1942 } 1943 timeout { 1944 slow_kill $my_pid 1945 fail "sacctmgr add not responding" 1946 } 1947 eof { 1948 wait 1949 } 1950} 1951if {$matches != 4} { 1952 fail "Unexpected error. Got $matches" 1953} 1954 1955set matches 0 1956set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20,fedstate%20"] 1957expect { 1958 -re "Federation\\s+Cluster\\s+FedState $eol" { 1959 incr matches 1960 exp_continue 1961 } 1962 -re "\\s+$fed1\\s+(\\S+)\\s+ACTIVE $eol" { 1963 set match $expect_out(1,string) 1964 if {[string equal $match $tc1] || 1965 [string equal $match $tc2] || 1966 [string equal $match $tc3]} { 1967 incr matches 1968 } 1969 exp_continue 1970 } 1971 timeout { 1972 slow_kill $my_pid 1973 fail "sacctmgr add not responding" 1974 } 1975 eof { 1976 wait 1977 } 1978} 1979if {$matches != 4} { 1980 fail "Unexpected error. Got $matches" 1981} 1982 1983set matches 0 1984set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters-=$tc1,$tc2] 1985expect { 1986 -re "Setting$eol" { 1987 incr matches 1988 exp_continue 1989 } 1990 -re "Cluster\\s+ -= $tc1$eol" { 1991 incr matches 1992 exp_continue 1993 } 1994 -re "Cluster\\s+ -= $tc2$eol" { 1995 incr matches 1996 exp_continue 1997 } 1998 -re "^\\s+Modified federation...$eol" { 1999 incr matches 2000 exp_continue 2001 } 2002 -re "\\s+$fed1$eol" { 2003 incr matches 2004 exp_continue 2005 } 2006 timeout { 2007 slow_kill $my_pid 2008 fail "sacctmgr add not responding" 2009 } 2010 eof { 2011 wait 2012 } 2013} 2014if {$matches != 5} { 2015 fail "Unexpected error. Got $matches" 2016} 2017 2018set matches 0 2019set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20,fedstate%20"] 2020expect { 2021 -re "Federation\\s+Cluster\\s+FedState $eol" { 2022 incr matches 2023 exp_continue 2024 } 2025 -re "\\s+$fed1\\s+(\\S+)\\s+ACTIVE $eol" { 2026 set match $expect_out(1,string) 2027 if {[string equal $match $tc3]} { 2028 incr matches 2029 } 2030 exp_continue 2031 } 2032 timeout { 2033 slow_kill $my_pid 2034 fail "sacctmgr add not responding" 2035 } 2036 eof { 2037 wait 2038 } 2039} 2040if {$matches != 2} { 2041 fail "Unexpected error. Got $matches" 2042} 2043 2044set matches 0 2045set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters-=$tc1,$tc3] 2046expect { 2047 -re "The cluster $tc1 isn't assigned to federation $fed1" { 2048 incr matches 2049 exp_continue 2050 } 2051 -re "Setting$eol" { 2052 incr matches 2053 exp_continue 2054 } 2055 -re "Cluster\\s+ -= $tc3$eol" { 2056 incr matches 2057 exp_continue 2058 } 2059 -re "^\\s+Modified federation...$eol" { 2060 incr matches 2061 exp_continue 2062 } 2063 -re "\\s+$fed1$eol" { 2064 incr matches 2065 exp_continue 2066 } 2067 timeout { 2068 slow_kill $my_pid 2069 fail "sacctmgr add not responding" 2070 } 2071 eof { 2072 wait 2073 } 2074} 2075if {$matches != 5} { 2076 fail "Unexpected error. Got $matches" 2077} 2078 2079set matches 0 2080set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20,fedstate%20"] 2081expect { 2082 -re "Federation\\s+Cluster\\s+FedState $eol" { 2083 incr matches 2084 exp_continue 2085 } 2086 -re "\\s+$fed1\\s+ $eol" { 2087 incr matches 2088 exp_continue 2089 } 2090 timeout { 2091 slow_kill $my_pid 2092 fail "sacctmgr add not responding" 2093 } 2094 eof { 2095 wait 2096 } 2097} 2098if {$matches != 2} { 2099 fail "Unexpected error. Got $matches" 2100} 2101 2102##################################### 2103# TEST: error checking on using +, - and = 2104##################################### 2105set matches 0 2106set my_pid [spawn $sacctmgr -i modify federation $fed1 set cluster=$tc1,+$tc2] 2107expect { 2108 "sacctmgr: error: You can't use '=' and '+' or '-' in the same line" { 2109 incr matches 2110 exp_continue 2111 } 2112 timeout { 2113 slow_kill $my_pid 2114 fail "sacctmgr add not responding" 2115 } 2116 eof { 2117 wait 2118 } 2119} 2120if {$matches != 1} { 2121 fail "Failed testing mod with + and =" 2122} 2123 2124set matches 0 2125set my_pid [spawn $sacctmgr -i modify federation $fed1 set cluster=$tc1,-$tc2] 2126expect { 2127 "sacctmgr: error: You can't use '=' and '+' or '-' in the same line" { 2128 incr matches 2129 exp_continue 2130 } 2131 timeout { 2132 slow_kill $my_pid 2133 fail "sacctmgr add not responding" 2134 } 2135 eof { 2136 wait 2137 } 2138} 2139if {$matches != 1} { 2140 fail "Failed testing mod with - and =" 2141} 2142 2143 2144##################################### 2145# TEST: modify federation, clear clusters 2146##################################### 2147set matches 0 2148set my_pid [spawn $sacctmgr -i modify cluster $tc1 $tc2 $tc3 set federation=$fed1] 2149expect { 2150 -re "Setting$eol" { 2151 incr matches 2152 exp_continue 2153 } 2154 -re "^\\s+Federation\\s+=\\s+$fed1$eol" { 2155 incr matches 2156 exp_continue 2157 } 2158 -re "Modified cluster...$eol" { 2159 incr matches 2160 exp_continue 2161 } 2162 -re "^\\s+$tc1$eol" { 2163 incr matches 2164 exp_continue 2165 } 2166 -re "^\\s+$tc2$eol" { 2167 incr matches 2168 exp_continue 2169 } 2170 -re "^\\s+$tc3$eol" { 2171 incr matches 2172 exp_continue 2173 } 2174 timeout { 2175 slow_kill $my_pid 2176 fail "sacctmgr mod not responding" 2177 } 2178 eof { 2179 wait 2180 } 2181} 2182if {$matches != 6} { 2183 fail "Unexpected error. Got $matches" 2184} 2185 2186set matches 0 2187set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters=] 2188expect { 2189 -re "Setting$eol" { 2190 incr matches 2191 exp_continue 2192 } 2193 -re "Cluster\\s+ -= $tc1$eol" { 2194 incr matches 2195 exp_continue 2196 } 2197 -re "Cluster\\s+ -= $tc2$eol" { 2198 incr matches 2199 exp_continue 2200 } 2201 -re "Cluster\\s+ -= $tc3$eol" { 2202 incr matches 2203 exp_continue 2204 } 2205 -re "^\\s+Modified federation...$eol" { 2206 incr matches 2207 exp_continue 2208 } 2209 -re "\\s+$fed1$eol" { 2210 incr matches 2211 exp_continue 2212 } 2213 timeout { 2214 slow_kill $my_pid 2215 fail "sacctmgr add not responding" 2216 } 2217 eof { 2218 wait 2219 } 2220} 2221if {$matches != 6} { 2222 fail "Unexpected error. Got $matches" 2223} 2224 2225set matches 0 2226set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20,fedstate%20"] 2227expect { 2228 -re "Federation\\s+Cluster\\s+FedState $eol" { 2229 incr matches 2230 exp_continue 2231 } 2232 -re "\\s+$fed1\\s+ $eol" { 2233 incr matches 2234 exp_continue 2235 } 2236 timeout { 2237 slow_kill $my_pid 2238 fail "sacctmgr add not responding" 2239 } 2240 eof { 2241 wait 2242 } 2243} 2244if {$matches != 2} { 2245 fail "Unexpected error. Got $matches" 2246} 2247 2248# Verify clusters fed_id=0, federation="", fed_state=NA after being removed from 2249# federation 2250set matches 0 2251set my_pid [spawn $sacctmgr show cluster $tc1 $tc2 $tc3 format="cluster%20,federation%20,fedstate%20,id"] 2252expect { 2253 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 2254 incr matches 2255 exp_continue 2256 } 2257 -re "\\s+($tc1|$tc2|$tc3)\\s+NA\\s+0 $eol" { 2258 incr matches 2259 exp_continue 2260 } 2261 timeout { 2262 slow_kill $my_pid 2263 fail "sacctmgr add not responding" 2264 } 2265 eof { 2266 wait 2267 } 2268} 2269if {$matches != 4} { 2270 fail "Unexpected error. Got $matches" 2271} 2272 2273 2274##################################### 2275# TEST: test deleting cluster with where federation= clause 2276##################################### 2277set my_pid [spawn $sacctmgr -i delete federation $fed2 $fed3] 2278expect { 2279 timeout { 2280 slow_kill $my_pid 2281 fail "sacctmgr add not responding" 2282 } 2283 eof { 2284 wait 2285 } 2286} 2287 2288set matches 0 2289set my_pid [spawn $sacctmgr -i add federation $fed2 clusters=$tc1,$tc2] 2290expect { 2291 -re "Adding Federation\\(s\\)$eol" { 2292 incr matches 2293 exp_continue 2294 } 2295 -re "$fed2$eol" { 2296 incr matches 2297 exp_continue 2298 } 2299 -re "Settings$eol" { 2300 incr matches 2301 exp_continue 2302 } 2303 -re "\\s+Cluster\\s+=\\s+$tc1$eol" { 2304 incr matches 2305 exp_continue 2306 } 2307 -re "\\s+Cluster\\s+=\\s+$tc2$eol" { 2308 incr matches 2309 exp_continue 2310 } 2311 timeout { 2312 slow_kill $my_pid 2313 fail "sacctmgr add not responding" 2314 } 2315 eof { 2316 wait 2317 } 2318} 2319if {$matches != 5} { 2320 fail "Adding federation with clusters failed. Got $matches" 2321} 2322 2323# add second cluster to make sure selectin only on federation 2324set matches 0 2325set my_pid [spawn $sacctmgr -i add federation $fed3 clusters=$tc3,$tc4] 2326expect { 2327 -re "Adding Federation\\(s\\)$eol" { 2328 incr matches 2329 exp_continue 2330 } 2331 -re "$fed3$eol" { 2332 incr matches 2333 exp_continue 2334 } 2335 -re "Settings$eol" { 2336 incr matches 2337 exp_continue 2338 } 2339 -re "\\s+Cluster\\s+=\\s+$tc3$eol" { 2340 incr matches 2341 exp_continue 2342 } 2343 -re "\\s+Cluster\\s+=\\s+$tc4$eol" { 2344 incr matches 2345 exp_continue 2346 } 2347 timeout { 2348 slow_kill $my_pid 2349 fail "sacctmgr add not responding" 2350 } 2351 eof { 2352 wait 2353 } 2354} 2355if {$matches != 5} { 2356 fail "Adding federation with clusters failed. Got $matches" 2357} 2358 2359set matches 0 2360set my_pid [spawn $sacctmgr -i delete cluster where federation=$fed2] 2361expect { 2362 -re "Deleting clusters...$eol" { 2363 incr matches 2364 exp_continue 2365 } 2366 -re "$tc1$eol" { 2367 incr matches 2368 exp_continue 2369 } 2370 -re "$tc2$eol" { 2371 incr matches 2372 exp_continue 2373 } 2374 timeout { 2375 slow_kill $my_pid 2376 fail "sacctmgr add not responding" 2377 } 2378 eof { 2379 wait 2380 } 2381} 2382if {$matches != 3} { 2383 fail "Deleting clusters with federation=. Got $matches" 2384} 2385 2386# add back clusters back to federation to verify both federation clusters are 2387# selected. 2388set matches 0 2389set my_pid [spawn $sacctmgr -i add cluster $tc1,$tc2 federation=$fed2] 2390expect { 2391 -re "Adding Cluster\\(s\\)$eol" { 2392 incr matches 2393 exp_continue 2394 } 2395 -re "\\s+$tc1$eol" { 2396 incr matches 2397 exp_continue 2398 } 2399 -re "\\s+$tc2$eol" { 2400 incr matches 2401 exp_continue 2402 } 2403 -re "\\s+Setting$eol" { 2404 incr matches 2405 exp_continue 2406 } 2407 -re "\\s+Federation\\s+=\\s+$fed2$eol" { 2408 incr matches 2409 exp_continue 2410 } 2411 timeout { 2412 slow_kill $my_pid 2413 fail "sacctmgr add not responding" 2414 } 2415 eof { 2416 wait 2417 } 2418} 2419if {$matches != 5} { 2420 fail "Unexpected error. Got $matches" 2421} 2422 2423set matches 0 2424set my_pid [spawn $sacctmgr -i delete cluster where federation=$fed2,$fed3] 2425expect { 2426 -re "Deleting clusters...$eol" { 2427 incr matches 2428 exp_continue 2429 } 2430 -re "$tc1$eol" { 2431 incr matches 2432 exp_continue 2433 } 2434 -re "$tc2$eol" { 2435 incr matches 2436 exp_continue 2437 } 2438 -re "$tc3$eol" { 2439 incr matches 2440 exp_continue 2441 } 2442 -re "$tc4$eol" { 2443 incr matches 2444 exp_continue 2445 } 2446 timeout { 2447 slow_kill $my_pid 2448 fail "sacctmgr delete cluster not responding" 2449 } 2450 eof { 2451 wait 2452 } 2453} 2454if {$matches != 5} { 2455 fail "Deleting clusters with federation=. Got $matches" 2456} 2457 2458 2459##################################### 2460# TEST: test adding more than 63 clusters to a federation 2461##################################### 2462# unset federations 2463set my_pid [spawn $sacctmgr -i modify federation $fed1 set clusters=] 2464expect { 2465 timeout { 2466 slow_kill $my_pid 2467 fail "sacctmgr add not responding" 2468 } 2469 eof { 2470 wait 2471 } 2472} 2473 2474set matches 0 2475set tmp_clusters "" 2476for {set i 1} {$i < $max_federations} {incr i} { 2477 if {$i > 1} { 2478 append tmp_clusters "," 2479 } 2480 append tmp_clusters "max${i}_$test_id_2" 2481} 2482set timeout 300 2483set my_pid [spawn $sacctmgr -i add cluster $tmp_clusters federation=$fed1] 2484expect { 2485 -re "Adding Cluster\\(s\\)$eol" { 2486 incr matches 2487 exp_continue 2488 } 2489 -re "\\s+max\[1-6\]{0,1}\\d{1}_$test_id_2$eol" { 2490 incr matches 2491 exp_continue 2492 } 2493 -re "\\s+Setting$eol" { 2494 incr matches 2495 exp_continue 2496 } 2497 -re "\\s+Federation\\s+=\\s+$fed1$eol" { 2498 incr matches 2499 exp_continue 2500 } 2501 timeout { 2502 slow_kill $my_pid 2503 fail "sacctmgr add not responding" 2504 } 2505 eof { 2506 wait 2507 } 2508} 2509if {$matches != 66} { 2510 fail "Unexpected error. Got $matches" 2511} 2512 2513set matches 0 2514set tmpc "max${i}_$test_id_2" 2515set my_pid [spawn $sacctmgr -i add cluster $tmpc federation=$fed1] 2516expect { 2517 -re "Adding Cluster\\(s\\)$eol" { 2518 incr matches 2519 exp_continue 2520 } 2521 -re "\\s+$tmpc$eol" { 2522 incr matches 2523 exp_continue 2524 } 2525 -re "\\s+Setting$eol" { 2526 incr matches 2527 exp_continue 2528 } 2529 -re "\\s+Federation\\s+=\\s+$fed1$eol" { 2530 incr matches 2531 exp_continue 2532 } 2533 -re "\\s+Problem adding clusters: Too many clusters in federation?" { 2534 incr matches 2535 exp_continue 2536 } 2537 timeout { 2538 slow_kill $my_pid 2539 fail "sacctmgr add not responding" 2540 } 2541 eof { 2542 wait 2543 } 2544} 2545if {$matches != 5} { 2546 fail "Unexpected error. Got $matches" 2547} 2548 2549set matches 0 2550##################################### 2551# TEST: modify cluster to exceed max clusters in federation 2552##################################### 2553#add last cluster without federation 2554set my_pid [spawn $sacctmgr -i add cluster $tmpc] 2555expect { 2556 -re "Adding Cluster\\(s\\)$eol" { 2557 incr matches 2558 exp_continue 2559 } 2560 -re "\\s+$tmpc$eol" { 2561 incr matches 2562 exp_continue 2563 } 2564 timeout { 2565 slow_kill $my_pid 2566 fail "sacctmgr add not responding" 2567 } 2568 eof { 2569 wait 2570 } 2571} 2572if {$matches != 2} { 2573 fail "Unexpected error. Got $matches" 2574} 2575 2576set matches 0 2577set my_pid [spawn $sacctmgr -i modify cluster $tmpc set federation=$fed1] 2578expect { 2579 -re "Setting$eol" { 2580 incr matches 2581 exp_continue 2582 } 2583 -re "^\\s+Federation\\s+=\\s+$fed1$eol" { 2584 incr matches 2585 exp_continue 2586 } 2587 -re "sacctmgr: error: slurmdbd: Too many clusters in federation$eol" { 2588 incr matches 2589 exp_continue 2590 } 2591 timeout { 2592 slow_kill $my_pid 2593 fail "sacctmgr add not responding" 2594 } 2595 eof { 2596 wait 2597 } 2598} 2599if {$matches != 3} { 2600 fail "Unexpected error. Got $matches" 2601} 2602 2603set matches 0 2604set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20"] 2605expect { 2606 -re "Federation\\s+Cluster $eol" { 2607 incr matches 2608 exp_continue 2609 } 2610 -re "\\s+$fed1\\s+max\[1-6\]{0,1}\\d{1}_$test_id_2 $eol" { 2611 incr matches 2612 exp_continue 2613 } 2614 timeout { 2615 slow_kill $my_pid 2616 fail "sacctmgr add not responding" 2617 } 2618 eof { 2619 wait 2620 } 2621} 2622if {$matches != $max_federations} { 2623 fail "Unexpected error. Got $matches" 2624} 2625 2626##################################### 2627# TEST: delete cluster - should delete it from federation. 2628##################################### 2629delete_clusters "max1_$test_id_2" 2630 2631set matches 0 2632set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20"] 2633expect { 2634 -re "\\s+$fed1\\s+max1_$test_id_2 $eol" { 2635 incr matches 2636 exp_continue 2637 } 2638 timeout { 2639 slow_kill $my_pid 2640 fail "sacctmgr add not responding" 2641 } 2642 eof { 2643 wait 2644 } 2645} 2646if {$matches } { 2647 fail "Found cluster still on federation when it should have been deleted. Got $matches" 2648} 2649 2650 2651##################################### 2652# TEST: delete federation - should clean clusters from federation. 2653##################################### 2654delete_federations $fed1 2655 2656set matches 0 2657set my_pid [spawn $sacctmgr show federation $fed1 format="federation%20,cluster%20"] 2658expect { 2659 -re "\\s+$fed1.*?$eol" { 2660 incr matches 2661 exp_continue 2662 } 2663 timeout { 2664 slow_kill $my_pid 2665 fail "sacctmgr add not responding" 2666 } 2667 eof { 2668 wait 2669 } 2670} 2671if {$matches } { 2672 fail "Found federation when it should have been deleted. Got $matches" 2673} 2674 2675set matches 0 2676set my_pid [spawn $sacctmgr show cluster format="cluster%20,federation%20"] 2677expect { 2678 -re "$fed1" { 2679 incr matches 2680 exp_continue 2681 } 2682 timeout { 2683 slow_kill $my_pid 2684 fail "sacctmgr add not responding" 2685 } 2686 eof { 2687 wait 2688 } 2689} 2690if {$matches } { 2691 fail "Found federation on cluster when it was deleted. Got $mattches" 2692} 2693 2694 2695# Verify clusters fed_id=0, federation="", fed_state=NA after federation is deleted. 2696 2697set tmp_clusters "" 2698for {set i 0} {$i <= $max_federations} {incr i} { 2699 append tmp_clusters "max${i}_$test_id_2," 2700} 2701set matches 0 2702set my_pid [spawn $sacctmgr show cluster $tmp_clusters format="cluster%20,federation%20,fedstate%20,id"] 2703expect { 2704 -re "Cluster\\s+Federation\\s+FedState\\s+ID $eol" { 2705 incr matches 2706 exp_continue 2707 } 2708 -re "\\s+max\[1-6\]{0,1}\\d{1}_$test_id_2\\s+NA\\s+0 $eol" { 2709 incr matches 2710 exp_continue 2711 } 2712 timeout { 2713 slow_kill $my_pid 2714 fail "sacctmgr add not responding" 2715 } 2716 eof { 2717 wait 2718 } 2719} 2720if {$matches != $max_federations} { 2721 fail "Unexpected error. Got $matches" 2722} 2723 2724 2725##################################### 2726# TEST: add/modify cluster features 2727##################################### 2728set matches 0 2729set my_pid [spawn $sacctmgr -i add cluster $tc5 features=a,b] 2730expect { 2731 -re "Adding Cluster\\(s\\)$eol" { 2732 incr matches 2733 exp_continue 2734 } 2735 -re "\\s+$tc5$eol" { 2736 incr matches 2737 exp_continue 2738 } 2739 -re "\\s+Setting$eol" { 2740 incr matches 2741 exp_continue 2742 } 2743 -re "\\s+Feature\\s+=\\s+a$eol" { 2744 incr matches 2745 exp_continue 2746 } 2747 -re "\\s+Feature\\s+=\\s+b$eol" { 2748 incr matches 2749 exp_continue 2750 } 2751 timeout { 2752 slow_kill $my_pid 2753 fail "sacctmgr add not responding" 2754 } 2755 eof { 2756 wait 2757 } 2758} 2759if {$matches != 5} { 2760 fail "Unexpected error. Got $matches" 2761} 2762 2763set matches 0 2764set my_pid [spawn $sacctmgr show cluster $tc5 format="cluster%20,features%20"] 2765expect { 2766 -re "Cluster\\s+Features $eol" { 2767 incr matches 2768 exp_continue 2769 } 2770 -re "\\s+a,b $eol" { 2771 incr matches 2772 exp_continue 2773 } 2774 timeout { 2775 slow_kill $my_pid 2776 fail "sacctmgr add not responding" 2777 } 2778 eof { 2779 wait 2780 } 2781} 2782if {$matches != 2} { 2783 fail "Unexpected error. Got $matches" 2784} 2785 2786set matches 0 2787set my_pid [spawn $sacctmgr -i modify cluster $tc5 set features=aa,ab] 2788expect { 2789 -re "Setting$eol" { 2790 incr matches 2791 exp_continue 2792 } 2793 -re "^\\s+Feature\\s+=\\s+aa" { 2794 incr matches 2795 exp_continue 2796 } 2797 -re "^\\s+Feature\\s+=\\s+ab" { 2798 incr matches 2799 exp_continue 2800 } 2801 -re "Modified cluster...$eol" { 2802 incr matches 2803 exp_continue 2804 } 2805 -re "^\\s+$tc5$eol" { 2806 incr matches 2807 exp_continue 2808 } 2809 timeout { 2810 slow_kill $my_pid 2811 fail "sacctmgr mod not responding" 2812 } 2813 eof { 2814 wait 2815 } 2816} 2817if {$matches != 5} { 2818 fail "Unexpected error. Got $matches" 2819} 2820 2821set matches 0 2822set my_pid [spawn $sacctmgr show cluster $tc5 format="cluster%20,features%20"] 2823expect { 2824 -re "Cluster\\s+Features $eol" { 2825 incr matches 2826 exp_continue 2827 } 2828 -re "\\s+aa,ab $eol" { 2829 incr matches 2830 exp_continue 2831 } 2832 timeout { 2833 slow_kill $my_pid 2834 fail "sacctmgr add not responding" 2835 } 2836 eof { 2837 wait 2838 } 2839} 2840if {$matches != 2} { 2841 fail "Unexpected error. Got $matches" 2842} 2843 2844set matches 0 2845set my_pid [spawn $sacctmgr -i modify cluster $tc5 set features+=fc] 2846expect { 2847 -re "Setting$eol" { 2848 incr matches 2849 exp_continue 2850 } 2851 -re "^\\s+Feature\\s+\\+=\\s+fc" { 2852 incr matches 2853 exp_continue 2854 } 2855 -re "Modified cluster...$eol" { 2856 incr matches 2857 exp_continue 2858 } 2859 -re "^\\s+$tc5$eol" { 2860 incr matches 2861 exp_continue 2862 } 2863 timeout { 2864 slow_kill $my_pid 2865 fail "sacctmgr mod not responding" 2866 } 2867 eof { 2868 wait 2869 } 2870} 2871if {$matches != 4} { 2872 fail "Unexpected error. Got $matches" 2873} 2874 2875set matches 0 2876set my_pid [spawn $sacctmgr show cluster $tc5 format="cluster%20,features%20"] 2877expect { 2878 -re "Cluster\\s+Features $eol" { 2879 incr matches 2880 exp_continue 2881 } 2882 -re "\\s+aa,ab,fc $eol" { 2883 incr matches 2884 exp_continue 2885 } 2886 timeout { 2887 slow_kill $my_pid 2888 fail "sacctmgr add not responding" 2889 } 2890 eof { 2891 wait 2892 } 2893} 2894if {$matches != 2} { 2895 fail "Unexpected error. Got $matches" 2896} 2897 2898set matches 0 2899set my_pid [spawn $sacctmgr -i modify cluster $tc5 set features-=ab] 2900expect { 2901 -re "Setting$eol" { 2902 incr matches 2903 exp_continue 2904 } 2905 -re "^\\s+Feature\\s+-=\\s+ab" { 2906 incr matches 2907 exp_continue 2908 } 2909 -re "Modified cluster...$eol" { 2910 incr matches 2911 exp_continue 2912 } 2913 -re "^\\s+$tc5$eol" { 2914 incr matches 2915 exp_continue 2916 } 2917 timeout { 2918 slow_kill $my_pid 2919 fail "sacctmgr mod not responding" 2920 } 2921 eof { 2922 wait 2923 } 2924} 2925if {$matches != 4} { 2926 fail "Unexpected error. Got $matches" 2927} 2928 2929set matches 0 2930set my_pid [spawn $sacctmgr show cluster $tc5 format="cluster%20,features%20"] 2931expect { 2932 -re "Cluster\\s+Features $eol" { 2933 incr matches 2934 exp_continue 2935 } 2936 -re "\\s+aa,fc $eol" { 2937 incr matches 2938 exp_continue 2939 } 2940 timeout { 2941 slow_kill $my_pid 2942 fail "sacctmgr add not responding" 2943 } 2944 eof { 2945 wait 2946 } 2947} 2948if {$matches != 2} { 2949 fail "Unexpected error. Got $matches" 2950} 2951 2952set matches 0 2953set my_pid [spawn $sacctmgr -i modify cluster $tc5 set features-=aa,fc] 2954expect { 2955 -re "Setting$eol" { 2956 incr matches 2957 exp_continue 2958 } 2959 -re "^\\s+Feature\\s+-=\\s+aa" { 2960 incr matches 2961 exp_continue 2962 } 2963 -re "^\\s+Feature\\s+-=\\s+fc" { 2964 incr matches 2965 exp_continue 2966 } 2967 -re "Modified cluster...$eol" { 2968 incr matches 2969 exp_continue 2970 } 2971 -re "^\\s+$tc5$eol" { 2972 incr matches 2973 exp_continue 2974 } 2975 timeout { 2976 slow_kill $my_pid 2977 fail "sacctmgr mod not responding" 2978 } 2979 eof { 2980 wait 2981 } 2982} 2983if {$matches != 5} { 2984 fail "Unexpected error. Got $matches" 2985} 2986 2987set matches 0 2988set my_pid [spawn $sacctmgr show cluster $tc5 format="cluster%20,features%20"] 2989expect { 2990 -re "Cluster\\s+Features $eol" { 2991 incr matches 2992 exp_continue 2993 } 2994 -re "\\s+ $eol" { 2995 incr matches 2996 exp_continue 2997 } 2998 timeout { 2999 slow_kill $my_pid 3000 fail "sacctmgr add not responding" 3001 } 3002 eof { 3003 wait 3004 } 3005} 3006if {$matches != 2} { 3007 fail "Unexpected error. Got $matches" 3008} 3009