From: Dies Koper <[email protected]>
---
tests/cimi/system1_test.rb | 6 +++++-
tests/cimi/test_helper.rb | 12 +++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/tests/cimi/system1_test.rb b/tests/cimi/system1_test.rb
index 6102c37..0acae54 100644
--- a/tests/cimi/system1_test.rb
+++ b/tests/cimi/system1_test.rb
@@ -133,6 +133,8 @@ class SystemTemplate < CIMI::Test::Spec
# 1.10 Starting the new System
it "should be able to start the system", :only => :json do
test_system_created = get(fetch(system_created.headers[:location]).id,
:accept => :json)
+ # ensure the system has reached a stable state (STOPPED, MIXED or STARTED)
+ poll_state(fetch(system_created.headers[:location]), ["STARTED",
"STOPPED", "MIXED"])
unless test_system_created.json["state"].eql?("STARTED")
uri = discover_uri_for("start", "",
test_system_created.json["operations"])
response = post( uri,
@@ -158,7 +160,9 @@ class SystemTemplate < CIMI::Test::Spec
# 1.12 Stop the new System
it "should be able to stop the system", :only => :json do
test_system_created = get(fetch(system_created.headers[:location]).id,
:accept => :json)
- unless test_system_created.json["state"].eql?("STOPPED")
+ # ensure the system has reached a stable state (STOPPED, MIXED or STARTED)
+ poll_state(fetch(system_created.headers[:location]), ["STARTED",
"STOPPED", "MIXED"])
+ unless test_system_created.json["state"].upcase.eql?("STOPPED")
uri = discover_uri_for("stop", "",
test_system_created.json["operations"])
response = post( uri,
"<Action xmlns=\"http://schemas.dmtf.org/cimi/1\">" +
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index c4bedac..66f32be 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -254,12 +254,14 @@ module CIMI::Test::Methods
log.debug "/#{method.to_s.upcase} #{absolute_url(path)}"
end
- def poll_state(machine, state)
- while not machine.state.upcase.eql?(state)
- puts state
- puts 'waiting for machine to be: ' + state.to_s()
+ def poll_state(stateful_resource, states)
+ states = [states] unless states.is_a? Array
+ while not states.include?(stateful_resource.state.upcase)
+ puts stateful_resource.state
+ puts 'waiting for resource to be: ' + states.join(' or ').to_s
sleep(10)
- machine = machine(:refetch => true)
+ stateful_resource = machine(:refetch => true) if
stateful_resource.is_a? CIMI::Model::Machine
+ stateful_resource = machine(:refetch => true) if
stateful_resource.is_a? CIMI::Model::System
end
end
--
1.8.0.msysgit.0