From: marios <[email protected]>

Signed-off-by: marios <[email protected]>
---
 tests/README                      |  101 +++++++++++++++++++++++++++++++++++++
 tests/Rakefile                    |   10 +++-
 tests/deltacloud/base_api_test.rb |    8 ++--
 3 files changed, 114 insertions(+), 5 deletions(-)
 create mode 100644 tests/README

diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..e273248
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,101 @@
+API TESTS README:
+=================
+
+These tests use RestClient [https://github.com/archiloque/rest-client] to make
+requests to a deltacloud server running somewhere. The requests/tests are meant
+ to exercise all the REST routes defined in the API
+[http://deltacloud.apache.org/rest-api.html]. At minimum you need to configure
+the tests with the location of the deltacloud server to be tested, as well as
+the credentials for the driver you expect to be running at that deltacloud 
server.
+ Otherwise you'll see a RunTime error like:
+
+"No user or password in config.yaml for openstack driver used by
+http://localhost:3001/api";
+
+
+RUNNING the tests:
+==================
+
+* Need a deltacloud server running somewhere
+* edit the config.yaml file (more on this below)
+* rake test:deltacloud to run all tests
+* rake test:deltacloud:COLLECTION to run a specific collection test, or 
'base_api'
+  for just the API tests.... e.g. rake test:deltacloud:buckets, rake
+  test:deltacloud:base_api, rake test:deltacloud:images
+* more verbose output is achieved by passing TEST_OPTS="-v", e.g.
+  rake test:deltacloud TEST_OPTS="-v"
+
+
+CONFIGURATION - the config.yaml file:
+=====================================
+
+* api_url - set this to the URI for the running deltacloud server
+* each driver has it's own section... enter credentials for the driver
+  you expect to be running at api_url. If there is no section for your driver,
+  add it - the section should have the name used by the deltacloud server for 
that
+  driver. For example for the rhevm driver:
+
+---
+api_url: "http://localhost:3003/api";
+mock:
+  user: "mockuser"
+  password: "mockpassword"
+#this is a comment
+rhevm:
+  user: "username"
+  password: "mypassword"
+
+* running the instances collection tests involves launching instances. The 
image,
+  realm and hardware profile used to launch those instances are chosen at 
random
+  from the returned lists. However, this may cause errors to occur - especially
+  in EC2 where for example a given realm may be 'at capacity' and not accepting
+  any more requests ("please use us-east-1b/1c/1a instead"), or your user creds
+  may not allow you to launch a particular image  (again this was seen for 
ec2).
+  If you are hitting errors like this, you can configure a 'preferred'
+  image/realm/hardware_profile to use for the instances test. Refer to the 
'ec2'
+  section of the config.yaml file:
+
+ec2:
+  user: KEY
+  password: SECRET_KEY
+  instances:
+    preferred_image: "ami-2b5fba42"
+    preferred_hwp: "m1.small"
+    preferred_realm: "us-east-1b"
+
+You can add this 'instances' section under any driver in the config.yaml file 
and
+those values will be used in the instances test. You can also only include only
+some of those, for example a preferred_image but not a preferred_hwp.
+
+
+FILE LAYOUT:
+============
+deltacloud
+|--D-->tests
+|------------------------------------------------------------------------------
+   |----->config.yaml                       the tests config file
+   |---------------------------------------------------------------------------
+   |----->Rakefile                          rake routes for running tests
+   |---------------------------------------------------------------------------
+   |--D-->deprecated                        'old' cuke tests - for reference
+   |---------------------------------------------------------------------------
+   |--D-->deltacloud                        tests for the deltacloud API - idea
+      |                                     is for test directories to be added
+      |                                     for CIMI and EC2 frontends
+      |------------------------------------------------------------------------
+      |-----> test_setup.rb                 loads configuration, wrappers for
+      |                                     RestClient methods (get/put/post
+      |                                     etc) and mini DSL - like
+      |                                     need_collection/need_feature.
+      |------------------------------------------------------------------------
+      |-----> base_api_test.rb              tests for the API itself
+      |------------------------------------------------------------------------
+      |-----> common_tests_collections.rb   common tests that are executed
+      |                                     for all collections
+      |------------------------------------------------------------------------
+      |-----> instances_test.rb             tests for instances collection
+      |------------------------------------------------------------------------
+      |-----> images_test.rb                tests for images collection
+      |------------------------------------------------------------------------
+      |... etc for all the collections
+
diff --git a/tests/Rakefile b/tests/Rakefile
index 26b27a4..88c1966 100644
--- a/tests/Rakefile
+++ b/tests/Rakefile
@@ -20,6 +20,14 @@ namespace :test do
   desc "Run tests for the Deltacloud API frontend."
   Rake::TestTask.new(:deltacloud) do |t|
     t.test_files = FileList["deltacloud/*_test.rb"]
-    t.options = "-v"
   end
+
+  namespace :deltacloud do
+    ["base_api", "buckets", "images", "instances", "instance_states", "keys", 
"realms", "storage_volumes", "storage_snapshots", "hardware_profiles"].each do 
|col|
+      Rake::TestTask.new(col) do |t|
+        t.test_files = FileList["deltacloud/#{col}_test.rb"]
+      end
+    end
+  end
+
 end
diff --git a/tests/deltacloud/base_api_test.rb 
b/tests/deltacloud/base_api_test.rb
index bd37b46..841b299 100644
--- a/tests/deltacloud/base_api_test.rb
+++ b/tests/deltacloud/base_api_test.rb
@@ -120,17 +120,17 @@ describe "Deltacloud API Entry Point" do
   end
 
   it 'must change the API PROVIDER using the /api;provider matrix parameter in 
URI' do
-    res = get(';provider=test1', :public => true)
+    res = get(";provider=test1", {:accept=>:xml, :noauth=>true})
     res.xml.root[:provider].wont_be_nil
     res.xml.root[:provider].must_equal 'test1'
-    res = get(';provider=test2', :public => true)
+    res = get(";provider=test2", {:accept=>:xml, :noauth=>true})
     res.xml.root[:provider].must_equal 'test2'
   end
 
   it 'must change the API DRIVER using the /api;driver matrix parameter in 
URI' do
-    res = get(';driver=ec2', :public => true)
+    res = get(";driver=ec2", {:accept=>:xml, :noauth=>true})
     res.xml.root[:driver].must_equal 'ec2'
-    res = get(';driver=mock', :public => true)
+    res = get(";driver=mock", {:accept=>:xml, :noauth=>true})
     res.xml.root[:driver].must_equal 'mock'
   end
 
-- 
1.7.6.5

Reply via email to