test/integration/vm/VM_Create_test.rb in azure-0.6.1 vs test/integration/vm/VM_Create_test.rb in azure-0.6.2

- old
+ new

@@ -59,110 +59,111 @@ storage_account_name: storage_account_name, cloud_service_name: cloud_service_name } end - before do Loggerx.expects(:puts).returns(nil).at_least(0) - end describe '#deployment' do it 'should set options hash with valid cloud_service_name, deployment_name, storage_account_name and virtual network' do - cloud_name = options[:cloud_service_name] + csn = options[:cloud_service_name] options[:availability_set_name] = 'aval-set-test' - subject.create_virtual_machine(params, options, false) - virtual_machine = subject.get_virtual_machine(virtual_machine_name, cloud_name) - virtual_machine.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine - virtual_machine.cloud_service_name.wont_be_nil - virtual_machine.vm_name.must_equal virtual_machine_name - virtual_machine.deployment_name.wont_be_nil - virtual_machine.deployment_name.must_equal virtual_machine.cloud_service_name - virtual_machine.os_type.must_equal 'Linux' - virtual_machine.role_size.must_equal 'Small' - virtual_machine.availability_set_name.must_equal 'aval-set-test' + vm = subject.create_virtual_machine(params, options, false) + vm.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine + vm.cloud_service_name.wont_be_nil + vm.vm_name.must_equal virtual_machine_name + vm.deployment_name.wont_be_nil + vm.deployment_name.must_equal vm.cloud_service_name + vm.os_type.must_equal 'Linux' + vm.role_size.must_equal 'Small' + vm.availability_set_name.must_equal 'aval-set-test' options[:storage_account_name].wont_be_nil - assert_match(/^#{params[:vm_name] + '-service'}*/, cloud_name) + assert_match(/^#{params[:vm_name] + '-service'}*/, csn) # Test for add role params[:vm_name] = 'test-add-role-vm' options[:ssh_port] = 2222 vm = subject.create_virtual_machine(params, options, true) - vm.cloud_service_name.must_equal cloud_name + vm.cloud_service_name.must_equal csn vm.vm_name.must_equal params[:vm_name] - virtual_machine.deployment_name.wont_be_nil - virtual_machine.os_type.must_equal 'Linux' + vm.deployment_name.wont_be_nil + vm.os_type.must_equal 'Linux' end it 'should creates http and https enabled winrm virtual machine without certificate.' do default_options.merge!(winrm_transport: %w(https http)) - subject.create_virtual_machine(windows_params, default_options) - result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name) + result = subject.create_virtual_machine(windows_params, default_options) result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine - assert_equal(result.os_type, 'Windows', 'Error in the OS type of VI created') + assert_equal(result.os_type, 'Windows') tcp_endpoints_names = [] result.tcp_endpoints.each do |tcp_endpoint| - tcp_endpoints_names << tcp_endpoint['Name'] + tcp_endpoints_names << tcp_endpoint[:name] end - tcp_endpoints_names.must_include 'WinRm-Https' + tcp_endpoints_names.must_include 'PowerShell' tcp_endpoints_names.must_include 'WinRm-Http' sleep 30 end it 'should creates https enabled winrm virtual machine using certificate.' do - default_options.merge!(winrm_transport: ['https'], private_key_file: private_key, certificate_file: certificate) - subject.create_virtual_machine(windows_params, default_options) - result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name) + default_options.merge!( + winrm_transport: ['https'], + private_key_file: private_key, + certificate_file: certificate + ) + result = subject.create_virtual_machine(windows_params, default_options) result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine - assert_equal(result.os_type, 'Windows', 'Error in the OS type of VI created') + assert_equal(result.os_type, 'Windows') tcp_endpoints_names = [] result.tcp_endpoints.each do |tcp_endpoint| - tcp_endpoints_names << tcp_endpoint['Name'] + tcp_endpoints_names << tcp_endpoint[:name] end - tcp_endpoints_names.must_include 'WinRm-Https' + tcp_endpoints_names.must_include 'PowerShell' end it 'should creates windows virtual machine without winrm.' do default_options.merge!(winrm_transport: ['none']) - subject.create_virtual_machine(windows_params, default_options) - result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name) + result = subject.create_virtual_machine(windows_params, default_options) result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine - assert_equal(result.os_type, 'Windows', 'Error in the OS type of VI created') + assert_equal(result.os_type, 'Windows') tcp_endpoints_names = [] result.tcp_endpoints.each do |tcp_endpoint| tcp_endpoints_names << tcp_endpoint['Name'] end - assert (!tcp_endpoints_names.include? 'WinRm-Https') - assert (!tcp_endpoints_names.include? 'WinRm-Http') + assert !tcp_endpoints_names.include?('PowerShell') + assert !tcp_endpoints_names.include?('WinRm-Http') end it 'created linux virtual machine should be accessible using password and certificate' do - default_options.merge!(private_key_file: private_key, certificate_file: certificate) - subject.create_virtual_machine(params, default_options) - result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name) + default_options.merge!( + private_key_file: private_key, + certificate_file: certificate + ) + result = subject.create_virtual_machine(params, default_options) result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine - assert_equal(result.os_type, 'Linux', 'Error in the OS type of VI created') + assert_equal(result.os_type, 'Linux') sleep 30 end - it 'throws Runtime error as port value is beyond or less than actual range' do + it 'throws error as port value is beyond or less than actual range' do default_options.merge!(tcp_endpoints: '80,166535:166535') msg = subject.create_virtual_machine(params, default_options) - assert_match(/invalid. Allowed values are 'a number between 1 to 65535'./i, msg) + error_msg = "invalid. Allowed values are 'a number between 1 to 65535'." + assert_match(/#{error_msg}/i, msg) default_options.merge!(tcp_endpoints: '80,0:0') msg = subject.create_virtual_machine(params, default_options) - assert_match(/invalid. Allowed values are 'a number between 1 to 65535'./i, msg) - + assert_match(/#{error_msg}/i, msg) cloud_service.delete_cloud_service(cloud_service_name) end it 'throws error when multiple VMs created under same DNS' do subject.create_virtual_machine(params, default_options) msg = subject.create_virtual_machine(windows_params, default_options) - assert_match(/The specified deployment slot Production is occupied./i, msg) + error_msg = 'The specified deployment slot Production is occupied.' + assert_match(/#{error_msg}/i, msg) end it 'throws SystemExit error when vm_user not provided' do params.delete(:vm_user) msg = subject.create_virtual_machine(params) @@ -193,13 +194,14 @@ msg = subject.create_virtual_machine(params, default_options) assert_match(/The deployment name is invalid/i, msg) cloud_service.delete_cloud_service(cloud_service_name) end - it 'error thrown when invalid Virtual Machine name for Windows OS provided' do + it 'error thrown when invalid VM name given for Windows OS' do windows_params.merge!(vm_name: 'MSServerInstnce01') msg = subject.create_virtual_machine(windows_params, default_options) - assert_match(/The computer name cannot be more than 15 characters long, be entirely numeric, or contain the following characters/i, msg) + error_msg = 'The computer name cannot be more than 15 characters long' + assert_match(/#{error_msg}/i, msg) cloud_service.delete_cloud_service(cloud_service_name) end it 'error thrown when blank password for Windows OS provided' do windows_params.delete(:password)