Ticket #1066: 2

File 2, 5.4 KB (added by trac, 9 years ago)
Line 
1#___INFO__MARK_BEGIN__
2##########################################################################
3#
4#  The Contents of this file are made available subject to the terms of
5#  the Sun Industry Standards Source License Version 1.2
6#
7#  Sun Microsystems Inc., March, 2001
8#
9#
10#  Sun Industry Standards Source License Version 1.2
11#  =================================================
12#  The contents of this file are subject to the Sun Industry Standards
13#  Source License Version 1.2 (the "License"); You may not use this file
14#  except in compliance with the License. You may obtain a copy of the
15#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
16#
17#  Software provided under this License is provided on an "AS IS" basis,
18#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21#  See the License for the specific provisions governing your rights and
22#  obligations concerning the Software.
23#
24#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
25#
26#  Copyright: 2001 by Sun Microsystems, Inc.
27#
28#  All Rights Reserved.
29#
30##########################################################################
31#___INFO__MARK_END__
32
33global check_name check_description check_needs check_functions
34global check_category check_root_access_needs  check_highest_level
35
36set check_root_access_needs  "yes"
37
38
39set check_name           "qmaster_failover"
40set check_category       "COMPATIBILITY SYSTEM L10N VERIFIED"
41set check_highest_level  0
42set check_description(0) "checking status of queue with attribute"
43set check_description(1) "initial_state after qmaster failover"
44set check_needs          "init_core_system "      ;# dependencies of this check (name of other check)
45
46#
47# Cleanup function
48#
49set check_cleanup_function "qmaster_failover_cleanup"
50#
51# The test functions
52#
53set check_functions      "";
54lappend check_functions  "check_queue_state"
55#
56# Fun starts here.
57#
58proc qmaster_failover_cleanup {} {
59   global CHECK_OUTPUT CHECK_PRODUCT_ROOT CHECK_CORE_EXECD
60   #
61   # Clean up test.q if it's still around.
62   #
63   set hostname [lindex $CHECK_CORE_EXECD 0]
64   if {[lsearch [get_queue_list] "test.q"] != -1} {
65      puts $CHECK_OUTPUT "Deleting test.q"
66      del_queue test.q $hostname 0 1
67   }
68   return 0
69}
70#
71# The point about this test is that queues with initial_state = disabled
72# should not enter state DISABLED after failure of qmaster if previously
73# enabled.
74#
75proc check_queue_state {} {
76   global CHECK_OUTPUT CHECK_CORE_EXECD
77   global ts_config
78
79   #
80   # Test Plan
81   # =========
82   #
83   # * shutdown and restart qmaster
84   # * create a new queue with attribute initial_state == disabled
85   # * make sure that queue is disabled
86   # * enable queue and verify status
87   # * terminate and restart qmaster
88   # * let execd's re-connect to qmaster and ship queue status
89   # * check if queue still enabled, otherwise test failed
90   #
91   puts $CHECK_OUTPUT \
92        "checking state of queue with with initial_state = disabled for qmaster failover"
93
94   #
95   # Start from scratch to obtain with defined state.
96   #
97   shutdown_system_daemon $ts_config(master_host) "qmaster"
98   #
99   # ... and start over
100   #
101   startup_qmaster 0
102   #
103   # Create test queue with attribute initial_state DISABLED.
104   #
105   set hostname [lindex $CHECK_CORE_EXECD 0]
106   set testq(slots) 10
107   set testq(initial_state) "disabled"
108   add_queue test.q $hostname testq
109   set qname [get_queue_instance test.q $hostname]
110   puts $CHECK_OUTPUT "Created test queue $qname"
111   #
112   # Queue should be disabled; better x-check.
113   #
114   set q_state [ get_queue_state $qname ]
115   if { $q_state == "d" } {
116      puts $CHECK_OUTPUT "Queue $qname state DISABLED as expected"
117   } else {
118      add_proc_error "check_queue_state" \
119                     -1 \
120                     "unexpected state for queue $qname: $q_state. Should be: disabled"
121      return
122   }
123   #
124   # OK, enable queue
125   #
126   set qmod_options "-e $qname"
127   set result [ start_sge_bin "qmod" "$qmod_options" "" "" exit_code]
128   #
129   # Again, x-check if queue is enabled.
130   #
131   set q_state [ get_queue_state $qname ]
132   if { $q_state == "" } {
133      puts $CHECK_OUTPUT "Queue $qname state ENABLED as expected"
134   } else {
135      add_proc_error "check_queue_state" \
136                     -1 \
137                     "unexpected state for $qname: $q_state. Should be enabled"
138      return
139   }
140   #
141   # Shutdown and restart qmaster
142   #
143   shutdown_system_daemon $ts_config(master_host) "qmaster"
144   startup_qmaster 0
145   #
146   # Give execd's some time to re-register with new qmaster and
147   # update load report and queue status. A grace period of
148   # 100 seconds should be sufficient.
149   #
150   set success 0
151   for { set index 1 } { $index <= 10 } { incr index 1 } {
152      #
153      # Wait until queue enters state enabled
154      #
155      set q_state [ get_queue_state $qname ]
156      if { $q_state == "" } {
157         #
158         # Queue is enabled. All well, exit from here.
159         #
160         puts $CHECK_OUTPUT "Queue $qname state ENABLED as expected"
161         set success 1
162         break
163      }
164      puts $CHECK_OUTPUT "status: $q_state ...still waiting...($index)"
165      sleep 10
166   }
167   if { $success == 0 } {
168      add_proc_error "check_queue_state" \
169                     -1 \
170                     "unexpected state for $qname: $q_state. Should be enabled"
171      return
172  }
173}
174