deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [1/2] git commit: CIMI tests - add create machineTemplate for scenario
Date Mon, 03 Dec 2012 15:09:33 GMT
Updated Branches:
  refs/heads/master ca39bcaed -> b4c8a0747


CIMI tests - add create machineTemplate for scenario


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/b4c8a074
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/b4c8a074
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/b4c8a074

Branch: refs/heads/master
Commit: b4c8a07472c94648624b709700475d68b3747bd7
Parents: eed21c6
Author: marios <marios@redhat.com>
Authored: Mon Dec 3 17:08:18 2012 +0200
Committer: marios <marios@redhat.com>
Committed: Mon Dec 3 17:08:18 2012 +0200

----------------------------------------------------------------------
 tests/cimi/part3_test.rb  |   43 +++++++++++++++++++++++++++------------
 tests/cimi/test_helper.rb |    4 +-
 2 files changed, 32 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b4c8a074/tests/cimi/part3_test.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/part3_test.rb b/tests/cimi/part3_test.rb
index 190fb61..4b70efe 100644
--- a/tests/cimi/part3_test.rb
+++ b/tests/cimi/part3_test.rb
@@ -23,17 +23,40 @@ class CreateNewMachineFromMachineTemplate < CIMI::Test::Spec
     "http://schemas.dmtf.org/cimi/1/CloudEntryPoint"
   ROOTS = ["machines", "machineImages", "machineConfigurations"]
 
+  model :subject, :cache => true do |fmt|
+    cep(:accept => fmt)
+  end
+  # This test must adhere to one of the "Query the CEP" test in the previous section.
+  # CEP.machines, CEP.machineConfigs and CEP.machineImages must be set
+  query_the_cep(ROOTS)
+
+  i_suck_and_my_tests_are_order_dependent!
   MiniTest::Unit.after_tests { teardown(@@created_resources, api.basic_auth) }
+  #create a machineTemplate for use in these tests:
+  cep_json = cep(:accept => :json)
+  mach_templ_add_uri = discover_uri_for("add", "machineTemplates")
+  mach_templ_created = RestClient.post(mach_templ_add_uri,
+    "<MachineTemplateCreate>" +
+      "<name>cimi_machineTemplate1</name>"+
+      "<description>A CIMI MachineTemplate, created by part3_test.rb</description>"+
+      "<property name=\"foo\">bar</property>"+
+      "<machineConfig " +
+        "href=\"" + get_a(cep_json, "machineConfig") + "\"/>" +
+      "<machineImage " +
+        "href=\"" + get_a(cep_json, "machineImage") + "\"/>" +
+    "</MachineTemplateCreate>",
+    {'Authorization' => api.basic_auth, :accept => :json})
 
   # 3.1: Query the CEP
-  model :subject, :cache => true do |fmt|
-    cep(:accept => fmt)
+  model :machineTemplate  do |fmt|
+    get mach_templ_created.json["id"], :accept => fmt
   end
 
   # This test must adhere to one of the "Query the CEP" test in the previous section.
   # CEP.machines, CEP.machineConfigs and CEP.machineImages must be set
   query_the_cep(ROOTS)
 
+
   # 3.2 Querying MachineTemplates
   # At least one MachineTemplate resource must appear in the collection
   it "should contain one MachineTemplates resource" do
@@ -43,14 +66,8 @@ class CreateNewMachineFromMachineTemplate < CIMI::Test::Spec
     assert_equal model.attribute_values[r][0].nil?(), false
   end
 
-  # A represenation of a MachineTemplatesCollection resource is returned.
-  cep_json = cep(:accept => :json)
-  model :machineTemplate do |fmt|
-    get(cep_json.json["machineTemplates"]["href"], {:accept=> :json}).json["machineTemplates"][0]
-  end
-
   it "should have a name" do
-    machineTemplate["name"].wont_be_empty
+    machineTemplate.name.wont_be_empty
   end
 
   it "should have a response code equal to 200" do
@@ -59,11 +76,11 @@ class CreateNewMachineFromMachineTemplate < CIMI::Test::Spec
   end
 
   it "should have a machineConfig" do
-    machineTemplate["machineConfig"].wont_be_empty
+    machineTemplate.machine_config["href"].wont_be_empty
   end
 
   it "should have a machineImage" do
-    machineTemplate["machineImage"].wont_be_empty
+    machineTemplate.machine_image["href"].wont_be_empty
   end
 
   # 3.3 Creating a new machine
@@ -75,14 +92,14 @@ class CreateNewMachineFromMachineTemplate < CIMI::Test::Spec
       "<Machine>" +
         "<name>cimi_machine_from_template" + fmt.to_s() + "</name>" +
         "<description> Created machine from template" + fmt.to_s() + "</description>"
+
-        "<machineTemplate" +
+        "<machineTemplate " +
           "href=\"" + get_a(cep_json, "machineTemplate")+ "\"/>" +
       "</Machine>",
     {'Authorization' => api.basic_auth, :accept => fmt})
   end
 
   it "should add resource for cleanup" do
-    @@created_resources[:machines] << machine.id
+    @@created_resources[:machine_templates] << machineTemplate.id
   end
 
   it "should have a name" do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b4c8a074/tests/cimi/test_helper.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index 1b235c7..9e5f6a3 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -287,7 +287,7 @@ module CIMI::Test::Methods
       # machine_image, machine_volumes, other collections
       if (not @@created_resources[:machine_images].nil?) &&
       (not @@created_resources[:volumes].nil?)
-        [:machine_images, :volumes].each do |col|
+        [:machine_images, :volumes, :machine_templates].each do |col|
           @@created_resources[col].each do |k|
             attempts = 0
             begin
@@ -414,7 +414,7 @@ class CIMI::Test::Spec < MiniTest::Spec
   def setup
    unless defined? @@created_resources
      # Keep track of what collections were created for deletion after tests:
-     @@created_resources = {:machines=>[], :machine_images=>[], :volumes=>[]}
+     @@created_resources = {:machines=>[], :machine_images=>[], :volumes=>[], :machine_templates=>[]}
    end
    @@created_resources
  end


Mime
View raw message