Skip to content

Commit

Permalink
Merge pull request #1325 from dprince/openstack_quota_test_fixes
Browse files Browse the repository at this point in the history
OpenStack: updates to quota tests.
  • Loading branch information
dprince committed Nov 30, 2012
2 parents 26b7de8 + f80b21a commit e4b382d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/fog/openstack/compute.rb
Expand Up @@ -191,13 +191,13 @@ def self.data
:addresses => {},
:quota => {
'metadata_items' => 128,
'key_pairs' => 10,
'injected_file_content_bytes' => 10240,
'injected_file_path_bytes' => 256,
'injected_files' => 5,
'gigabytes' => 1000,
'ram' => 51200,
'floating_ips' => 10,
'instances' => 10,
'volumes' => 10,
'cores' => 20,
}
}
Expand Down
19 changes: 16 additions & 3 deletions tests/openstack/requests/compute/quota_tests.rb
Expand Up @@ -2,21 +2,22 @@

@tenant_id = Fog::Compute[:openstack].list_tenants.body['tenants'].first['id']
@quota_set_format = {
'key_pairs' => Fixnum,
'metadata_items' => Fixnum,
'injected_file_content_bytes' => Fixnum,
'injected_file_path_bytes' => Fixnum,
'injected_files' => Fixnum,
'gigabytes' => Fixnum,
'ram' => Fixnum,
'floating_ips' => Fixnum,
'instances' => Fixnum,
'volumes' => Fixnum,
'cores' => Fixnum,
'security_groups' => Fog::Nullable::Integer,
'security_group_rules' => Fog::Nullable::Integer,
'id' => String
}

tests('success') do

tests('#get_quota_defaults').formats({ 'quota_set' => @quota_set_format }) do
Fog::Compute[:openstack].get_quota_defaults(@tenant_id).body
end
Expand All @@ -27,8 +28,9 @@
end

tests('#update_quota') do

new_values = @quota.merge({
'volumes' => @quota['volumes']/2,
'floating_ips' => @quota['floating_ips']/2,
'cores' => @quota['cores']/2
})

Expand All @@ -39,6 +41,17 @@
returns(new_values, 'returns new values') do
Fog::Compute[:openstack].get_quota(@tenant_id).body['quota_set']
end

# set quota back to old values
succeeds do
Fog::Compute[:openstack].update_quota(@tenant_id, @quota.clone)
end

# ensure old values are restored
returns(@quota, 'old values restored') do
Fog::Compute[:openstack].get_quota(@tenant_id).body['quota_set']
end

end

end
Expand Down

0 comments on commit e4b382d

Please sign in to comment.