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,356 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/ec2/common'
|
3
|
-
|
4
|
-
describe 'Deltacloud API instances' do
|
5
|
-
include Deltacloud::Test
|
6
|
-
|
7
|
-
before do
|
8
|
-
Timecop.freeze(FREEZED_TIME)
|
9
|
-
VCR.insert_cassette __name__
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
VCR.eject_cassette
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'must advertise have the instances collection in API entrypoint' do
|
17
|
-
get root_url
|
18
|
-
(xml_response/'api/link[@rel=instances]').wont_be_empty
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
it 'must require authentication to access the "instance" collection' do
|
23
|
-
get collection_url(:instances)
|
24
|
-
last_response.status.must_equal 401
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should respond with HTTP_OK when accessing the :instances collection with authentication' do
|
28
|
-
authenticate
|
29
|
-
get collection_url(:instances)
|
30
|
-
last_response.status.must_equal 200
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should support the JSON media type' do
|
34
|
-
authenticate
|
35
|
-
header 'Accept', 'application/json'
|
36
|
-
get collection_url(:instances)
|
37
|
-
last_response.status.must_equal 200
|
38
|
-
last_response.headers['Content-Type'].must_equal 'application/json'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'must include the ETag in HTTP headers' do
|
42
|
-
authenticate
|
43
|
-
get collection_url(:instances)
|
44
|
-
last_response.headers['ETag'].wont_be_nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'must have the "instances" element on top level' do
|
48
|
-
authenticate
|
49
|
-
get collection_url(:instances)
|
50
|
-
xml_response.root.name.must_equal 'instances'
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'must have some "instance" elements inside "instances"' do
|
54
|
-
authenticate
|
55
|
-
get collection_url(:instances)
|
56
|
-
(xml_response/'instances/instance').wont_be_empty
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'must provide the :id attribute for each instance in collection' do
|
60
|
-
authenticate
|
61
|
-
get collection_url(:instances)
|
62
|
-
(xml_response/'instances/instance').each do |r|
|
63
|
-
r[:id].wont_be_nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'must include the :href attribute for each "instance" element in collection' do
|
68
|
-
authenticate
|
69
|
-
get collection_url(:instances)
|
70
|
-
(xml_response/'instances/instance').each do |r|
|
71
|
-
r[:href].wont_be_nil
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'must use the absolute URL in each :href attribute' do
|
76
|
-
authenticate
|
77
|
-
get collection_url(:instances)
|
78
|
-
(xml_response/'instances/instance').each do |r|
|
79
|
-
r[:href].must_match /^http/
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'must have the URL ending with the :id of the instance' do
|
84
|
-
authenticate
|
85
|
-
get collection_url(:instances)
|
86
|
-
(xml_response/'instances/instance').each do |r|
|
87
|
-
r[:href].must_match /#{r[:id]}$/
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'must return the list of valid parameters for the :index action' do
|
92
|
-
authenticate
|
93
|
-
options collection_url(:instances) + '/index'
|
94
|
-
last_response.headers['Allow'].wont_be_nil
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'must have the "name" element defined for each instance in collection' do
|
98
|
-
authenticate
|
99
|
-
get collection_url(:instances)
|
100
|
-
(xml_response/'instances/instance').each do |r|
|
101
|
-
(r/'name').wont_be_empty
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'must have the "state" element defined for each instance in collection' do
|
106
|
-
authenticate
|
107
|
-
get collection_url(:instances)
|
108
|
-
(xml_response/'instances/instance').each do |r|
|
109
|
-
(r/'state').wont_be_empty
|
110
|
-
(r/'state').first.must_match /(RUNNING|STOPPED|PENDING)/
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
it 'must return the full "instance" when following the URL in instance element' do
|
116
|
-
authenticate
|
117
|
-
get collection_url(:instances)
|
118
|
-
(xml_response/'instances/instance').each do |r|
|
119
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
120
|
-
get collection_url(:instances) + '/' + r[:id]
|
121
|
-
end
|
122
|
-
last_response.status.must_equal 200
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
it 'must have the "name" element for the instance and it should match with the one in collection' do
|
128
|
-
authenticate
|
129
|
-
get collection_url(:instances)
|
130
|
-
(xml_response/'instances/instance').each do |r|
|
131
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
132
|
-
get collection_url(:instances) + '/' + r[:id]
|
133
|
-
end
|
134
|
-
(xml_response/'name').wont_be_empty
|
135
|
-
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'must have the "name" element for the instance and it should match with the one in collection' do
|
140
|
-
authenticate
|
141
|
-
get collection_url(:instances)
|
142
|
-
(xml_response/'instances/instance').each do |r|
|
143
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
144
|
-
get collection_url(:instances) + '/' + r[:id]
|
145
|
-
end
|
146
|
-
(xml_response/'state').wont_be_empty
|
147
|
-
(xml_response/'state').first.text.must_equal((r/'state').first.text)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'must have the "owner_id" element for the instance and it should match with the one in collection' do
|
152
|
-
authenticate
|
153
|
-
get collection_url(:instances)
|
154
|
-
(xml_response/'instances/instance').each do |r|
|
155
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
156
|
-
get collection_url(:instances) + '/' + r[:id]
|
157
|
-
end
|
158
|
-
(xml_response/'owner_id').wont_be_empty
|
159
|
-
(xml_response/'owner_id').first.text.must_equal((r/'owner_id').first.text)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'must link to the realm that was used to during instance creation' do
|
164
|
-
authenticate
|
165
|
-
get collection_url(:instances)
|
166
|
-
(xml_response/'instances/instance').each do |r|
|
167
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
168
|
-
get collection_url(:instances) + '/' + r[:id]
|
169
|
-
end
|
170
|
-
(xml_response/'realm').wont_be_empty
|
171
|
-
(xml_response/'realm').size.must_equal 1
|
172
|
-
(xml_response/'realm').first[:id].wont_be_nil
|
173
|
-
(xml_response/'realm').first[:href].wont_be_nil
|
174
|
-
(xml_response/'realm').first[:href].must_match /\/#{(xml_response/'realm').first[:id]}$/
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'must link to the image that was used to during instance creation' do
|
179
|
-
authenticate
|
180
|
-
get collection_url(:instances)
|
181
|
-
(xml_response/'instances/instance').each do |r|
|
182
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
183
|
-
get collection_url(:instances) + '/' + r[:id]
|
184
|
-
end
|
185
|
-
(xml_response/'image').wont_be_empty
|
186
|
-
(xml_response/'image').size.must_equal 1
|
187
|
-
(xml_response/'image').first[:id].wont_be_nil
|
188
|
-
(xml_response/'image').first[:href].wont_be_nil
|
189
|
-
(xml_response/'image').first[:href].must_match /\/#{(xml_response/'image').first[:id]}$/
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
it 'must link to the hardware_profile that was used to during instance creation' do
|
194
|
-
authenticate
|
195
|
-
get collection_url(:instances)
|
196
|
-
(xml_response/'instances/instance').each do |r|
|
197
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
198
|
-
get collection_url(:instances) + '/' + r[:id]
|
199
|
-
end
|
200
|
-
(xml_response/'hardware_profile').wont_be_empty
|
201
|
-
(xml_response/'hardware_profile').size.must_equal 1
|
202
|
-
(xml_response/'hardware_profile').first[:id].wont_be_nil
|
203
|
-
(xml_response/'hardware_profile').first[:href].wont_be_nil
|
204
|
-
(xml_response/'hardware_profile').first[:href].must_match /\/#{(xml_response/'hardware_profile').first[:id]}$/
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'should advertise the public and private addresses of the instance' do
|
209
|
-
authenticate
|
210
|
-
get collection_url(:instances)
|
211
|
-
(xml_response/'instances/instance[@state=RUNNING]').each do |r|
|
212
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
213
|
-
get collection_url(:instances) + '/' + r[:id]
|
214
|
-
end
|
215
|
-
puts xml_response
|
216
|
-
(xml_response/'public_addresses').wont_be_empty
|
217
|
-
(xml_response/'public_addresses').size.must_equal 1
|
218
|
-
(xml_response/'public_addresses/address').each do |a|
|
219
|
-
a[:type].wont_be_nil
|
220
|
-
a.text.strip.wont_be_empty
|
221
|
-
end
|
222
|
-
(xml_response/'private_addresses').wont_be_empty
|
223
|
-
(xml_response/'private_addresses').size.must_equal 1
|
224
|
-
(xml_response/'private_addresses/address').each do |a|
|
225
|
-
a[:type].wont_be_nil
|
226
|
-
a.text.strip.wont_be_empty
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should advertise the storage volumes used by the instance' do
|
232
|
-
authenticate
|
233
|
-
get collection_url(:instances)
|
234
|
-
(xml_response/'instances/instance').each do |r|
|
235
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
236
|
-
get collection_url(:instances) + '/' + r[:id]
|
237
|
-
end
|
238
|
-
(xml_response/'storage_volumes').wont_be_empty
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'should advertise the list of actions that can be executed for each instance' do
|
243
|
-
authenticate
|
244
|
-
get collection_url(:instances)
|
245
|
-
(xml_response/'instances/instance').each do |r|
|
246
|
-
VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do
|
247
|
-
get collection_url(:instances) + '/' + r[:id]
|
248
|
-
end
|
249
|
-
(xml_response/'actions/link').wont_be_empty
|
250
|
-
(xml_response/'actions/link').each do |l|
|
251
|
-
l[:href].wont_be_nil
|
252
|
-
l[:href].must_match /^http/
|
253
|
-
l[:method].wont_be_nil
|
254
|
-
l[:rel].wont_be_nil
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
it 'should allow to create and destroy new instance using the image without realm' do
|
260
|
-
authenticate
|
261
|
-
image_id = 'ami-e565ba8c'
|
262
|
-
VCR.use_cassette "#{__name__}_create_instance" do
|
263
|
-
post collection_url(:instances), { :image_id => image_id }
|
264
|
-
end
|
265
|
-
last_response.status.must_equal 201 # HTTP_CREATED
|
266
|
-
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
267
|
-
instance_id = last_response.headers['Location'].split('/').last
|
268
|
-
# Get the instance and check if ID and image is set correctly
|
269
|
-
VCR.use_cassette "#{__name__}_get_instance" do
|
270
|
-
get collection_url(:instances) + '/' + instance_id
|
271
|
-
end
|
272
|
-
last_response.status.must_equal 200 # HTTP_OK
|
273
|
-
(xml_response/'instance').first[:id].must_equal instance_id
|
274
|
-
(xml_response/'instance/image').first[:id].must_equal image_id
|
275
|
-
10.times do |i|
|
276
|
-
VCR.use_cassette "#{__name__}_pool_#{i}_instance" do
|
277
|
-
get collection_url(:instances) + '/' + instance_id
|
278
|
-
end
|
279
|
-
break if (xml_response/'instance/state').text == 'RUNNING'
|
280
|
-
sleep(10)
|
281
|
-
end
|
282
|
-
(xml_response/'instance/state').text.must_equal 'RUNNING'
|
283
|
-
# Delete created instance
|
284
|
-
VCR.use_cassette "#{__name__}_delete_instance" do
|
285
|
-
post collection_url(:instances) + '/' + instance_id + '/stop'
|
286
|
-
end
|
287
|
-
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
288
|
-
end
|
289
|
-
|
290
|
-
it 'should allow to create and destroy new instance using the image within realm' do
|
291
|
-
authenticate
|
292
|
-
image_id = 'ami-e565ba8c'
|
293
|
-
realm_id = 'us-east-1c'
|
294
|
-
VCR.use_cassette "#{__name__}_create_instance" do
|
295
|
-
post collection_url(:instances), { :image_id => image_id, :realm_id => realm_id }
|
296
|
-
end
|
297
|
-
last_response.status.must_equal 201 # HTTP_CREATED
|
298
|
-
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
299
|
-
instance_id = last_response.headers['Location'].split('/').last
|
300
|
-
# Get the instance and check if ID and image is set correctly
|
301
|
-
VCR.use_cassette "#{__name__}_get_instance" do
|
302
|
-
get collection_url(:instances) + '/' + instance_id
|
303
|
-
end
|
304
|
-
last_response.status.must_equal 200 # HTTP_OK
|
305
|
-
(xml_response/'instance').first[:id].must_equal instance_id
|
306
|
-
(xml_response/'instance/image').first[:id].must_equal image_id
|
307
|
-
10.times do |i|
|
308
|
-
VCR.use_cassette "#{__name__}_pool_#{i}_instance" do
|
309
|
-
get collection_url(:instances) + '/' + instance_id
|
310
|
-
end
|
311
|
-
break if (xml_response/'instance/state').text == 'RUNNING'
|
312
|
-
sleep(10)
|
313
|
-
end
|
314
|
-
(xml_response/'instance/state').text.must_equal 'RUNNING'
|
315
|
-
(xml_response/'instance/realm').first[:id].must_equal realm_id
|
316
|
-
# Delete created instance
|
317
|
-
VCR.use_cassette "#{__name__}_delete_instance" do
|
318
|
-
post collection_url(:instances) + '/' + instance_id + '/stop'
|
319
|
-
end
|
320
|
-
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
321
|
-
end
|
322
|
-
|
323
|
-
it 'should allow to create and destroy new instance using the first available image and first hardware_profile' do
|
324
|
-
authenticate
|
325
|
-
image_id = 'ami-e565ba8c'
|
326
|
-
hwp_id = 'm1.small'
|
327
|
-
VCR.use_cassette "#{__name__}_create_instance" do
|
328
|
-
post collection_url(:instances), { :image_id => image_id, :hwp_id => hwp_id }
|
329
|
-
end
|
330
|
-
last_response.status.must_equal 201 # HTTP_CREATED
|
331
|
-
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
332
|
-
instance_id = last_response.headers['Location'].split('/').last
|
333
|
-
# Get the instance and check if ID and image is set correctly
|
334
|
-
VCR.use_cassette "#{__name__}_get_instance" do
|
335
|
-
get collection_url(:instances) + '/' + instance_id
|
336
|
-
end
|
337
|
-
last_response.status.must_equal 200 # HTTP_OK
|
338
|
-
(xml_response/'instance').first[:id].must_equal instance_id
|
339
|
-
(xml_response/'instance/image').first[:id].must_equal image_id
|
340
|
-
10.times do |i|
|
341
|
-
VCR.use_cassette "#{__name__}_pool_#{i}_instance" do
|
342
|
-
get collection_url(:instances) + '/' + instance_id
|
343
|
-
end
|
344
|
-
break if (xml_response/'instance/state').text == 'RUNNING'
|
345
|
-
sleep(10)
|
346
|
-
end
|
347
|
-
(xml_response/'instance/state').text.must_equal 'RUNNING'
|
348
|
-
(xml_response/'instance/hardware_profile').first[:id].must_equal hwp_id
|
349
|
-
# Delete created instance
|
350
|
-
VCR.use_cassette "#{__name__}_delete_instance" do
|
351
|
-
post collection_url(:instances) + '/' + instance_id + '/stop'
|
352
|
-
end
|
353
|
-
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
354
|
-
end
|
355
|
-
|
356
|
-
end
|
@@ -1,181 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/drivers/ec2/common'
|
3
|
-
|
4
|
-
describe 'Deltacloud API Keys' do
|
5
|
-
|
6
|
-
before do
|
7
|
-
Timecop.freeze(FREEZED_TIME)
|
8
|
-
VCR.insert_cassette __name__
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
VCR.eject_cassette
|
13
|
-
end
|
14
|
-
|
15
|
-
include Deltacloud::Test
|
16
|
-
|
17
|
-
it 'must advertise have the keys collection in API entrypoint' do
|
18
|
-
get root_url
|
19
|
-
(xml_response/'api/link[@rel=keys]').wont_be_empty
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'must require authentication to access the "key" collection' do
|
23
|
-
get collection_url(:keys)
|
24
|
-
last_response.status.must_equal 401
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should respond with HTTP_OK when accessing the :keys collection with authentication' do
|
28
|
-
authenticate
|
29
|
-
get collection_url(:keys)
|
30
|
-
last_response.status.must_equal 200
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should support the JSON media type' do
|
34
|
-
authenticate
|
35
|
-
header 'Accept', 'application/json'
|
36
|
-
get collection_url(:keys)
|
37
|
-
last_response.status.must_equal 200
|
38
|
-
last_response.headers['Content-Type'].must_equal 'application/json'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'must include the ETag in HTTP headers' do
|
42
|
-
authenticate
|
43
|
-
get collection_url(:keys)
|
44
|
-
last_response.headers['ETag'].wont_be_nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'must have the "keys" element on top level' do
|
48
|
-
authenticate
|
49
|
-
get collection_url(:keys)
|
50
|
-
xml_response.root.name.must_equal 'keys'
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'must have some "key" elements inside "keys"' do
|
54
|
-
authenticate
|
55
|
-
get collection_url(:keys)
|
56
|
-
(xml_response/'keys/key').wont_be_empty
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'must tell the kind of "key" elements inside "keys"' do
|
60
|
-
authenticate
|
61
|
-
get collection_url(:keys)
|
62
|
-
(xml_response/'keys/key').each do |k|
|
63
|
-
k[:type].must_match /(key|password)/
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'must provide the :id attribute for each key in collection' do
|
68
|
-
authenticate
|
69
|
-
get collection_url(:keys)
|
70
|
-
(xml_response/'keys/key').each do |r|
|
71
|
-
r[:id].wont_be_nil
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'must include the :href attribute for each "key" element in collection' do
|
76
|
-
authenticate
|
77
|
-
get collection_url(:keys)
|
78
|
-
(xml_response/'keys/key').each do |r|
|
79
|
-
r[:href].wont_be_nil
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'must use the absolute URL in each :href attribute' do
|
84
|
-
authenticate
|
85
|
-
get collection_url(:keys)
|
86
|
-
(xml_response/'keys/key').each do |r|
|
87
|
-
r[:href].must_match /^http/
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'must have the URL ending with the :id of the key' do
|
92
|
-
authenticate
|
93
|
-
get collection_url(:keys)
|
94
|
-
(xml_response/'keys/key').each do |r|
|
95
|
-
r[:href].must_match /#{r[:id]}$/
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'must return the list of valid parameters for the :index action' do
|
100
|
-
authenticate
|
101
|
-
options collection_url(:keys) + '/index'
|
102
|
-
last_response.headers['Allow'].wont_be_nil
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'must have the "name" element defined for each key in collection' do
|
106
|
-
authenticate
|
107
|
-
get collection_url(:keys)
|
108
|
-
(xml_response/'keys/key').each do |r|
|
109
|
-
(r/'name').wont_be_empty
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
it 'must return the full "key" when following the URL in key element' do
|
115
|
-
authenticate
|
116
|
-
get collection_url(:keys)
|
117
|
-
(xml_response/'keys/key').each do |r|
|
118
|
-
get collection_url(:keys) + '/' + r[:id]
|
119
|
-
last_response.status.must_equal 200
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'must have the "name" element for the key and it should match with the one in collection' do
|
124
|
-
authenticate
|
125
|
-
get collection_url(:keys)
|
126
|
-
(xml_response/'keys/key').each do |r|
|
127
|
-
VCR.use_cassette "#{__name__}_key_#{r[:id]}" do
|
128
|
-
get collection_url(:keys) + '/' + r[:id]
|
129
|
-
end
|
130
|
-
(xml_response/'name').wont_be_empty
|
131
|
-
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'must have the "name" element for the key and it should match with the one in collection' do
|
136
|
-
authenticate
|
137
|
-
get collection_url(:keys)
|
138
|
-
(xml_response/'keys/key').each do |r|
|
139
|
-
VCR.use_cassette "#{__name__}_key_#{r[:id]}" do
|
140
|
-
get collection_url(:keys) + '/' + r[:id]
|
141
|
-
end
|
142
|
-
(xml_response/'state').wont_be_empty
|
143
|
-
(xml_response/'state').first.text.must_equal((r/'state').first.text)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'should advertise the list of actions that can be executed for each key' do
|
148
|
-
authenticate
|
149
|
-
get collection_url(:keys)
|
150
|
-
(xml_response/'keys/key').each do |r|
|
151
|
-
VCR.use_cassette "#{__name__}_key_#{r[:id]}" do
|
152
|
-
get collection_url(:keys) + '/' + r[:id]
|
153
|
-
end
|
154
|
-
(xml_response/'actions/link').wont_be_empty
|
155
|
-
(xml_response/'actions/link').each do |l|
|
156
|
-
l[:href].wont_be_nil
|
157
|
-
l[:href].must_match /^http/
|
158
|
-
l[:method].wont_be_nil
|
159
|
-
l[:rel].wont_be_nil
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should allow to create a new key and then remove it' do
|
165
|
-
authenticate
|
166
|
-
key_name = Time.now.to_i.to_s
|
167
|
-
post collection_url(:keys), {
|
168
|
-
:name => 'test_key_'+key_name
|
169
|
-
}
|
170
|
-
last_response.status.must_equal 201 # HTTP_CREATED
|
171
|
-
VCR.use_cassette "#{__name__}_key_#{key_name}" do
|
172
|
-
get collection_url(:keys) + '/' + 'test_key_'+key_name
|
173
|
-
end
|
174
|
-
last_response.status.must_equal 200 # HTTP_OK
|
175
|
-
VCR.use_cassette "#{__name__}_delete_key_#{key_name}" do
|
176
|
-
delete collection_url(:keys) + '/' + 'test_key_'+key_name
|
177
|
-
end
|
178
|
-
last_response.status.must_equal 204 # HTTP_NO_CONTENT
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|