deltacloud-core 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/bin/deltacloudd +11 -5
- data/config.ru +3 -3
- data/deltacloud-core.gemspec +24 -18
- data/lib/cimi/collections/address_templates.rb +3 -3
- data/lib/cimi/collections/addresses.rb +6 -5
- data/lib/cimi/collections/entity_metadata.rb +0 -2
- data/lib/cimi/collections/machine_admins.rb +5 -5
- data/lib/cimi/collections/machine_configurations.rb +2 -2
- data/lib/cimi/collections/machine_images.rb +3 -3
- data/lib/cimi/collections/machines.rb +32 -10
- data/lib/cimi/collections/network_configurations.rb +4 -3
- data/lib/cimi/collections/network_templates.rb +4 -3
- data/lib/cimi/collections/networks.rb +8 -8
- data/lib/cimi/collections/routing_group_templates.rb +4 -3
- data/lib/cimi/collections/routing_groups.rb +4 -3
- data/lib/cimi/collections/volume_configurations.rb +3 -3
- data/lib/cimi/collections/volume_images.rb +3 -3
- data/lib/cimi/collections/volumes.rb +4 -3
- data/lib/cimi/collections/vsp_configurations.rb +4 -3
- data/lib/cimi/collections/vsp_templates.rb +4 -3
- data/lib/cimi/collections/vsps.rb +8 -7
- data/lib/cimi/helpers.rb +1 -1
- data/lib/cimi/helpers/cimi_helper.rb +11 -1
- data/lib/cimi/models.rb +4 -0
- data/lib/cimi/models/base.rb +11 -1
- data/lib/cimi/models/cloud_entry_point.rb +7 -14
- data/lib/cimi/models/disk.rb +40 -0
- data/lib/cimi/models/disk_collection.rb +38 -0
- data/lib/cimi/models/machine.rb +9 -43
- data/lib/cimi/models/machine_collection.rb +7 -4
- data/lib/cimi/models/machine_configuration.rb +8 -15
- data/lib/cimi/models/machine_configuration_collection.rb +6 -4
- data/lib/cimi/models/machine_image_collection.rb +6 -4
- data/lib/cimi/models/machine_template_collection.rb +6 -4
- data/lib/cimi/models/machine_volume.rb +42 -0
- data/lib/cimi/models/machine_volume_collection.rb +34 -0
- data/lib/cimi/models/network.rb +5 -9
- data/lib/cimi/models/network_collection.rb +6 -5
- data/lib/cimi/models/schema.rb +20 -0
- data/lib/cimi/models/volume_collection.rb +6 -4
- data/lib/cimi/models/volume_configuration_collection.rb +6 -4
- data/lib/cimi/models/volume_image_collection.rb +6 -4
- data/lib/cimi/models/volume_template_collection.rb +6 -4
- data/lib/deltacloud/api.rb +3 -3
- data/lib/deltacloud/collections/addresses.rb +1 -1
- data/lib/deltacloud/collections/firewalls.rb +4 -2
- data/lib/deltacloud/collections/keys.rb +1 -1
- data/lib/deltacloud/collections/load_balancers.rb +1 -1
- data/lib/deltacloud/collections/storage_volumes.rb +4 -4
- data/lib/deltacloud/drivers/base_driver.rb +12 -20
- data/lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb +294 -0
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +38 -6
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +4 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +40 -4
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +8 -7
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +422 -416
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +30 -16
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +1 -0
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +3 -9
- data/lib/deltacloud/helpers/deltacloud_helper.rb +0 -2
- data/lib/deltacloud/models/firewall_rule.rb +2 -0
- data/lib/deltacloud/models/hardware_profile.rb +61 -59
- data/{tests/deprecated/core_ext/string.rb → lib/deltacloud/version.rb} +3 -15
- data/lib/deltacloud_rack.rb +1 -0
- data/lib/ec2/server.rb +5 -3
- data/lib/sinatra/rack_accept.rb +53 -53
- data/lib/sinatra/rack_etag.rb +1 -1
- data/tests/cimi/collections/cloud_entry_point_test.rb +11 -2
- data/tests/deltacloud/common.rb +1 -1
- data/tests/deltacloud/rack_test.rb +3 -3
- data/tests/drivers/base/base_driver_test.rb +6 -2
- data/tests/drivers/base/common.rb +1 -0
- data/tests/drivers/base/library_test.rb +6 -2
- data/tests/drivers/ec2/common.rb +34 -15
- data/tests/drivers/ec2/images_test.rb +2 -3
- data/tests/drivers/ec2/instance_test.rb +12 -2
- data/tests/drivers/ec2/keys_test.rb +2 -2
- data/tests/drivers/ec2/realms_test.rb +7 -3
- data/tests/drivers/ec2/storage_snapshots_test.rb +2 -3
- data/tests/drivers/gogrid/common.rb +24 -0
- data/tests/drivers/gogrid/hardware_profiles_test.rb +51 -0
- data/tests/drivers/gogrid/images_test.rb +57 -0
- data/tests/drivers/gogrid/instances_test.rb +92 -0
- data/tests/drivers/gogrid/realms_test.rb +45 -0
- data/tests/drivers/google/buckets_test.rb +105 -0
- data/tests/drivers/google/common.rb +20 -0
- data/tests/drivers/mock/common.rb +1 -0
- data/tests/drivers/mock/images_test.rb +3 -2
- data/tests/drivers/mock/instances_test.rb +3 -2
- data/tests/drivers/mock/keys_test.rb +3 -2
- data/tests/drivers/mock/realms_test.rb +3 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +3 -2
- data/tests/drivers/mock/storage_volumes_test.rb +3 -2
- data/tests/drivers/models/address_test.rb +3 -3
- data/tests/drivers/models/base_test.rb +4 -2
- data/tests/drivers/models/blob_test.rb +3 -3
- data/tests/drivers/models/common.rb +3 -0
- data/tests/drivers/models/hardware_profile_test.rb +5 -4
- data/tests/drivers/models/instance_address_test.rb +3 -3
- data/tests/drivers/models/instance_profile_test.rb +3 -3
- data/tests/drivers/models/instance_test.rb +3 -3
- data/tests/drivers/models/keys_test.rb +3 -3
- data/tests/drivers/models/metrics_test.rb +3 -3
- data/tests/drivers/openstack/common.rb +26 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +46 -0
- data/tests/drivers/openstack/images_test.rb +50 -0
- data/tests/drivers/openstack/instances_test.rb +66 -0
- data/tests/drivers/openstack/keys_test.rb +61 -0
- data/tests/drivers/openstack/realms_test.rb +46 -0
- data/tests/drivers/rhevm/common.rb +2 -0
- data/tests/drivers/rhevm/images_test.rb +3 -4
- data/tests/drivers/rhevm/instance_test.rb +2 -2
- data/tests/drivers/rhevm/provider_test.rb +2 -2
- data/tests/drivers/rhevm/realms_test.rb +2 -3
- data/tests/ec2/common.rb +5 -4
- data/tests/ec2/server_test.rb +3 -2
- data/tests/helpers/rack/common.rb +3 -0
- data/tests/helpers/rack/rack_accept_test.rb +65 -0
- data/tests/helpers/rack/rack_date_test.rb +27 -0
- data/tests/helpers/rack/rack_driver_select_test.rb +53 -0
- data/tests/helpers/rack/rack_etag_test.rb +29 -0
- data/tests/helpers/rack/rack_matrix_params_test.rb +72 -0
- data/tests/test_helper.rb +44 -36
- data/views/hardware_profiles/index.html.haml +1 -1
- data/views/hardware_profiles/show.html.haml +2 -2
- data/views/hardware_profiles/show.xml.haml +2 -1
- data/views/images/show.html.haml +6 -5
- metadata +74 -117
- data/tests/deprecated/api/common.rb +0 -1
- data/tests/deprecated/api/driver_test.rb +0 -79
- data/tests/deprecated/api/library_test.rb +0 -6
- data/tests/deprecated/cimi/features/step_definitions/common_steps.rb +0 -59
- data/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/deprecated/cimi/features/step_definitions/machines_steps.rb +0 -100
- data/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb +0 -115
- data/tests/deprecated/cimi/features/support/env.rb +0 -75
- data/tests/deprecated/common.rb +0 -279
- data/tests/deprecated/drivers/ec2/api_test.rb +0 -19
- data/tests/deprecated/drivers/ec2/common.rb +0 -23
- data/tests/deprecated/drivers/ec2/drivers_test.rb +0 -120
- data/tests/deprecated/drivers/ec2/hardware_profiles_test.rb +0 -224
- data/tests/deprecated/drivers/ec2/images_test.rb +0 -230
- data/tests/deprecated/drivers/ec2/instances_test.rb +0 -356
- data/tests/deprecated/drivers/ec2/keys_test.rb +0 -181
- data/tests/deprecated/drivers/ec2/realms_test.rb +0 -146
- data/tests/deprecated/drivers/fgcp/api_test.rb +0 -47
- data/tests/deprecated/drivers/fgcp/hardware_profiles_test.rb +0 -54
- data/tests/deprecated/drivers/fgcp/realms_test.rb +0 -42
- data/tests/deprecated/drivers/fgcp/setup.rb +0 -13
- data/tests/deprecated/drivers/google/api_test.rb +0 -19
- data/tests/deprecated/drivers/google/buckets_test.rb +0 -100
- data/tests/deprecated/drivers/google/common.rb +0 -54
- data/tests/deprecated/drivers/mock/api_test.rb +0 -10
- data/tests/deprecated/drivers/mock/buckets_test.rb +0 -195
- data/tests/deprecated/drivers/mock/common.rb +0 -7
- data/tests/deprecated/drivers/mock/drivers_test.rb +0 -123
- data/tests/deprecated/drivers/mock/hardware_profiles_test.rb +0 -224
- data/tests/deprecated/drivers/mock/images_test.rb +0 -197
- data/tests/deprecated/drivers/mock/instances_test.rb +0 -343
- data/tests/deprecated/drivers/mock/keys_test.rb +0 -161
- data/tests/deprecated/drivers/mock/realms_test.rb +0 -132
- data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +0 -114
- data/tests/deprecated/drivers/mock/storage_volumes_test.rb +0 -122
- data/tests/deprecated/drivers/openstack/api_test.rb +0 -46
- data/tests/deprecated/drivers/openstack/common.rb +0 -21
- data/tests/deprecated/drivers/openstack/hardware_profiles_test.rb +0 -64
- data/tests/deprecated/drivers/openstack/images_test.rb +0 -46
- data/tests/deprecated/drivers/openstack/instances_test.rb +0 -208
- data/tests/deprecated/drivers/openstack/realms_test.rb +0 -40
- data/tests/deprecated/drivers/rackspace/api_test.rb +0 -46
- data/tests/deprecated/drivers/rackspace/buckets_test.rb +0 -150
- data/tests/deprecated/drivers/rackspace/common.rb +0 -16
- data/tests/deprecated/drivers/rackspace/hardware_profiles_test.rb +0 -58
- data/tests/deprecated/drivers/rackspace/images_test.rb +0 -45
- data/tests/deprecated/drivers/rackspace/instances_test.rb +0 -166
- data/tests/deprecated/drivers/rackspace/realms_test.rb +0 -41
- data/tests/deprecated/drivers/rhevm/api_test.rb +0 -45
- data/tests/deprecated/drivers/rhevm/common.rb +0 -21
- data/tests/deprecated/drivers/rhevm/hardware_profiles_test.rb +0 -58
- data/tests/deprecated/drivers/rhevm/images_test.rb +0 -48
- data/tests/deprecated/drivers/rhevm/instances_test.rb +0 -182
- data/tests/deprecated/drivers/rhevm/realms_test.rb +0 -40
- data/tests/deprecated/minitest_common.rb +0 -58
- data/tests/deprecated/minitest_common_api_test.rb +0 -115
- data/tests/deprecated/rabbit_test.rb +0 -52
@@ -1,45 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/rhevm/common'
|
3
|
-
|
4
|
-
module RHEVMTest
|
5
|
-
|
6
|
-
class ApiTest < Test::Unit::TestCase
|
7
|
-
include Rack::Test::Methods
|
8
|
-
|
9
|
-
def app
|
10
|
-
Rack::Builder.new {
|
11
|
-
map '/' do
|
12
|
-
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
|
13
|
-
run Rack::Cascade.new([Deltacloud::API])
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_01_it_returns_entry_points
|
19
|
-
get_auth_url '/api;driver=rhevm'
|
20
|
-
(last_xml_response/'/api').first[:driver].should == 'rhevm'
|
21
|
-
(last_xml_response/'/api/link').length.should > 0
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_02_it_has_rhevm_features
|
25
|
-
get_url '/api;driver=rhevm'
|
26
|
-
features = (last_xml_response/'/api/link[@rel="instances"]/feature').collect { |f| f[:name] }
|
27
|
-
features.include?('user_name').should == true
|
28
|
-
features.include?('user_data').should == true
|
29
|
-
features.length.should == 2
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_03_it_has_rhevm_collections
|
33
|
-
get_url '/api;driver=rhevm'
|
34
|
-
collections = (last_xml_response/'/api/link').collect { |f| f[:rel] }
|
35
|
-
collections.include?('instance_states').should == true
|
36
|
-
collections.include?('instances').should == true
|
37
|
-
collections.include?('images').should == true
|
38
|
-
collections.include?('realms').should == true
|
39
|
-
collections.include?('hardware_profiles').should == true
|
40
|
-
collections.include?('storage_volumes').should == true
|
41
|
-
collections.length.should == 7
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
load File.join(File.dirname(__FILE__), '..', '..', 'common.rb')
|
2
|
-
|
3
|
-
ENV['API_USER'] = 'vdcadmin@rhev.lab.eng.brq.redhat.com'
|
4
|
-
ENV['API_PASSWORD'] = '123456'
|
5
|
-
ENV['API_PROVIDER'] = 'https://rhev30-dc.lab.eng.brq.redhat.com:8443/rhevm-api;645e425e-66fe-4ac9-8874-537bd10ef08d'
|
6
|
-
|
7
|
-
require 'vcr'
|
8
|
-
|
9
|
-
DeltacloudTestCommon::record!
|
10
|
-
|
11
|
-
VCR.config do |c|
|
12
|
-
c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
|
13
|
-
c.stub_with :webmock
|
14
|
-
c.default_cassette_options = { :record => :none }
|
15
|
-
end
|
16
|
-
|
17
|
-
class WebMock::Config
|
18
|
-
def net_http_connect_on_start
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/rhevm/common'
|
3
|
-
|
4
|
-
module RHEVMTest
|
5
|
-
|
6
|
-
class HardwareProfilesTest < Test::Unit::TestCase
|
7
|
-
include Rack::Test::Methods
|
8
|
-
|
9
|
-
def app
|
10
|
-
Rack::Builder.new {
|
11
|
-
map '/' do
|
12
|
-
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
|
13
|
-
run Rack::Cascade.new([Deltacloud::API])
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_01_it_returns_hardware_profiles
|
19
|
-
get_auth_url '/api;driver=rhevm/hardware_profiles'
|
20
|
-
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 2
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_02_each_hardware_profile_has_a_name
|
24
|
-
get_auth_url '/api;driver=rhevm/hardware_profiles'
|
25
|
-
(last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
|
26
|
-
(profile/'name').text.should_not == nil
|
27
|
-
(profile/'name').text.should_not == ''
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_03_each_hardware_profile_has_correct_properties
|
32
|
-
get_auth_url '/api;driver=rhevm/hardware_profiles'
|
33
|
-
(last_xml_response/'hardware_profiles/hardware_profile').each do |profile|
|
34
|
-
(profile/'property[@name="architecture"]').first[:value].should == 'x86_64'
|
35
|
-
(profile/'property[@name="memory"]').first[:unit].should == 'MB'
|
36
|
-
(profile/'property[@name="memory"]').first[:kind].should == 'range'
|
37
|
-
(profile/'property[@name="storage"]').first[:unit].should == 'GB'
|
38
|
-
(profile/'property[@name="storage"]').first[:kind].should == 'range'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_04_it_returns_single_hardware_profile
|
43
|
-
get_auth_url '/api;driver=rhevm/hardware_profiles/DESKTOP'
|
44
|
-
(last_xml_response/'hardware_profile/name').first.text.should == 'DESKTOP'
|
45
|
-
(last_xml_response/'hardware_profile/property[@name="architecture"]').first[:value].should == 'x86_64'
|
46
|
-
(last_xml_response/'hardware_profile/property[@name="memory"]').first[:value].should == '512'
|
47
|
-
(last_xml_response/'hardware_profile/property[@name="storage"]').first[:value].should == '1'
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_05_it_filter_hardware_profiles
|
51
|
-
get_auth_url '/api;driver=rhevm/hardware_profiles?architecture=i386'
|
52
|
-
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 0
|
53
|
-
get_auth_url '/api;driver=rhevm/hardware_profiles?architecture=x86_64'
|
54
|
-
(last_xml_response/'hardware_profiles/hardware_profile').length.should == 2
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/rhevm/common'
|
3
|
-
|
4
|
-
module RHEVMTest
|
5
|
-
|
6
|
-
class ImagesTest < Test::Unit::TestCase
|
7
|
-
include Rack::Test::Methods
|
8
|
-
|
9
|
-
def app
|
10
|
-
Rack::Builder.new {
|
11
|
-
map '/' do
|
12
|
-
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
|
13
|
-
run Rack::Cascade.new([Deltacloud::API])
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_01_it_returns_images
|
19
|
-
get_auth_url '/api;driver=rhevm/images'
|
20
|
-
puts last_response.body
|
21
|
-
(last_xml_response/'images/image').length.should > 0
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_02_each_image_has_correct_properties
|
25
|
-
get_auth_url '/api;driver=rhevm/images'
|
26
|
-
(last_xml_response/'images/image').each do |image|
|
27
|
-
(image/'name').should_not == nil
|
28
|
-
(image/'name').should_not == ''
|
29
|
-
(image/'description').should_not == nil
|
30
|
-
(image/'description').should_not == ''
|
31
|
-
(image/'architecture').should_not == nil
|
32
|
-
(image/'architecture').should_not == ''
|
33
|
-
(image/'state').text.should == 'OK'
|
34
|
-
(image/'owner_id').text.should == ENV['API_USER']
|
35
|
-
(image/'actions/link').length.should == 1
|
36
|
-
(image/'actions/link').first[:rel].should == 'create_instance'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_03_it_returns_single_image
|
41
|
-
get_auth_url '/api;driver=rhevm/images/3e82e2d5-913f-4095-ae72-ebcfa9d0571d'
|
42
|
-
(last_xml_response/'image').length.should == 1
|
43
|
-
(last_xml_response/'image/name').text.should == 'f15-minimal-2'
|
44
|
-
(last_xml_response/'image/state').text.should == 'OK'
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,182 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/rhevm/common'
|
3
|
-
|
4
|
-
module RHEVMTest
|
5
|
-
|
6
|
-
class InstancesTest < Test::Unit::TestCase
|
7
|
-
include Rack::Test::Methods
|
8
|
-
|
9
|
-
def app
|
10
|
-
Rack::Builder.new {
|
11
|
-
map '/' do
|
12
|
-
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
|
13
|
-
run Rack::Cascade.new([Deltacloud::API])
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_01_01_it_can_create_instance_without_hardware_profile
|
19
|
-
params = {
|
20
|
-
:image_id => '3e82e2d5-913f-4095-ae72-ebcfa9d0571d',
|
21
|
-
:name => 'dc-webmock-1',
|
22
|
-
:'api[driver]' => 'rhevm',
|
23
|
-
}
|
24
|
-
post_url '/api/instances', params
|
25
|
-
last_response.status.should == 201 # Created
|
26
|
-
@@instance = last_xml_response
|
27
|
-
(@@instance/'instance').length.should > 0
|
28
|
-
(@@instance/'instance/name').first.text.should_not == nil
|
29
|
-
(@@instance/'instance/name').first.text.should == 'dc-webmock-1'
|
30
|
-
(@@instance/'instance/owner_id').first.text.should_not == ''
|
31
|
-
(@@instance/'instance/owner_id').first.text.should == ENV['API_USER']
|
32
|
-
(@@instance/'instance/state').first.text.should == 'PENDING'
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_01_02_it_can_create_instance_with_hardware_profile
|
36
|
-
params = {
|
37
|
-
:image_id => '3e82e2d5-913f-4095-ae72-ebcfa9d0571d',
|
38
|
-
:name => 'dc-webmock-2',
|
39
|
-
:hwp_id => 'SERVER',
|
40
|
-
:'api[driver]' => 'rhevm',
|
41
|
-
}
|
42
|
-
post_url '/api/instances', params
|
43
|
-
last_response.status.should == 201 # Created
|
44
|
-
@@instance2 = last_xml_response
|
45
|
-
(@@instance2/'instance').length.should > 0
|
46
|
-
(@@instance2/'instance/name').first.text.should_not == nil
|
47
|
-
(@@instance2/'instance/name').first.text.should == 'dc-webmock-2'
|
48
|
-
(@@instance2/'instance/owner_id').first.text.should_not == ''
|
49
|
-
(@@instance2/'instance/owner_id').first.text.should == ENV['API_USER']
|
50
|
-
(@@instance2/'instance/state').first.text.should == 'PENDING'
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_03_02_created_instance_has_correct_hardware_profile
|
54
|
-
(@@instance2/'instance/hardware_profile').length.should == 1
|
55
|
-
(@@instance2/'instance/hardware_profile').first[:id].should == "SERVER"
|
56
|
-
(@@instance2/'instance/hardware_profile').first[:href].should_not == nil
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_03_01_instance_can_be_started
|
60
|
-
params = {
|
61
|
-
:'api[driver]' => 'rhevm'
|
62
|
-
}
|
63
|
-
20.times do |tick|
|
64
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance2/'instance').first[:id]}", { :tick => "START1-#{tick}"}
|
65
|
-
last_response.status.should_not == 500
|
66
|
-
state = (last_xml_response/'instance/state').first.text
|
67
|
-
break if state=='STOPPED'
|
68
|
-
sleep(5)
|
69
|
-
end
|
70
|
-
post_url "/api/instances/#{(@@instance/'instance').first[:id]}/start", params
|
71
|
-
last_response.status.should == 204
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_04_01_created_instance_goes_to_running_state
|
75
|
-
20.times do |tick|
|
76
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
77
|
-
last_response.status.should_not == 500
|
78
|
-
state = (last_xml_response/'instance/state').first.text
|
79
|
-
break if state=='RUNNING'
|
80
|
-
sleep(5)
|
81
|
-
end
|
82
|
-
@@instance = last_xml_response
|
83
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance/'instance').first[:id]}"
|
84
|
-
last_response.status.should_not == 500
|
85
|
-
(last_xml_response/'instance/state').first.text.should == 'RUNNING'
|
86
|
-
(last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_03_02_instance_can_be_started
|
90
|
-
params = {
|
91
|
-
:'api[driver]' => 'rhevm'
|
92
|
-
}
|
93
|
-
20.times do |tick|
|
94
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance2/'instance').first[:id]}", { :tick => "START2-#{tick}"}
|
95
|
-
last_response.status.should_not == 500
|
96
|
-
state = (last_xml_response/'instance/state').first.text
|
97
|
-
break if state=='STOPPED'
|
98
|
-
sleep(5)
|
99
|
-
end
|
100
|
-
post_url "/api/instances/#{(@@instance2/'instance').first[:id]}/start", params
|
101
|
-
last_response.status.should == 204
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_04_02_created_instance_goes_to_running_state
|
105
|
-
20.times do |tick|
|
106
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
107
|
-
last_response.status.should_not == 500
|
108
|
-
state = (last_xml_response/'instance/state').first.text
|
109
|
-
break if state=='RUNNING'
|
110
|
-
sleep(5)
|
111
|
-
end
|
112
|
-
@@instance2 = last_xml_response
|
113
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance2/'instance').first[:id]}"
|
114
|
-
last_response.status.should_not == 500
|
115
|
-
(last_xml_response/'instance/state').first.text.should == 'RUNNING'
|
116
|
-
(last_xml_response/'instance/actions/link[@rel="stop"]').first.should_not == nil
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_05_01_created_instance_can_be_stopped
|
120
|
-
params = {
|
121
|
-
:'api[driver]' => 'rhevm',
|
122
|
-
}
|
123
|
-
post_url "/api/instances/#{(@@instance/'instance').first[:id]}/stop", params
|
124
|
-
last_response.status.should == 204
|
125
|
-
20.times do |tick|
|
126
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
127
|
-
last_response.status.should_not == 500
|
128
|
-
state = (last_xml_response/'instance/state').first.text
|
129
|
-
break if state=='STOPPED'
|
130
|
-
sleep(5)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_05_02_created_instance_can_be_stopped
|
135
|
-
params = {
|
136
|
-
:'api[driver]' => 'rhevm',
|
137
|
-
}
|
138
|
-
post_url "/api/instances/#{(@@instance2/'instance').first[:id]}/stop", params
|
139
|
-
last_response.status.should == 204
|
140
|
-
20.times do |tick|
|
141
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
142
|
-
last_response.status.should_not == 500
|
143
|
-
state = (last_xml_response/'instance/state').first.text
|
144
|
-
break if state=='STOPPED'
|
145
|
-
sleep(5)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# FIXME:
|
150
|
-
# New RHEV-M version introduces a bug that when you're requesting an
|
151
|
-
# instance which was deleted or not exists instead of returning 404 as
|
152
|
-
# status code it returns 500
|
153
|
-
#
|
154
|
-
def test_06_01_created_instance_can_be_destroyed
|
155
|
-
params = {
|
156
|
-
:'api[driver]' => 'rhevm',
|
157
|
-
}
|
158
|
-
delete_url "/api/instances/#{(@@instance/'instance').first[:id]}", params
|
159
|
-
last_response.status.should == 204
|
160
|
-
20.times do |tick|
|
161
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance/'instance').first[:id]}", { :tick => tick}
|
162
|
-
break if last_response.status == 404
|
163
|
-
sleep(5)
|
164
|
-
end
|
165
|
-
last_response.status.should == 404
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_06_02_created_instance_can_be_destroyed
|
169
|
-
params = {
|
170
|
-
:'api[driver]' => 'rhevm',
|
171
|
-
}
|
172
|
-
delete_url "/api/instances/#{(@@instance2/'instance').first[:id]}", params, authenticate
|
173
|
-
last_response.status.should == 204
|
174
|
-
20.times do |tick|
|
175
|
-
get_auth_url "/api;driver=rhevm/instances/#{(@@instance2/'instance').first[:id]}", { :tick => tick}
|
176
|
-
break if last_response.status == 404
|
177
|
-
sleep(5)
|
178
|
-
end
|
179
|
-
last_response.status.should == 404
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/rhevm/common'
|
3
|
-
|
4
|
-
module RHEVMTest
|
5
|
-
|
6
|
-
class RealmsTest < Test::Unit::TestCase
|
7
|
-
include Rack::Test::Methods
|
8
|
-
|
9
|
-
def app
|
10
|
-
Rack::Builder.new {
|
11
|
-
map '/' do
|
12
|
-
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
|
13
|
-
run Rack::Cascade.new([Deltacloud::API])
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_01_it_returns_realms
|
19
|
-
get_auth_url '/api;driver=rhevm/realms'
|
20
|
-
(last_xml_response/'realms/realm').length.should == 1
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_02_each_realm_has_a_name
|
24
|
-
get_auth_url '/api;driver=rhevm/realms'
|
25
|
-
(last_xml_response/'realms/realm').each do |profile|
|
26
|
-
(profile/'name').text.should_not == nil
|
27
|
-
(profile/'name').text.should_not == ''
|
28
|
-
(profile/'name').text.should_not == 'Default'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_03_it_returns_single_realm
|
33
|
-
get_auth_url '/api;driver=rhevm/realms/3c8af388-cff6-11e0-9267-52540013f702'
|
34
|
-
(last_xml_response/'realm').first[:id].should == '3c8af388-cff6-11e0-9267-52540013f702'
|
35
|
-
(last_xml_response/'realm/name').first.text.should == 'engops-nfs'
|
36
|
-
(last_xml_response/'realm/state').first.text.should == 'AVAILABLE'
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
load File.join(File.dirname(__FILE__), '..', 'lib', 'deltacloud_rack.rb')
|
2
|
-
|
3
|
-
Deltacloud::configure do |server|
|
4
|
-
server.root_url '/api'
|
5
|
-
server.version '1.0.0'
|
6
|
-
server.klass 'Deltacloud::API'
|
7
|
-
end
|
8
|
-
|
9
|
-
Deltacloud.require_frontend!(:deltacloud)
|
10
|
-
|
11
|
-
require 'minitest/autorun'
|
12
|
-
require 'rack/test'
|
13
|
-
require 'nokogiri'
|
14
|
-
require 'json'
|
15
|
-
require 'pp'
|
16
|
-
|
17
|
-
module Deltacloud
|
18
|
-
module Test
|
19
|
-
include Rack::Test::Methods
|
20
|
-
|
21
|
-
def included?(sub)
|
22
|
-
sub.class_eval do
|
23
|
-
before do
|
24
|
-
header 'Accept', 'application/xml'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def xml_response
|
30
|
-
Nokogiri::XML(last_response.body)
|
31
|
-
end
|
32
|
-
|
33
|
-
def root_url
|
34
|
-
Deltacloud[:deltacloud].root_url
|
35
|
-
end
|
36
|
-
|
37
|
-
def api_version
|
38
|
-
Deltacloud[:deltacloud].version
|
39
|
-
end
|
40
|
-
|
41
|
-
def authenticate
|
42
|
-
authorize ENV['TESTS_API_USERNAME'], ENV['TESTS_API_PASSWORD']
|
43
|
-
end
|
44
|
-
|
45
|
-
def collection_url(collection)
|
46
|
-
[root_url, collection.to_s].join('/')
|
47
|
-
end
|
48
|
-
|
49
|
-
def app
|
50
|
-
Rack::Builder.new {
|
51
|
-
map '/' do
|
52
|
-
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
|
53
|
-
run Rack::Cascade.new([Deltacloud::API])
|
54
|
-
end
|
55
|
-
}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|