You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2013/04/26 01:16:05 UTC
git commit: CIMI tests: small changes to make work against FGCP
Updated Branches:
refs/heads/master c1d487af8 -> e8a2c85b6
CIMI tests: small changes to make work against FGCP
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/e8a2c85b
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/e8a2c85b
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/e8a2c85b
Branch: refs/heads/master
Commit: e8a2c85b647182ba10dacdbc32cfe846fb95b15a
Parents: c1d487a
Author: David Lutterkort <lu...@redhat.com>
Authored: Thu Apr 25 15:26:29 2013 -0700
Committer: David Lutterkort <lu...@redhat.com>
Committed: Thu Apr 25 16:15:58 2013 -0700
----------------------------------------------------------------------
tests/cimi/system1_test.rb | 22 +++++++++++-----------
tests/cimi/test_helper.rb | 12 +++++++++---
2 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/e8a2c85b/tests/cimi/system1_test.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/system1_test.rb b/tests/cimi/system1_test.rb
index 4b21961..2dd944a 100644
--- a/tests/cimi/system1_test.rb
+++ b/tests/cimi/system1_test.rb
@@ -72,7 +72,7 @@ class SystemTemplate < CIMI::Test::Spec
# 1.4 Create a new system from the systemTemplate
system_created = post(system_add_uri,
"<SystemCreate xmlns=\"#{CIMI::Test::CIMI_NAMESPACE}\">" +
- "<name>test_system</name>" +
+ "<name>dc_test_system_#{Time.now.to_i}</name>" +
"<systemTemplate href=\"" + get_a(cep_json, "systemTemplate") + "\"/>" +
"</SystemCreate>", :content_type => :xml)
end
@@ -131,20 +131,20 @@ 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)
+ sys = fetch(system_created.headers[:location])
# 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"])
+ sys = poll_state(sys, "STARTED", "STOPPED", "MIXED")
+ unless sys.state.eql?("STARTED")
+ uri = discover_uri_for("start", nil, sys.operations)
response = post( uri,
"<Action xmlns=\"http://schemas.dmtf.org/cimi/1\">" +
"<action>http://schemas.dmtf.org/cimi/1/action/start</action>" +
"</Action>",
:accept => :xml, :content_type => :xml)
response.code.must_equal 202
- poll_state(fetch(system_created.headers[:location]), "STARTED")
- get(fetch(system_created.headers[:location]).id, :accept => :json).json["state"].upcase.must_equal "STARTED"
+ sys = poll_state(sys, "STARTED")
end
+ sys.state.upcase.must_equal "STARTED"
end
# 1.11 Check that the machines are started
@@ -158,11 +158,11 @@ 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)
+ sys = fetch(system_created.headers[:location])
# 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"])
+ sys = poll_state(sys, "STARTED", "STOPPED", "MIXED")
+ unless sys.state.upcase.eql?("STOPPED")
+ uri = discover_uri_for("stop", nil, sys.operations)
response = post( uri,
"<Action xmlns=\"http://schemas.dmtf.org/cimi/1\">" +
"<action>http://schemas.dmtf.org/cimi/1/action/stop</action>" +
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/e8a2c85b/tests/cimi/test_helper.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index a1bdb76..8641ebe 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -113,11 +113,16 @@ module CIMI::Test::Methods
def cep(params = {})
get(api.cep_url, params)
end
+
def discover_uri_for(op, collection, operations = nil)
unless operations
- cep_json = cep(:accept => :json)
- #get the collection operations:
- operations = get(cep_json.json["#{collection}"]["href"], {:accept=> :json}).json["operations"]
+ if collection
+ cep_json = cep(:accept => :json)
+ #get the collection operations:
+ operations = get(cep_json.json["#{collection}"]["href"], {:accept=> :json}).json["operations"]
+ else
+ operations = []
+ end
end
op_regex = Regexp.new(op, Regexp::IGNORECASE) # "add" == /add/i
op_uri = operations.inject(""){|res,current| res = current["href"] if current["rel"] =~ op_regex; res} unless operations.nil?
@@ -262,6 +267,7 @@ module CIMI::Test::Methods
sleep(10)
res = fetch(res.id)
end
+ return res
end
def machine_stop_start(machine, action, state)