mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Added comments to tests
This commit is contained in:
parent
2632a2db42
commit
14a199abf0
1 changed files with 24 additions and 12 deletions
|
@ -38,11 +38,13 @@ Shindo.tests('Fog::Compute[:aws] | describe_instance_attribute request', ['aws']
|
||||||
|
|
||||||
tests('success') do
|
tests('success') do
|
||||||
|
|
||||||
@instance_id = nil
|
# In mocking the groupSet attribute is returned as nil
|
||||||
@ami = 'ami-79c0ae10'
|
|
||||||
if Fog.mocking?
|
if Fog.mocking?
|
||||||
@instance_attribute_format["groupSet"] = Fog::Nullable::Array
|
@instance_attribute_format["groupSet"] = Fog::Nullable::Array
|
||||||
end
|
end
|
||||||
|
# Setting up the environment
|
||||||
|
@instance_id = nil
|
||||||
|
@ami = 'ami-79c0ae10'
|
||||||
key_name = 'fog-test-key'
|
key_name = 'fog-test-key'
|
||||||
@key = Fog::Compute[:aws].key_pairs.create(:name => key_name)
|
@key = Fog::Compute[:aws].key_pairs.create(:name => key_name)
|
||||||
instance_type = "t1.micro"
|
instance_type = "t1.micro"
|
||||||
|
@ -65,6 +67,7 @@ Shindo.tests('Fog::Compute[:aws] | describe_instance_attribute request', ['aws']
|
||||||
@launch_config[:block_device_mapping] = block_device_mapping
|
@launch_config[:block_device_mapping] = block_device_mapping
|
||||||
else
|
else
|
||||||
security_group_ids = [nil]
|
security_group_ids = [nil]
|
||||||
|
# In mocking the first device provided in block_device_mapping is set as the root device. There is no root device by default. So setting the root device here so that the tests for rootDeviceName and blockDeviceMapping attribute get passed
|
||||||
block_device_mapping = [{"DeviceName" => "/dev/sda1", "VirtualName" => nil, "Ebs.VolumeSize" => 15},{"DeviceName" => "/dev/sdp1", "VirtualName" => nil, "Ebs.VolumeSize" => 15}]
|
block_device_mapping = [{"DeviceName" => "/dev/sda1", "VirtualName" => nil, "Ebs.VolumeSize" => 15},{"DeviceName" => "/dev/sdp1", "VirtualName" => nil, "Ebs.VolumeSize" => 15}]
|
||||||
@launch_config[:block_device_mapping] = block_device_mapping
|
@launch_config[:block_device_mapping] = block_device_mapping
|
||||||
end
|
end
|
||||||
|
@ -75,8 +78,11 @@ Shindo.tests('Fog::Compute[:aws] | describe_instance_attribute request', ['aws']
|
||||||
server.wait_for { ready? }
|
server.wait_for { ready? }
|
||||||
server.reload
|
server.reload
|
||||||
@instance_id = server.id
|
@instance_id = server.id
|
||||||
|
################
|
||||||
|
# BEGIN TESTS #
|
||||||
|
################
|
||||||
@instance_attributes.each do |attrib|
|
@instance_attributes.each do |attrib|
|
||||||
|
# Creating format schema for each attribute
|
||||||
describe_instance_attribute_format = @instance_attribute_common_format.clone
|
describe_instance_attribute_format = @instance_attribute_common_format.clone
|
||||||
if attrib == "kernel"
|
if attrib == "kernel"
|
||||||
key = "kernelId"
|
key = "kernelId"
|
||||||
|
@ -86,52 +92,58 @@ Shindo.tests('Fog::Compute[:aws] | describe_instance_attribute request', ['aws']
|
||||||
key = attrib
|
key = attrib
|
||||||
end
|
end
|
||||||
describe_instance_attribute_format[key] = @instance_attribute_format[key]
|
describe_instance_attribute_format[key] = @instance_attribute_format[key]
|
||||||
|
# Running format check
|
||||||
tests("#describe_instance_attribute('#{@instance_id}', #{attrib})").formats(describe_instance_attribute_format,false) do
|
tests("#describe_instance_attribute('#{@instance_id}', #{attrib})").formats(describe_instance_attribute_format,false) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, attrib).body
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, attrib).body
|
||||||
end
|
end
|
||||||
|
# Running test to see proper instance Id is get in each response
|
||||||
tests("#describe_instance_attribute('#{@instance_id}', #{attrib})").returns(@instance_id) do
|
tests("#describe_instance_attribute('#{@instance_id}', #{attrib})").returns(@instance_id) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, attrib).body['instanceId']
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, attrib).body['instanceId']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Test for instanceType attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'instanceType')").returns(instance_type) do
|
tests("#describe_instance_attribute(#{@instance_id}, 'instanceType')").returns(instance_type) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'instanceType').body["instanceType"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'instanceType').body["instanceType"]
|
||||||
end
|
end
|
||||||
|
# Test for disableApiTermination attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'disableApiTermination')").returns(false) do
|
tests("#describe_instance_attribute(#{@instance_id}, 'disableApiTermination')").returns(false) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'disableApiTermination').body["disableApiTermination"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'disableApiTermination').body["disableApiTermination"]
|
||||||
end
|
end
|
||||||
|
# Test for instanceInitiatedShutdownBehavior attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'instanceInitiatedShutdownBehavior')").returns('stop') do
|
tests("#describe_instance_attribute(#{@instance_id}, 'instanceInitiatedShutdownBehavior')").returns('stop') do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'instanceInitiatedShutdownBehavior').body["instanceInitiatedShutdownBehavior"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'instanceInitiatedShutdownBehavior').body["instanceInitiatedShutdownBehavior"]
|
||||||
end
|
end
|
||||||
|
# Test for rootDeviceName attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'rootDeviceName')").returns('/dev/sda1') do
|
tests("#describe_instance_attribute(#{@instance_id}, 'rootDeviceName')").returns('/dev/sda1') do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'rootDeviceName').body["rootDeviceName"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'rootDeviceName').body["rootDeviceName"]
|
||||||
end
|
end
|
||||||
|
# Test to see there are two devices for blockDeviceMapping attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'blockDeviceMapping')").returns(2) do
|
tests("#describe_instance_attribute(#{@instance_id}, 'blockDeviceMapping')").returns(2) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'blockDeviceMapping').body["blockDeviceMapping"].count
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'blockDeviceMapping').body["blockDeviceMapping"].count
|
||||||
end
|
end
|
||||||
|
# Test to check the device name /dev/sdp1 passed in block_device_mapping is returned correctly
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'blockDeviceMapping')").returns("/dev/sdp1") do
|
tests("#describe_instance_attribute(#{@instance_id}, 'blockDeviceMapping')").returns("/dev/sdp1") do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'blockDeviceMapping').body["blockDeviceMapping"].last["deviceName"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'blockDeviceMapping').body["blockDeviceMapping"].last["deviceName"]
|
||||||
end
|
end
|
||||||
|
# Test for groupSet attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'groupSet')").returns(security_group_ids) do
|
tests("#describe_instance_attribute(#{@instance_id}, 'groupSet')").returns(security_group_ids) do
|
||||||
group_set = Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'groupSet').body["groupSet"]
|
group_set = Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'groupSet').body["groupSet"]
|
||||||
group_set.collect { |g| g["groupId"]}
|
group_set.collect { |g| g["groupId"]}
|
||||||
end
|
end
|
||||||
|
# Test for sourceDestCheck attribute (This attribute is set only for VPC instances. So created the instance in a VPC during setup process)
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'sourceDestCheck')").returns(true) do
|
tests("#describe_instance_attribute(#{@instance_id}, 'sourceDestCheck')").returns(true) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'sourceDestCheck').body["sourceDestCheck"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'sourceDestCheck').body["sourceDestCheck"]
|
||||||
end
|
end
|
||||||
|
# Test for ebsOptimized attribute
|
||||||
tests("#describe_instance_attribute(#{@instance_id}, 'ebsOptimized')").returns(false) do
|
tests("#describe_instance_attribute(#{@instance_id}, 'ebsOptimized')").returns(false) do
|
||||||
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'ebsOptimized').body["ebsOptimized"]
|
Fog::Compute[:aws].describe_instance_attribute(@instance_id, 'ebsOptimized').body["ebsOptimized"]
|
||||||
end
|
end
|
||||||
|
###############
|
||||||
|
# END OF TEST #
|
||||||
|
###############
|
||||||
|
|
||||||
|
# Tear down
|
||||||
if !Fog.mocking?
|
if !Fog.mocking?
|
||||||
@key.destroy
|
@key.destroy
|
||||||
server.destroy
|
server.destroy
|
||||||
|
|
Loading…
Reference in a new issue