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 2012/05/11 15:16:05 UTC

[1/2] git commit: Initial tests for FGCP driver - from Dies Kopper diesk@fast.au.fujitsu.com

Updated Branches:
  refs/heads/master c79de54d6 -> 7bc7e8a43


Initial tests for FGCP driver - from Dies Kopper diesk@fast.au.fujitsu.com

https://issues.apache.org/jira/browse/DTACLOUD-176


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

Branch: refs/heads/master
Commit: 7bc7e8a431a7e78cfeb6306abb023f551bc65ddd
Parents: dd8ac75
Author: marios <ma...@redhat.com>
Authored: Fri May 11 16:13:10 2012 +0300
Committer: marios <ma...@redhat.com>
Committed: Fri May 11 16:13:10 2012 +0300

----------------------------------------------------------------------
 server/Rakefile                                    |    4 +-
 server/tests/drivers/fgcp/api_test.rb              |   47 +++++++++++++
 .../tests/drivers/fgcp/hardware_profiles_test.rb   |   54 +++++++++++++++
 server/tests/drivers/fgcp/realms_test.rb           |   42 +++++++++++
 server/tests/drivers/fgcp/setup.rb                 |   13 ++++
 5 files changed, 158 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7bc7e8a4/server/Rakefile
----------------------------------------------------------------------
diff --git a/server/Rakefile b/server/Rakefile
index 8543285..147cdcf 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -72,7 +72,7 @@ rescue LoadError
 end
 
 namespace :test do
-  %w(mock rackspace rhevm openstack google).each do |driver|
+  %w(mock rackspace rhevm openstack google fgcp).each do |driver|
     desc "Run #{driver} unit tests"
     Rake::TestTask.new(driver) { |t|
       t.test_files = ['tests/common.rb', "tests/drivers/#{driver}/setup.rb"] + FileList.new("tests/drivers/#{driver}/*_test.rb") + FileList.new('tests/rabbit_test.rb')
@@ -94,7 +94,7 @@ end
 
 desc "Call our Test::Unit suite"
 task :test do
-  %w(mock rackspace rhevm openstack google).each do |driver|
+  %w(mock rackspace rhevm openstack google fgcp).each do |driver|
    Rake::Task["test:#{driver}"].reenable
    Rake::Task["test:#{driver}"].invoke
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7bc7e8a4/server/tests/drivers/fgcp/api_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/fgcp/api_test.rb b/server/tests/drivers/fgcp/api_test.rb
new file mode 100644
index 0000000..2eb399d
--- /dev/null
+++ b/server/tests/drivers/fgcp/api_test.rb
@@ -0,0 +1,47 @@
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/common'
+
+module FGCPTest
+
+  class ApiTest < Test::Unit::TestCase
+    include Rack::Test::Methods
+
+    def app
+      Sinatra::Application
+    end
+
+    def test_01_it_returns_entry_points
+      get_auth_url '/api;driver=fgcp/?force_auth=1'
+      (last_xml_response/'/api').first[:driver].should == 'fgcp'
+      (last_xml_response/'/api/link').length.should > 0
+    end
+
+    def test_02_it_has_fgcp_instance_features
+      get_url '/api;driver=fgcp'
+      features = (last_xml_response/'/api/link[@rel="instances"]/feature').collect { |f| f[:name] }
+      features.include?('user_name').should == true
+      features.include?('authentication_password').should == true
+      features.length.should == 2
+    end
+
+    def test_03_it_has_fgcp_image_features
+      get_url '/api;driver=fgcp'
+      features = (last_xml_response/'/api/link[@rel="images"]/feature').collect { |f| f[:name] }
+      features.include?('user_name').should == true
+      features.include?('user_description').should == true
+      features.length.should == 2
+    end
+
+    def test_04_it_has_fgcp_collections
+      get_url '/api;driver=fgcp'
+      collections = (last_xml_response/'/api/link').collect { |f| f[:rel] }
+      collections.include?('instance_states').should == true
+      collections.include?('instances').should == true
+      collections.include?('images').should == true
+      collections.include?('realms').should == true
+      collections.include?('hardware_profiles').should == true
+      collections.length.should == 6
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7bc7e8a4/server/tests/drivers/fgcp/hardware_profiles_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/fgcp/hardware_profiles_test.rb b/server/tests/drivers/fgcp/hardware_profiles_test.rb
new file mode 100644
index 0000000..623b9c2
--- /dev/null
+++ b/server/tests/drivers/fgcp/hardware_profiles_test.rb
@@ -0,0 +1,54 @@
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/common'
+
+module FGCPTest
+
+  class HardwareProfilesTest < Test::Unit::TestCase
+    include Rack::Test::Methods
+
+    def app
+      Sinatra::Application
+    end
+
+    def test_01_it_returns_hardware_profiles
+      get_auth_url '/api;driver=fgcp/hardware_profiles'
+      (last_xml_response/'hardware_profiles/hardware_profile').length.should == 4
+    end
+
+    def test_02_each_hardware_profile_has_a_name
+      get_auth_url '/api;driver=fgcp/hardware_profiles'
+      (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
+        (profile/'name').text.should_not == nil
+        (profile/'name').text.should_not == ''
+      end
+    end
+
+    def test_03_each_hardware_profile_has_correct_properties
+      get_auth_url '/api;driver=fgcp/hardware_profiles'
+      (last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
+        (profile/'property[@name="architecture"]').first[:value].should == 'x86_64'
+        (profile/'property[@name="memory"]').first[:unit].should == 'MB'
+        (profile/'property[@name="memory"]').first[:kind].should == 'fixed'
+#        (profile/'property[@name="storage"]').first[:unit].should == 'GB'
+#        (profile/'property[@name="storage"]').first[:kind].should == 'fixed'
+      end
+    end
+
+    def test_04_it_returns_single_hardware_profile
+      get_auth_url '/api;driver=fgcp/hardware_profiles/economy'
+      (last_xml_response/'hardware_profile/name').first.text.should == 'economy'
+      (last_xml_response/'hardware_profile/property[@name="architecture"]').first[:value].should == 'x86_64'
+      (last_xml_response/'hardware_profile/property[@name="memory"]').first[:value].should == '1740.8'
+      (last_xml_response/'hardware_profile/property[@name="cpu"]').first[:value].should == '1'
+#      (last_xml_response/'hardware_profile/property[@name="storage"]').first[:value].should == '0'
+    end
+
+    def test_05_it_filter_hardware_profiles
+      get_auth_url '/api;driver=fgcp/hardware_profiles?architecture=i386'
+      (last_xml_response/'hardware_profiles/hardware_profile').length.should == 0
+      get_auth_url '/api;driver=fgcp/hardware_profiles?architecture=x86_64'
+      (last_xml_response/'hardware_profiles/hardware_profile').length.should == 4
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7bc7e8a4/server/tests/drivers/fgcp/realms_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/fgcp/realms_test.rb b/server/tests/drivers/fgcp/realms_test.rb
new file mode 100644
index 0000000..bcb65d4
--- /dev/null
+++ b/server/tests/drivers/fgcp/realms_test.rb
@@ -0,0 +1,42 @@
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/common'
+
+module FGCPTest
+
+  class RealmsTest < Test::Unit::TestCase
+    include Rack::Test::Methods
+
+    def app
+      Sinatra::Application
+    end
+
+    def test_01_it_returns_realms
+      get_auth_url '/api;driver=fgcp/realms'
+      (last_xml_response/'realms/realm').length.should > 0
+    end
+
+    def test_02_each_realm_has_a_name
+      get_auth_url '/api;driver=fgcp/realms'
+      (last_xml_response/'realms/realm').each do |profile|
+        (profile/'name').text.should_not == nil
+        (profile/'name').text.should_not == ''
+#        (profile/'name').text.should == 'default'
+      end
+    end
+
+    def test_03_each_realm_is_available
+      get_auth_url '/api;driver=fgcp/realms'
+      (last_xml_response/'realms/realm').each do |profile|
+        (profile/'state').text.should == 'AVAILABLE'
+      end
+    end
+
+#    def test_03_it_returns_single_realm
+#      get_auth_url '/api;driver=fgcp/realms/us'
+#      (last_xml_response/'realm').first[:id].should == 'default'
+#      (last_xml_response/'realm/name').first.text.should == 'default'
+#      (last_xml_response/'realm/state').first.text.should == 'AVAILABLE'
+#    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7bc7e8a4/server/tests/drivers/fgcp/setup.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/fgcp/setup.rb b/server/tests/drivers/fgcp/setup.rb
new file mode 100644
index 0000000..eea1028
--- /dev/null
+++ b/server/tests/drivers/fgcp/setup.rb
@@ -0,0 +1,13 @@
+ENV.delete 'API_VERBOSE'
+ENV['API_DRIVER']   = "fgcp"
+ENV['API_USER']     = 'cert-dir'
+ENV['API_PASSWORD'] = 'secret'
+
+require 'vcr'
+DeltacloudTestCommon::record!
+
+VCR.config do |c|
+  c.cassette_library_dir = "#{File.dirname(__FILE__)}/../../../tests/drivers/fgcp/fixtures/"
+  c.stub_with :webmock
+  c.default_cassette_options = { :record => :new_episodes }
+end