test cases for azure cloud attributes loaded via ohai hints.

This commit is contained in:
kaustubh-d 2013-06-06 10:47:34 +05:30
Родитель 1653a58478
Коммит 134cc6f368
4 изменённых файлов: 172 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,116 @@
<?xml version="1.0"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>deployment004</Name>
<DeploymentSlot>Production</DeploymentSlot>
<PrivateID>2b1f2f0a4b414088a0ec64d583d9c4b3</PrivateID>
<Status>Running</Status>
<Label>WkdWd2JHOTViV1Z1ZERBd01RPT0=</Label>
<Url>http://service004.cloudapp-preview.net/</Url>
<Configuration>PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJyb2xlMDAyIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIxIiAvPg0KICA8L1JvbGU+DQogIDxSb2xlIG5hbWU9InJvbGUwMDEiPg0KICAgIDxJbnN0YW5jZXMgY291bnQ9IjEiIC8+DQogIDwvUm9sZT4NCjwvU2VydmljZUNvbmZpZ3VyYXRpb24+</Configuration>
<RoleInstanceList>
<RoleInstance>
<RoleName>ssh-vm</RoleName>
<InstanceName>ssh-vm</InstanceName>
<InstanceStatus>ReadyRole</InstanceStatus>
<InstanceUpgradeDomain>0</InstanceUpgradeDomain>
<InstanceFaultDomain>0</InstanceFaultDomain>
<InstanceSize>ExtraSmall</InstanceSize>
<InstanceStateDetails/>
<IpAddress>10.26.198.146</IpAddress>
<InstanceEndpoints>
<InstanceEndpoint>
<Name>tcpport66</Name>
<Vip>65.52.251.57</Vip>
<PublicPort>66</PublicPort>
<LocalPort>66</LocalPort>
<Protocol>tcp</Protocol>
</InstanceEndpoint>
<InstanceEndpoint>
<Name>SSH</Name>
<Vip>65.52.249.191</Vip>
<PublicPort>22</PublicPort>
<LocalPort>22</LocalPort>
<Protocol>tcp</Protocol>
</InstanceEndpoint>
</InstanceEndpoints>
<PowerState>Started</PowerState>
<HostName>ssh-vm</HostName>
</RoleInstance>
<RoleInstance>
<RoleName>winrm-vm</RoleName>
<InstanceName>winrm-vm</InstanceName>
<InstanceStatus>ReadyRole</InstanceStatus>
<InstanceUpgradeDomain>0</InstanceUpgradeDomain>
<InstanceFaultDomain>0</InstanceFaultDomain>
<InstanceSize>Small</InstanceSize>
<InstanceStateDetails/>
<IpAddress>10.26.196.254</IpAddress>
<InstanceEndpoints>
<InstanceEndpoint>
<Name>winrm</Name>
<Vip>65.52.249.191</Vip>
<PublicPort>5985</PublicPort>
<LocalPort>5985</LocalPort>
<Protocol>tcp</Protocol>
</InstanceEndpoint>
</InstanceEndpoints>
<PowerState>Started</PowerState>
<HostName>winrm-vm</HostName>
</RoleInstance>
</RoleInstanceList>
<UpgradeDomainCount>1</UpgradeDomainCount>
<RoleList>
<Role>
<RoleName>ssh-vm</RoleName>
<OsVersion>WA-GUEST-OS-1.18_201203-01</OsVersion>
<ConfigurationSets>
<ConfigurationSet i:type="NetworkConfigurationSet">
<ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
<InputEndpoints>
<InputEndpoint>
<Port>60657</Port>
<Protocol>tcp</Protocol>
<Vip>65.52.249.191</Vip>
</InputEndpoint>
</InputEndpoints>
<SubnetNames/>
</ConfigurationSet>
</ConfigurationSets>
</Role>
<Role i:type="PersistentVMRole">
<RoleName>winrm-vm</RoleName>
<OsVersion>WA-GUEST-OS-1.18_201203-01</OsVersion>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet i:type="NetworkConfigurationSet">
<ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
<InputEndpoints>
<InputEndpoint>
<LocalPort>5985</LocalPort>
<Name>winrm</Name>
<Port>5985</Port>
<Protocol>tcp</Protocol>
<Vip>65.52.249.191</Vip>
</InputEndpoint>
</InputEndpoints>
<SubnetNames/>
</ConfigurationSet>
</ConfigurationSets>
<DataVirtualHardDisks/>
<OSVirtualHardDisk>
<HostCaching>ReadWrite</HostCaching>
<DiskName>deployment004-winrm-vm-0-201241722113</DiskName>
<MediaLink>http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk001</MediaLink>
<SourceImageName>SUSE__OpenSUSE64121-03192012-en-us-15GB</SourceImageName>
<OS>Linux</OS>
</OSVirtualHardDisk>
<RoleSize>Small</RoleSize>
</Role>
</RoleList>
<SdkVersion>1.7</SdkVersion>
<Locked>false</Locked>
<RollbackAllowed>true</RollbackAllowed>
<CreatedTime>2012-04-17T22:01:10Z</CreatedTime>
<LastModifiedTime>2012-04-23T23:52:09Z</LastModifiedTime>
<ExtendedProperties/>
</Deployment>

Просмотреть файл

@ -1 +1 @@
<HostedServices xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service001</Url><ServiceName>service001</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMQ==</Label><Status>Created</Status><DateCreated>2012-04-17T21:56:23Z</DateCreated><DateLastModified>2012-04-17T22:01:08Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service002</Url><ServiceName>service002</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMg==</Label><Status>Created</Status><DateCreated>2012-04-17T22:27:08Z</DateCreated><DateLastModified>2012-04-23T21:42:47Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service003</Url><ServiceName>service003</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMw==</Label><Status>Created</Status><DateCreated>2012-04-19T20:17:26Z</DateCreated><DateLastModified>2012-04-19T20:17:25Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService></HostedServices>
<HostedServices xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service001</Url><ServiceName>service001</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMQ==</Label><Status>Created</Status><DateCreated>2012-04-17T21:56:23Z</DateCreated><DateLastModified>2012-04-17T22:01:08Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service002</Url><ServiceName>service002</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMg==</Label><Status>Created</Status><DateCreated>2012-04-17T22:27:08Z</DateCreated><DateLastModified>2012-04-23T21:42:47Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service003</Url><ServiceName>service003</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMw==</Label><Status>Created</Status><DateCreated>2012-04-19T20:17:26Z</DateCreated><DateLastModified>2012-04-19T20:17:25Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService><HostedService><Url>https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service004</Url><ServiceName>service004</ServiceName><HostedServiceProperties><Description>Explicitly created hosted service</Description><Location>Windows Azure Preview</Location><Label>c2VydmljZTAwMQ==</Label><Status>Created</Status><DateCreated>2012-04-17T21:56:23Z</DateCreated><DateLastModified>2012-04-17T22:01:08Z</DateLastModified><ExtendedProperties/></HostedServiceProperties></HostedService></HostedServices>

Просмотреть файл

@ -130,6 +130,56 @@ describe "parameter test:" do
end
end
describe "cloud attributes" do
context "WinRM protocol:" do
before do
@bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
Chef::Knife::BootstrapWindowsWinrm.stub(:new).and_return(@bootstrap)
@bootstrap.should_receive(:run)
@server_instance.should_receive(:is_image_windows?).any_number_of_times.and_return(true)
Chef::Config[:knife][:bootstrap_protocol] = 'winrm'
Chef::Config[:knife][:winrm_password] = 'winrm_password'
Chef::Config[:knife][:azure_dns_name] = 'service004'
Chef::Config[:knife][:azure_vm_name] = 'winrm-vm'
Chef::Config[:knife][:hints] = nil # reset as this is loaded only once for app(test here)
@server_instance.run
end
it "should set the cloud attributes in hints" do
cloud_attributes = Chef::Config[:knife][:hints]["azure"]
cloud_attributes["public_ip"].should == "65.52.249.191"
cloud_attributes["vm_name"].should == "winrm-vm"
cloud_attributes["public_fqdn"].should == "service004.cloudapp.net"
cloud_attributes["public_ssh_port"].should be_nil
cloud_attributes["public_winrm_port"].should == "5985"
end
end
context "SSH protocol:" do
before do
@bootstrap = Chef::Knife::Bootstrap.new
Chef::Knife::Bootstrap.stub(:new).and_return(@bootstrap)
@bootstrap.should_receive(:run)
@server_instance.should_receive(:is_image_windows?).any_number_of_times.and_return(false)
Chef::Config[:knife][:bootstrap_protocol] = 'ssh'
Chef::Config[:knife][:ssh_password] = 'ssh_password'
Chef::Config[:knife][:ssh_user] = 'ssh_user'
Chef::Config[:knife][:azure_dns_name] = 'service004'
Chef::Config[:knife][:azure_vm_name] = 'ssh-vm'
Chef::Config[:knife][:hints] = nil # reset as this is loaded only once for app(test here)
@server_instance.run
end
it "should set the cloud attributes in hints" do
cloud_attributes = Chef::Config[:knife][:hints]["azure"]
cloud_attributes["public_ip"].should == "65.52.251.57"
cloud_attributes["vm_name"].should == "ssh-vm"
cloud_attributes["public_fqdn"].should == "service004.cloudapp.net"
cloud_attributes["public_ssh_port"].should == "22"
cloud_attributes["public_winrm_port"].should be_nil
end
end
end
describe "for bootstrap protocol winrm:" do
before do
Chef::Config[:knife][:bootstrap_protocol] = 'winrm'

Просмотреть файл

@ -43,6 +43,8 @@ module QueryAzureMock
retval = Nokogiri::XML readFile('list_deployments_for_service002.xml')
elsif name == 'hostedservices/service003/deploymentslots/Production'
retval = Nokogiri::XML readFile('list_deployments_for_service003.xml')
elsif name == 'hostedservices/service004/deploymentslots/Production'
retval = Nokogiri::XML readFile('list_deployments_for_service004.xml')
elsif name == 'storageservices'
retval = Nokogiri::XML readFile('list_storageaccounts.xml')
else
@ -61,6 +63,9 @@ module QueryAzureMock
elsif name == 'hostedservices/service001/deployments/deployment001/roles'
retval = Nokogiri::XML readFile('post_success.xml')
@receivedXML = body
elsif name == 'hostedservices/service004/deployments/deployment004/roles'
retval = Nokogiri::XML readFile('post_success.xml')
@receivedXML = body
elsif name =~ /hostedservices\/vm01.*\/deployments/
retval = Nokogiri::XML readFile('post_success.xml')
@receivedXML = body