You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2013/03/18 18:08:02 UTC

git commit: CIMI - Tests - Extended machine scenarios part 2 and plan corrections

Updated Branches:
  refs/heads/master 858bbe0ef -> a42a2a714


CIMI - Tests - Extended machine scenarios part 2 and plan corrections

TrackedAt: http://tracker.deltacloud.org/patch/ad87387648d328a70c3952ca78787245657caf1f


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

Branch: refs/heads/master
Commit: a42a2a714960c19f8e2550089911b4a8beaba6d7
Parents: 858bbe0
Author: Ronelle Landy <rl...@redhat.com>
Authored: Fri Mar 15 10:34:29 2013 -0400
Committer: marios <ma...@redhat.com>
Committed: Mon Mar 18 19:01:53 2013 +0200

----------------------------------------------------------------------
 tests/cimi/machex2_test.rb   |   95 +++++++++++++++++++++++++++++++++++++
 tests/cimi/plan/scMachEx.xml |   21 ++++----
 2 files changed, 106 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a42a2a71/tests/cimi/machex2_test.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/machex2_test.rb b/tests/cimi/machex2_test.rb
new file mode 100644
index 0000000..f59f790
--- /dev/null
+++ b/tests/cimi/machex2_test.rb
@@ -0,0 +1,95 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+$:.unshift File.join(File.dirname(__FILE__))
+
+require "test_helper.rb"
+
+class RestartAMachine < CIMI::Test::Spec
+  RESOURCE_URI =
+    "http://schemas.dmtf.org/cimi/1/Machine"
+  ROOTS = ["machines", "machineImages", "machineConfigurations"]
+
+  MiniTest::Unit.after_tests {  teardown(@@created_resources, api.basic_auth) }
+
+  #  Ensure test executes in test plan order
+  i_suck_and_my_tests_are_order_dependent!
+
+  # 1: Query the CEP
+  model :subject, :cache => true do |fmt|
+    cep(:accept => fmt)
+  end
+
+  # CEP.machines, CEP.machineConfigs and CEP.machineImages must be set
+  query_the_cep(ROOTS)
+
+  # 2: Create a new machine
+  cep_json = cep(:accept => :json)
+  # Discover machine create URI:
+  machine_add_uri = discover_uri_for("add", "machines")
+  machine_created = post(machine_add_uri,
+    "<MachineCreate>" +
+      "<name>cimi_machine_machex2</name>" +
+      "<description> created as part of tests/cimi/machex2_test </description>" +
+      "<machineTemplate>" +
+        "<machineConfig " +
+          "href=\"" + get_a(cep_json, "machineConfig") + "\"/>" +
+        "<machineImage " +
+          "href=\"" + get_a(cep_json, "machineImage") + "\"/>" +
+      "</machineTemplate>" +
+    "</MachineCreate>",
+    :accept => :json, :content_type => :xml)
+
+  model :machine do |fmt|
+    get machine_created.json["id"], :accept => fmt
+  end
+
+  it "should add resource for cleanup", :only => :json do
+    @@created_resources[:machines] << machine_created.json["id"]
+  end
+
+  # 3. Find the restart operation
+  it "should advertise a restart operation" do
+
+  s = Set.new ["STOPPED", "STARTED"]
+  machine = get(machine_created.json["id"], :accept=>:json)
+        5.times do |j|
+          break if s.include?(machine.json["state"].upcase)
+          puts machine.json["state"]
+          puts 'waiting for machine to be in a stable initial state'
+          sleep(5)
+          machine = get(machine_created.json["id"], :accept=>:json)
+        end unless s.include?(machine.json["state"].upcase)
+
+    if (discover_uri_for("restart","", machine.json["operations"]).nil?())
+      # Change the machine state and check for the restart operation
+      machine = machine(:refetch => true)
+      if machine.state.upcase.eql?("STOPPED")
+        machine_stop_start(machine(:refetch => true), "start", "STARTED")
+      elsif machine.state.upcase.eql?("STARTED")
+        machine_stop_start(machine(:refetch => true), "stop", "STOPPED")
+      end
+    end
+    unless discover_uri_for("restart","", machine.json["operations"]).nil?()
+      # Restart the machine
+      machine_stop_start(machine(:refetch => true), "restart", "STARTED")
+      machine = get(machine_created.json["id"], :accept=>:json)
+      machine.code.must_be_one_of [200, 202]
+      machine.json["state"].must_equal "STARTED"
+    end
+  end
+
+ end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a42a2a71/tests/cimi/plan/scMachEx.xml
----------------------------------------------------------------------
diff --git a/tests/cimi/plan/scMachEx.xml b/tests/cimi/plan/scMachEx.xml
index c3715a9..bcffdd5 100644
--- a/tests/cimi/plan/scMachEx.xml
+++ b/tests/cimi/plan/scMachEx.xml
@@ -38,9 +38,8 @@
 
   <part title="Capturing a Machine">
    <note> From spec: This operation will create a new Machine Image from an existing Machine. This operation is defined
-within the Machine Image resource; see 5.14.7.1 for more details. Note that while this operation is
-performed against a Machine Image, its presence in the Machine serialization is used to advertise
-support for the operation.</note>
+within the Machine Image resource; see 5.14.7.1 for more details. Note that while the HTTP request which will perform this
+ operation is sent to the MachineImageCollection resource, it is present in the Machine resource's serialization."</note>
   <tests>
     <test name="Query the CEP">
 
@@ -178,10 +177,9 @@ Content-Type: application/json
 
 	<note> HTTP response code must be "201 Created" </note>
 	<note> The machineImage must have:
-          <item> id? </item>
           <item> state </item>
           <item> type </item>
-          <item> imageLocation </item> </note>
+          <item> name </item> </note>
 
       <p/>
       <popup title="Sample">
@@ -328,7 +326,7 @@ Location: http://example.com/machines/machineId12345
 	an intermediate state is returned, poll for the machine state to
 	change to a stable state where the restart operation can be found. </note>
      <note> Some providers allow for restarting a machine
-        in a RUNNING/STARTED state while other providers support
+        in a STARTED state while other providers support
         restarting a machine in a STOPPED state.
         If, after the machine is in a stable initial state, the restart
         operation is not advertised, the test should change the machine's state
@@ -369,16 +367,17 @@ Content-Type: application/json
 
     <test name="Restart the Machine">
      <desc>
-      Execute a POST /machines/machineId/restart
-      <note> If the provider under test supports the 'restart' action from both the STOPPED and RUNNING/STARTED states, both should be tested. </note>
+      Send a HTTP POST request to the URI corresponding to the restart operation - as
+      discovered in 2.3 above
+      <note> If the provider under test supports the 'restart' action from both the STOPPED and STARTED states, both should be tested. </note>
     </desc>
 
     <succ>
     <note> The response to the restart operation must be either "200 OK" or "202 Accepted". </note>
     <note> The state reported by the response to the 'restart machine'
-	operation might be a 'STOPPING' (if the machine was initially in a STARTED/RUNNING state), and then 'STARTING' or other intermediate
+	operation might be a 'STOPPING' (if the machine was initially in a STARTED state), and then 'STARTING' or other intermediate
 	state before the machine can be placed into a stable
-	RUNNING/STARTED state. </note>
+	STARTED state. </note>
 
       <p/>
       <popup title="Sample">
@@ -552,6 +551,8 @@ Content-Type: application/json
      <desc>
 	 The user_data may be available from inside the Machine using one of
 the following three methods: Metadata server, Disk or Image Modification - depending on the provider under test. SSH to the machine using the address found the step above and use the user_data access method supported by the provider to check that the user_data is accessible from the machine.
+You can discover the specific mechanism in use for this provider by querying the capabilities
+attribute of the Machine ResourceMetadata resource.
      </desc>
 
     <succ>