From: Ronelle Landy <rla...@redhat.com>

---
 tests/cimi/machex2_test.rb     |   95 ++++++
 tests/cimi/plan/scMachEx.xml   |  611 +++++++++++++++++++++++++++++++++++++++
 tests/cimi/plan/scRMD_rev2.xml |  619 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1325 insertions(+), 0 deletions(-)
 create mode 100644 tests/cimi/machex2_test.rb
 create mode 100644 tests/cimi/plan/scMachEx.xml
 create mode 100644 tests/cimi/plan/scRMD_rev2.xml

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
diff --git a/tests/cimi/plan/scMachEx.xml b/tests/cimi/plan/scMachEx.xml
new file mode 100644
index 0000000..bcffdd5
--- /dev/null
+++ b/tests/cimi/plan/scMachEx.xml
@@ -0,0 +1,611 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="file:sc2html.xsl" title="scenario"?>
+<scenario xmlns="http://www.wstf.org";>
+
+ <metadata>
+  <number>CIMI Machines</number>
+  <title>Extended Scenarios</title>
+  <date>2013/03/06</date>
+  <status>Draft</status>
+  <nowstf/>
+ </metadata>
+
+ <abstract>
+  These scenarios will test Machines collection as defined in the CIMI 
specification. These scenarios were not included in the initial CIMI-Basics 
plan 
(http://members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html).
+ </abstract>
+
+ <section title="Dependencies">
+  <scope>
+   <technology name="CIMI" 
url="http://dmtf.org/sites/default/files/standards/documents/DSP0263_1.0.0.pdf"/>
+  </scope>
+
+  <namespaces>
+   <namespace prefix="cimi" ns="http://schemas.dmtf.org/cimi/1"; name="CIMI"/>
+   <namespace prefix="xs" ns="http://www.w3.org/2001/XMLSchema";
+                           name="XML Schema"/>
+   <namespace prefix="scMACHEX" 
ns="http://www.wstf.org/docs/scenarios/scMACHEX";
+                           name="SCMACHEX (this scenario)"/>
+  </namespaces>
+ </section>
+
+ <section title="Testcases">
+  The testcases are ordered by:
+       <item>Capturing a Machine</item>
+       <item>Restarting a Machine</item>
+       <item>Adding user_data when Creating a Machine</item>
+
+   <note>Testing of the CEP and Creation of a Machine are included in the 
CIMI-Basics scenarios and are not repeated here. Since these scenarios are 
machines related, the tests will require a Machine to be created at the start 
of each test. For steps to verify a machine was created as required, see the 
CIMI-Basics plan. </note>
+
+  <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 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">
+
+      <desc>
+       Consumer queries the CEP to determine the URLs
+       of the Machine and machineImage collection
+      </desc>
+
+      <succ>A serialization of a CEP is
+       returned. This test must adhere to the "Query the CEP"
+       test detailed in:
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+
+        <note> CEP.machines, CEP.machineConfigs and CEP.machineImages must be 
set </note>
+       <p/>
+
+      <popup title="Sample">
+      <xml>GET /CEP HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/CloudEntryPoint";,
+  "id": "http://example.com/CEP";,
+  "baseURI": "http://example.com/";,
+  "machineConfigs": { "href": "http://example.com/machineConfigs"; },
+  "machineImages": { "href": "http://example.com/machineImages"; },
+  "machines": { "href": "http://example.com/machines"; }
+}</xml>
+      </popup>
+
+     </succ>
+    </test>
+
+    <test name="Create a new machine">
+      <desc>
+       Create a
+       new machine using either a single machineTemplate or a
+       machineImage and a machineConfig
+     </desc>
+
+     <succ>
+       The response returned must adhere to the success criteria
+       described in
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+       (Creating a new Machine section)
+
+       <note> HTTP response code must be "201 Created" </note>
+       <note> The state reported by the response to the 'create machine'
+       operation might be a 'PENDING', 'CREATING' or other intermediate
+       state before the machine can be placed into a stable initial
+       state.</note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>POST /machines HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "machineTemplate": {
+    "machineConfig": { "href": " 
http://example.com/machine_configurations/small"; },
+    "machineImage": { "href": " http://example.com/machine_images/img2"; },
+    "credential": { "href": "http://example.com/creds/12345"; }
+  }
+}
+
+<hr/>HTTP/1.1 201 Created
+Location: http://example.com/machines/machineId12345
+</xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Find the capture operation">
+     <desc>
+       Execute a
+       GET on the id of the new machine to return the
+       available operations
+     </desc>
+
+     <succ>
+      <note> HTTP response code must be "200 OK" </note>
+      <note> The state reported by the response to the GET operation
+       might be a 'PENDING', 'CREATING' or other intermediate state
+       before the machine can be placed into a stable initial state. If
+       an intermediate state is returned, poll for the machine state to
+       change to a stable state where the capture operation can be found. 
</note>
+     <note> Some providers allow for creating a machineImage from a machine
+        in a STARTED/RUNNING state while other providers support creation of a
+        machineImage from a machine in a STOPPED state.
+        If, after the machine is in a stable initial state, the capture
+        operation is not advertised, the test should change the machine's state
+        by stopping or starting the machine and then check the operations
+        advertised to see if the capture operation is supported by a
+        machine in this changed state.</note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceType": "http://schemas.dmtf.org/cimi/1/Machine";,
+  "id": "http://example.com/machines/machineId12345";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "created": "2013-01-02T10:04:00Z",
+  "updated": "2013-01-22T10:04:00Z",
+  "state": "STARTED",
+  "cpu": "1",
+  "memory": 10485760,
+  "disks" : { "href": "http://example.com/machines/machineId12345/disks";,
+  "volumes": { "href": "http://example.com/machines/machineId12345/volumes"; },
+  "networkInterfaces": { "href": 
"http://example.com/machines/machineId12345/NIs";,
+  "operations": [
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/capture";,
+    "href": "http://example.com/cimi/machine_images"; },
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/stop";,
+     "href": "http://example.com/machines/machineId12345/stop"; }
+  ]
+}
+     </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Create a machineImage from the machine">
+      <desc>
+       Create a new machineImage from the machine create above using
+       the capture operation
+     </desc>
+
+     <succ>
+
+       <note> HTTP response code must be "201 Created" </note>
+       <note> The machineImage must have:
+          <item> state </item>
+          <item> type </item>
+          <item> name </item> </note>
+
+      <p/>
+      <popup title="Sample">
+      <xml>POST /CEP.machineImages HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/machineImageCreate";,
+  "name": "machineImageTest",
+  "description": "machineImage created from test machine",
+  "type": "IMAGE",
+  "imageLocation": "http://example.com/machines/machineId12345";
+}
+
+<hr/>HTTP/1.1 201 Created
+{
+  "id":"http://localhost:3001/cimi/machine_images/machineImageTest";,
+  "name":"machineImageTest",
+  "state":"AVAILABLE",
+  "type":"IMAGE",
+  "resourceURI":"http://schemas.dmtf.org/cimi/1/MachineImage";
+}
+</xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Cleanup">
+     <desc>
+       (STOP and) DELETE the machine created above.
+         DELETE the machineImage created above.
+     </desc>
+
+     <succ>
+
+      <note> HTTP response code must be one of (200-207) </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>DELETE /machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+   </tests>
+
+  </part>
+
+
+  <part title="Restarting a Machine">
+   <note> This test applies only if the Machines Collection exists and the 
restart operation is supported. </note>
+   <note> From spec: This operation will restart a Machine. If the Machine is 
in the "STARTED" state, this operation will have the semantic effect of 
executing the "stop" and then "start" operations. If the Machine is in the
+"STOPPED" state, this operation will have the semantic effect of executing the 
"start" operation.</note>
+   <tests>
+    <test name="Query the CEP">
+
+      <desc>
+       Consumer queries the CEP to determine the URLs
+       of the Machine collection
+      </desc>
+
+      <succ>A serialization of a CEP is
+       returned. This test must adhere to the "Query the CEP"
+       test detailed in:
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+
+        <note> CEP.machines, CEP.machineConfigs and CEP.machineImages must be 
set </note>
+       <p/>
+
+      <popup title="Sample">
+      <xml>GET /CEP HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/CloudEntryPoint";,
+  "id": "http://example.com/CEP";,
+  "baseURI": "http://example.com/";,
+  "machineConfigs": { "href": "http://example.com/machineConfigs"; },
+  "machineImages": { "href": "http://example.com/machineImages"; },
+  "machines": { "href": "http://example.com/machines"; }
+}</xml>
+      </popup>
+
+     </succ>
+    </test>
+
+    <test name="Create a new machine">
+      <desc>
+       Create a
+       new machine using either a single machineTemplate or a
+       machineImage and a machineConfig
+     </desc>
+
+     <succ>
+       The response returned must adhere to the success criteria
+       described in
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+       (Creating a new Machine section)
+
+       <note> HTTP response code must be "201 Created" </note>
+       <note> The state reported by the response to the 'create machine'
+       operation might be a 'PENDING', 'CREATING' or other intermediate
+       state before the machine can be placed into a stable initial
+       state.</note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>POST /machines HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "machineTemplate": {
+    "machineConfig": { "href": " 
http://example.com/machine_configurations/small"; },
+    "machineImage": { "href": " http://example.com/machine_images/img2"; },
+    "credential": { "href": "http://example.com/creds/12345"; }
+  }
+}
+
+<hr/>HTTP/1.1 201 Created
+Location: http://example.com/machines/machineId12345
+</xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Find the restart operation">
+     <desc>
+       Execute a
+       GET on the id of the new machine to return the
+       available operations
+     </desc>
+
+     <succ>
+      <note> HTTP response code must be "200 OK" </note>
+      <note> The state reported by the response to the GET operation
+       might be a 'PENDING', 'CREATING' or other intermediate state
+       before the machine can be placed into a stable initial state. If
+       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 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
+        by stopping or starting the machine and then check the operations
+        advertised to see if the restart operation is supported by a
+        machine in this changed state.</note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceType": "http://schemas.dmtf.org/cimi/1/Machine";,
+  "id": "http://example.com/machines/machineId12345";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "created": "2013-01-02T10:04:00Z",
+  "updated": "2013-01-22T10:04:00Z",
+  "state": "STARTED",
+  "cpu": "1",
+  "memory": 10485760,
+  "disks" : { "href": "http://example.com/machines/machineId12345/disks";,
+  "volumes": { "href": "http://example.com/machines/machineId12345/volumes"; },
+  "networkInterfaces": { "href": 
"http://example.com/machines/machineId12345/NIs";,
+  "operations": [
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/capture";,
+    "href": "http://example.com/cimi/machine_images"; },
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/stop";,
+     "href": "http://example.com/machines/machineId12345/stop"; },
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/restart";,
+     "href": "http://example.com/machines/machineId12345/restart"; }
+  ]
+}
+     </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Restart the Machine">
+     <desc>
+      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 state), and then 'STARTING' or other intermediate
+       state before the machine can be placed into a stable
+       STARTED state. </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>POST x/machines/machineId HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/Action";,
+  "action": "http://schemas.dmtf.org/cimi/1/action/restart";
+}
+
+<hr/>HTTP/1.1 200 OK
+
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Cleanup">
+     <desc>
+       (STOP and) DELETE the machine created.
+     </desc>
+
+    <succ>
+     <note> HTTP response code must be one of (200-207) </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>DELETE /machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+   </tests>
+
+  </part>
+
+
+  <part title="Adding user_data when Creating a Machine">
+   <note> This test applies only if the Machines Collection exists and if 
user_data is supported. Check the Machine Resource metadata to confirm if 
user_data is supported.</note>
+   <note> From spec: To simplify the customization of individual Machines, it 
is possible to pass arbitrary data into the new
+Machine by using the userData parameter. The value of this parameter shall be 
the Base64-encoded
+payload. The Provider shall arrange for this data to be available from inside 
the Machine by using one of
+the following three methods: Metadata server, Disk or Image 
Modification.</note>
+   <tests>
+    <test name="Query the CEP">
+
+      <desc>
+       Consumer queries the CEP to determine the URLs
+       of the Machine collection
+      </desc>
+
+      <succ>A serialization of a CEP is
+       returned. This test must adhere to the "Query the CEP"
+       test detailed in:
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+
+        <note> CEP.machines, CEP.machineConfigs and CEP.machineImages must be 
set </note>
+       <p/>
+
+      <popup title="Sample">
+      <xml>GET /CEP HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/CloudEntryPoint";,
+  "id": "http://example.com/CEP";,
+  "baseURI": "http://example.com/";,
+  "machineConfigs": { "href": "http://example.com/machineConfigs"; },
+  "machineImages": { "href": "http://example.com/machineImages"; },
+  "machines": { "href": "http://example.com/machines"; }
+}</xml>
+      </popup>
+
+     </succ>
+    </test>
+
+    <test name="Create a new machine with user_data">
+      <desc>
+       Create a new machine with user_data. The user_data may be included in a 
single machineTemplate or passed directly in the operation to create the 
machine using a machineImage and a machineConfig.
+     </desc>
+
+     <succ>
+       The response returned must adhere to the success criteria
+       described in
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+       (Creating a new Machine section)
+
+       <note> HTTP response code must be "201 Created" </note>
+       <note> The state reported by the response to the 'create machine'
+       operation might be a 'PENDING', 'CREATING' or other intermediate
+       state before the machine can be placed into a stable initial
+       state.</note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>POST /machines HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "machineTemplate": {
+    "machineConfig": { "href": " 
http://example.com/machine_configurations/small"; },
+    "machineImage": { "href": " http://example.com/machine_images/img2"; },
+    "userData": "QmFzZS02NCBlbmNvZGVkIGRhdGE="
+    "credential": { "href": "http://example.com/creds/12345"; }
+  }
+}
+
+<hr/>HTTP/1.1 201 Created
+Location: http://example.com/machines/machineId12345
+</xml>
+      </popup>
+     </succ>
+    </test>
+
+
+   <test name="Find the address for the machine">
+     <desc>
+       Execute a
+       GET on the id of the new machine to return the
+       available ip address required to SSH to the machine.
+     </desc>
+
+     <succ>
+      <note> HTTP response code must be "200 OK" </note>
+      <note> The state reported by the response to the GET operation
+       might be a 'PENDING', 'CREATING' or other intermediate state
+       before the machine can be placed into a stable initial state. If
+       an intermediate state is returned, poll for the machine state to
+       change to a stable state where the ip address can be found.
+        This may require starting a STOPPED machine </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceType": "http://schemas.dmtf.org/cimi/1/Machine";,
+  "id": "http://example.com/machines/machineId12345";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "created": "2013-01-02T10:04:00Z",
+  "updated": "2013-01-22T10:04:00Z",
+  "state": "STARTED",
+  "cpu": "1",
+  "memory": 10485760,
+  "disks" : { "href": "http://example.com/machines/machineId12345/disks"; },
+  "volumes": { "href": "http://example.com/machines/machineId12345/volumes"; },
+  "networkInterfaces": {
+     "addresses": {"href": 
"http://example.com/machines/machineId12345/1.2.3.4"},
+  }
+  "operations": [
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/capture";,
+    "href": "http://example.com/cimi/machine_images"; },
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/stop";,
+     "href": "http://example.com/machines/machineId12345/stop"; }
+  ]
+}
+     </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Check that the user_data is available from the machine">
+     <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>
+     <note> Should be able to SSH to the machine using the credentials or 
password provided. </note>
+     <note> The Base-64 encoded user_data string passed to the machine should 
be accessible </note>
+     <note> The user_data accessed from the machine should match the exact 
string passed in the machine create operation above.</note>
+      <p/>
+      <popup title="Sample">
+       <xml> ssh root@1.2.3.4</xml>
+       <p/>
+       <xml> GET http://169.254.169.254/cimi/latest/user-data.
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+
+    <test name="Cleanup">
+     <desc>
+       (STOP and) DELETE the machine created.
+     </desc>
+
+    <succ>
+     <note> HTTP response code must be one of (200-207) </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>DELETE /machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+   </tests>
+
+  </part>
+
+  </section>
+
+ <section title="Findings">
+   <num>
+
+   </num>
+ </section>
+
+ <section title="Change History">
+  <changes>
+   <change date="2013/03/06" who="Ronelle Landy">Initial Draft</change>
+  </changes>
+ </section>
+
+</scenario>
+
diff --git a/tests/cimi/plan/scRMD_rev2.xml b/tests/cimi/plan/scRMD_rev2.xml
new file mode 100644
index 0000000..c8a48cc
--- /dev/null
+++ b/tests/cimi/plan/scRMD_rev2.xml
@@ -0,0 +1,619 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="file:sc2html.xsl" title="scenario"?>
+<scenario xmlns="http://www.wstf.org";>
+
+ <metadata>
+  <number>Entity Metadata</number>
+  <title>Capabilities</title>
+  <date>2013/02/01</date>
+  <status>Draft</status>
+  <nowstf/>
+ </metadata>
+
+ <abstract>
+  These scenarios will test the Resource Metadata Capabilties as defined in 
the CIMI specification. Relevant spec quotes:
+
+  <item>
+   ???Implementations of this specification SHOULD allow for
+Consumers to discover the metadata associated with each supported
+entity. Doing so allows for the discovery of Provider defined
+constraints on the CIMI defined attributes as well as discovery of
+any new extension attributes or operations that the Provider may have
+defined. EntityMetadata can also be used to express any Provider
+specific capabilities or features. The mechanism by which this
+metadata is made available will be protocol specific.???
+  </item>
+  <item> ??? A set of Provider defined metadata that can be used by
+Consumer to discover any capability or feature provided by this
+Provider.???
+  </item>
+ <p/>
+ </abstract>
+
+ <section title="Dependencies">
+  <scope>
+   <technology name="CIMI" 
url="http://dmtf.org/sites/default/files/standards/documents/DSP0263_1.0.0.pdf"/>
+  </scope>
+
+  <namespaces>
+   <namespace prefix="cimi" ns="http://schemas.dmtf.org/cimi/1"; name="CIMI"/>
+   <namespace prefix="xs" ns="http://www.w3.org/2001/XMLSchema";
+                           name="XML Schema"/>
+   <namespace prefix="scRMD" ns="http://www.wstf.org/docs/scenarios/scRMD";
+                           name="SCRMD (this scenario)"/>
+  </namespaces>
+ </section>
+
+ <section title="Testcases">
+  The testcases are ordered by:
+       <item>Resource Metadata Collection</item>
+       <item>Resource Metadata Entry within the collection</item>
+       <item>Capabilty/Attribute/Action associated with the Resource Metadata 
Entry</item>
+
+  <part title="Resource Metadata Collection">
+   <note> Test for the Resource Metadata collection. This test should only
+       be run once ??? not with every capability, attribute or action
+       tested. </note>
+  <tests>
+    <test name="Query the CEP">
+
+      <desc>
+       Consumer queries the CEP to determine the URLs
+       of the ResourceMetadata collection
+      </desc>
+
+      <succ>A serialization of a CEP is
+       returned. This test must adhere to the "Query the CEP"
+       test detailed in:
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+
+        <note> CEP.ReourceMetadata must be set </note>
+       <p/>
+
+      <popup title="Sample">
+      <xml>GET /CEP HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/CloudEntryPoint";,
+  "id": "http://example.com/CEP";,
+  "baseURI": "http://example.com/";,
+  "resourceMetadata": { "href": "http://example.com/resourceMetadata"; },
+  "machines": { "href": "http://example.com/machines"; }
+}</xml>
+      </popup>
+
+     </succ>
+    </test>
+
+    <test name="Query the CEP.resourceMetadata collection">
+     <desc>GET request is sent
+       to CEP.resourceMetadata collection to query the metadata (attributes,
+       capabilities, actions) supported by the Cloud Provider. The
+       response can be returned in either format, XML or JSON.
+     </desc>
+
+     <succ>A representation of the CEP.resourceMetadata collection is
+       returned ??? using either JSON or XML serialization.
+
+      <note> HTTP response code must be "200 OK" </note>
+      <note> Content-Type header must be either "application/json"
+       or "application/xml" </note>
+      <note> id must be set to the URL of the resource metadata
+       collection</note>
+      <note> resourceURI must be set to point to
+       ResourceMetadataCollection</note>
+      <note> count must match value the number of ResourceMetadata
+       elements returned</note>
+      <note> ResourceMetadata elements must be listed (if they exist
+       for the provider)</note>
+      <note> For each collection appearing in the
+        CEP there should be a ResourceMetadata entry with the corresponding 
typeURI in the
+        ResourceMetadata collection </note>
+      <note> At least one of the capabilities/attributes/actions must be 
listed within
+       the Resource Metadata resource. Note that a collection Resource
+       Metadata resource does not have to have all three
+       (capabilities, attributes and actions) necessarily, but at least one
+       capability/attribute/action must be present. </note>
+     <note> All metadata for a given resource type will be included within the
+      ResourceMetadata representation for the resource type </note>
+
+    <p/>
+
+      <popup title="Sample">
+      <xml>GET /resourceMetadata HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/ResourceMetadataCollection";,
+  "id":"http://example.com/cimi/CEP.resourceMetadata";,
+  "count": 1,
+  "resourceMetadata":
+    "id": "http://example.com/cimi/CEP.resourceMetadata/collection";,
+    "name": "Collection",
+    "typeUri": "http://schemas.dmtf.org/cimi/1/Collection";,
+    [{"capabilities":
+      [{"name":"Capability1",
+        
"uri":"http://schemas.dmtf.org/cimi/1/capabilityCollection/Capability1";,
+        "description":"Description of Capability 1",
+        "value":"valueOfCapability1"},
+      {"name":"Capability2",
+       
"uri":"http://schemas.dmtf.org/cimi/1/capability/Collection/Capability2";,
+       "description":"Description of Capability 2",
+       "value":"valueOfCapability2A, valueOfCapability2B"}]
+    }],
+}
+       </xml>
+      </popup>
+
+     </succ>
+    </test>
+
+   </tests>
+  </part>
+
+<part title="Machines Resource Metadata">
+   <note>
+    This test applies only if the CEP.machines collection is present and the 
CEP.ResourceMetadata
+ collection contains an entry corresponding to the Machine resource.
+   </note>
+  <tests>
+    <test name="Query the CEP.resourceMetadata collection">
+     <desc> GET request is sent to CEP.resourceMetadata collection to query 
the metadata associated
+       with the 'Machine' entry
+     </desc>
+
+     <succ>A representation of the CEP.resourceMetadata collection is
+      returned ??? using either JSON or XML serialization.
+
+       <note> HTTP response code must be "200 OK" </note>
+       <note>ResourceMetadata.id must be set </note>
+       <note> ResourceMetadata.name must be set to Machine </note>
+       <note> ResourceMetadata.typeUri must be set </note>
+       <note> At least one of the capabilities/attributes/actions must be 
listed within
+       the Machine Resource Metadata resource. Note that a Machine Resource
+       Metadata resource does not have to have all three
+       (capabilities, attributes and actions) necessarily, but at least one
+       capability/attribute/action must be returned.  </note>
+
+      <p/>
+
+      <popup title="Sample">
+      <xml>GET /resourceMetadata HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/ResourceMetadataCollection";,
+  "id":"http://example.com/cimi/CEP.resourceMetadata";,
+  "count": 1,
+  "resourceMetadata":
+    "id": "http://example.com/cimi/CEP.resourceMetadata/collection";,
+    "name": "Collection",
+    "typeUri": "http://schemas.dmtf.org/cimi/1/Collection";,
+    [{"capabilities":
+      [{"name":"Capability1",
+        
"uri":"http://schemas.dmtf.org/cimi/1/capabilityCollection/Capability1";,
+        "description":"Description of Capability 1",
+        "value":"valueOfCapability1"},
+      {"name":"Capability2",
+       
"uri":"http://schemas.dmtf.org/cimi/1/capability/Collection/Capability2";,
+       "description":"Description of Capability 2",
+       "value":"valueOfCapability2A, valueOfCapability2B"}]
+    }],
+}
+      </xml>
+     </popup>
+     </succ>
+    </test>
+
+    <test name="Query the ResourceMetadata entry">
+     <desc> Issue a specific GET
+       request to return the capabilities, attributes and actions
+       associated with the Machine ResourceMetadata entry only
+     </desc>
+
+     <succ>
+     <note> HTTP response code must be "200 OK". </note>
+     <note> Each capability, attribute and action advertised must contain:
+       <note> name </note>
+       <note> uri (unique)</note>
+       <note> description </note>
+       <note> value </note>
+     </note>
+      <p/>
+      <popup title="Sample">
+      <xml>GET /resourceMetadata/machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+"resourceURI": "http://schemas.dmtf.org/cimi/1/ResourceMetadata";,
+"id": "http://example.com/cimi/CEP.resourceMetadata/machine";,
+"name": "Machine",
+"typeUri": "http://schemas.dmtf.org/cimi/1/Machine";,
+"capabilities":
+    [{"name":"Capability1",
+      "uri":"http://schemas.dmtf.org/cimi/1/capabilityCollection/Capability1";,
+      "description":"Description of Capability 1",
+      "value":"valueOfCapability1"},
+    {"name":"Capability2",
+     "uri":"http://schemas.dmtf.org/cimi/1/capability/Collection/Capability2";,
+     "description":"Description of Capability 2",
+     "value":"valueOfCapability2A, valueOfCapability2B"}]
+}
+      </xml>
+      </popup>
+     </succ>
+    </test>
+
+   </tests>
+
+  </part>
+
+<part title="Default Initial State ??? Machine Capability">
+ <note> This test applies only if the ResourceMetadata
+ corresponding to the Machine resource contains a DefaultInitialState 
capability. </note>
+  <tests>
+    <test name="Query the ResourceMetadata entry">
+     <desc>
+       Consumer queries Machine
+       ResourceMetadata to find the DefaultInitialState capability
+     </desc>
+
+     <succ>
+       A serialization of the CEP.resourceMetadata collection is returned
+       ??? using either JSON or XML serialization.  This test must adhere
+       to one of the "Query the ResourceMetadata entry" tests in
+       the previous section.
+
+       <note> The  DefaultInitialState capability must be returned </note>
+        <note>The capability advertised must contain:
+          <note> name </note>
+          <note> uri (unique)</note>
+          <note> description </note>
+          <note> a single value </note>
+       </note>
+
+      <p/>
+      <popup title="Sample">
+      <xml>GET /resourceMetadata/machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/xml
+
+&lt;ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1";
+ resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata";>
+&lt;id>http://example.com/cimi/CEP.resourceMetadata/machine&lt;/id>
+&lt;name>Machine&lt;/name>
+&lt;typeUri>http://schemas.dmtf.org/cimi/1/Machine&lt;/typeUri>
+&lt;capability name="DefaultInitialState"
+uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState";
+description="Indicates what the default initial state of a new Machine">
+STARTED&lt;/capability>
+&lt;/ResourceMetadata>
+     </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Put collection member in state to verify capability">
+     <desc>
+       Create a
+       new machine using either a single machineTemplate or a
+       machineImage and a machineConfig ??? without specifying a desired
+       initial state
+     </desc>
+
+
+     <succ>
+       The response returned must adhere to the success criteria
+       described in
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+       (Creating a new Machine section)
+
+       <note> HTTP response code must be "201 Created" </note>
+       <note> The state reported by the response to the 'create machine'
+       operation might be a 'PENDING', 'CREATING' or other intermediate
+       state before the machine can be placed into a stable initial
+       state.</note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>POST /machines HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "machineTemplate": {
+    "machineConfig": { "href": " 
http://example.com/machine_configurations/small"; },
+    "machineImage": { "href": " http://example.com/machine_images/img2"; },
+    "credential": { "href": "http://example.com/creds/12345"; }
+  }
+}
+
+<hr/>HTTP/1.1 201 Created
+Location: http://example.com/machines/machineId12345
+</xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Execute a query/action to expose the capability">
+     <desc>
+       Execute a
+       GET on the id of the new machine to return the
+       machine stable initial state
+     </desc>
+
+     <succ>
+      <note> HTTP response code must be "200 OK" </note>
+      <note> The state reported by the response to the GET operation
+       might be a 'PENDING', 'CREATING' or other intermediate state
+       before the machine can be placed into a stable initial state. If
+       an intermediate state is returned, poll for the machine state to
+       change to a stable initial state </note>
+     <note> After the machine is in a stable initial state, the value
+       returned in the STATE entry of the response must match the value
+       advertised in the DefaultInitialState capability </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceType": "http://schemas.dmtf.org/cimi/1/Machine";,
+  "id": "http://example.com/machines/machineId12345";,
+  "name": "machineDefaultInitialState",
+  "description": "Machine to test the default initial state",
+  "created": "2013-01-02T10:04:00Z",
+  "updated": "2013-01-22T10:04:00Z",
+  "state": "STARTED",
+  "cpu": "1",
+  "memory": 10485760,
+  "disks" : { "href": "http://example.com/machines/machineId12345/disks";,
+  "volumes": { "href": "http://example.com/machines/machineId12345/volumes"; },
+  "networkInterfaces": { "href": 
"http://example.com/machines/machineId12345/NIs";,
+  "operations": [
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/capture";,
+    "href": "http://example.com/cimi/machine_images"; },
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/stop";,
+     "href": "http://example.com/machines/machineId12345/stop"; }
+  ]
+}
+     </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Cleanup">
+     <desc>
+       (STOP and) DELETE the machine created in test above
+     </desc>
+
+     <succ>
+
+      <note> HTTP response code must be one of (200-207) </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>DELETE /machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+   </tests>
+
+  </part>
+
+
+  <part title="Initial States ??? Machine Capability">
+   <note> This test applies only if the ResourceMetadata
+ corresponding to the Machine resource contains an InitialStates capability. 
</note>
+   <tests>
+    <test name="Query the ResourceMetadata entry">
+     <desc>
+       Consumer queries Machine
+       ResourceMetadata to find the InitialStates capability
+     </desc>
+
+     <succ>
+       A serialization of the CEP.resourceMetadata collection is returned
+       ??? using either JSON or XML serialization.  This test must adhere
+       to one of the "Query the ResourceMetadata entry" test in
+       the section.
+
+      <note>The InitialStates capability must be returned </note>
+      <note> The capability advertised must contain:
+      <note> name </note>
+      <note> uri (unique)</note>
+      <note> description </note>
+      <note> value(s) </note>
+      </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>GET /resourceMetadata/machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+
+Content-Type: application/xml
+
+&lt;ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1";
+resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata";>
+&lt;id>http://example.com/cimi/CEP.resourceMetadata/machine&lt;/id>
+&lt;name>Machine&lt;/name>
+&lt;typeUri>http://schemas.dmtf.org/cimi/1/Machine&lt;/typeUri>
+&lt;capability name="InitialStates"
+uri="http://schemas.dmtf.org/cimi/1/capability/Machine/InitialStates";
+description="Indicates the list of allowable initial states">
+STARTED,STOPPED&lt;/capability>
+&lt;/ResourceMetadata>
+      </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Put collection member in state to verify capability">
+     <desc>
+       Create a
+       new machine using either a single machineTemplate or a
+       machineImage and a machineConfig ??? specifying a desired initial
+       state which is different from the default value (see
+       DefaultInitalState capability)
+    </desc>
+
+    <succ>
+       The response returned must adhere to the success criteria
+       described in
+       
members.dmtf.org/apps/org/workgroup/vcmf/download.php/68964/cimiTest.html
+       (Creating a new Machine section)
+
+    <note> HTTP response code must be "201 Created" </note>
+    <note> The state reported by the response to the 'create machine'
+       operation might be a 'PENDING', 'CREATING' or other intermediate
+       state before the machine can be placed into a stable initial
+       state. </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>POST /machines HTTP/1.1
+Content-Type: application/json
+
+{ "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate";,
+  "name": "machineInitialStateStopped",
+  "description": "Machine to test initial states",
+  "machineTemplate": {
+    "initialState": "STOPPED"
+    "machineConfig": { "href": 
"http://example.com/machine_configurations/small"; },
+    "machineImage": { "href": "http://example.com/machine_images/img2"; },
+    "credential": { "href": "http://example.com/creds/12345"; }
+  }
+}
+<hr/>HTTP/1.1 201 Created
+Location: http://example.com/machines/machineId123456
+
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Execute a query/action to expose the capability">
+     <desc>
+       Execute a
+       GET /machines/new machine id operation to return the
+       machine stable initial state
+     </desc>
+
+     <succ>
+
+      <note> HTTP response code must be "200 OK" </note>
+      <note> The state reported by the response to the GET operation
+       might be a 'PENDING', 'CREATING' or other intermediate state
+       before the machine can be placed into a stable initial state. If
+       an intermediate state is returned, poll for the machine state to
+       change to a stable initial state </note>
+      <note> After the machine is in a stable initial state, the value
+       returned in the STATE entry of the response must match the value
+       specified when the machine was created in test step above </note>
+      <note> The machine response must advertise operations that match
+       the state initial stable state (for example, a machine created
+       with a STOPPED initial state should advertise 'start' as an
+       available operation) </note>
+
+      <p/>
+      <popup title="Sample">
+      <xml>GET /machines HTTP/1.1</xml>
+      <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+
+{ "resourceType": "http://schemas.dmtf.org/cimi/1/Machine";,
+  "id": "http://example.com/machines/machineId123456";,
+  "name": "machineInitialStateStopped",
+  "description": "Machine to test initial states",
+  "created": "2013-01-02T11:04:00Z",
+  "updated": "2013-01-22T11:04:00Z",
+  "state": "STOPPED",
+  "cpu": "1",
+  "memory": 10485760,
+  "disks" : { "href": "http://example.com/machines/machineId123456/disks";,
+  "volumes": { "href": "http://example.com/machines/machineId123456/volumes"; },
+  "networkInterfaces": { "href": 
"http://example.com/machines/machineId123456/NIs";,
+  "operations": [
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/capture";,
+    "href": "http://example.com/cimi/machine_images"; },
+    { "rel": "http://schemas.dmtf.org/cimi/1/action/start";,
+    "href": "http://example.com/machines/machineId123456/start"; }
+  ]
+}
+      </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Cleanup">
+     <desc>
+       (STOP and) DELETE the machine created.
+     </desc>
+
+    <succ>
+     <note> HTTP response code must be one of (200-207) </note>
+
+      <p/>
+      <popup title="Sample">
+       <xml>DELETE /machine HTTP/1.1</xml>
+       <p/>
+       <xml>HTTP/1.1 200 OK
+Content-Type: application/json
+       </xml>
+      </popup>
+     </succ>
+    </test>
+
+    <test name="Repeat the test for initial states advertised (if there are
+                       more states to test)">
+     <desc>
+       Repeat steps to exercise and
+       verify the responses when a machine is created with each of the
+       possible initial states advertised in the capability.
+
+       <note> This test only applies if their are more than one InitialStates. 
</note>
+     </desc>
+
+     <succ>
+       The output results should adhere to the success criteria
+       specified for each step ??? making adjustments relative to the
+       initial state under test.
+     </succ>
+    </test>
+
+   </tests>
+
+  </part>
+
+
+ </section>
+
+ <section title="Findings">
+   <num>
+
+   </num>
+ </section>
+
+ <section title="Change History">
+  <changes>
+   <change date="2013/01/03" who="Ronelle Landy">Initial Draft</change>
+  </changes>
+ </section>
+
+</scenario>
+
-- 
1.7.7.6

Reply via email to