From 2548201ed6e4d0a82e1304654636d04d55dff3a5 Mon Sep 17 00:00:00 2001 From: Mukta A Date: Mon, 19 Aug 2013 13:05:26 +0530 Subject: [PATCH 01/22] Auto generation of chef_node_name is handled in knife-cloud now --- lib/chef/knife/openstack_server_create.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chef/knife/openstack_server_create.rb b/lib/chef/knife/openstack_server_create.rb index 805dd1f0..0e82925e 100644 --- a/lib/chef/knife/openstack_server_create.rb +++ b/lib/chef/knife/openstack_server_create.rb @@ -39,8 +39,8 @@ def before_exec_command # setup the create options @create_options = { :server_def => { - #servers require a name, generate one if not passed - :name => get_node_name(locate_config_value(:chef_node_name)), + #servers require a name, knife-cloud generates the chef_node_name + :name => config[:chef_node_name], :image_ref => locate_config_value(:image), :flavor_ref => locate_config_value(:flavor), :security_groups => locate_config_value(:openstack_security_groups), From e41dfe7bdd724346577a80b02ef9566ad1d2c672 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 21 Aug 2013 20:00:30 +0530 Subject: [PATCH 02/22] Removed openstack service stale rspec tests --- spec/unit/openstack_service_spec.rb | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 spec/unit/openstack_service_spec.rb diff --git a/spec/unit/openstack_service_spec.rb b/spec/unit/openstack_service_spec.rb deleted file mode 100644 index d7d42185..00000000 --- a/spec/unit/openstack_service_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' -require 'chef/knife/cloud/openstack_service' -require 'chef/knife/cloud/fog/service' -require 'support/shared_examples_for_fog_service' - -describe Chef::Knife::Cloud::OpenstackService do - it_behaves_like Chef::Knife::Cloud::FogService, Chef::Knife::Cloud::OpenstackService.new -end \ No newline at end of file From 08de6097bf5f270f9caef0b27f4760c613c93f52 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 21 Aug 2013 20:01:47 +0530 Subject: [PATCH 03/22] Removed set_image_os_type method --- lib/chef/knife/openstack_server_create.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/chef/knife/openstack_server_create.rb b/lib/chef/knife/openstack_server_create.rb index 938481c8..ffb852e8 100644 --- a/lib/chef/knife/openstack_server_create.rb +++ b/lib/chef/knife/openstack_server_create.rb @@ -36,10 +36,6 @@ class OpenstackServerCreate < ServerCreateCommand banner "knife openstack server create (options)" - def set_image_os_type - # Openstack does not provide a way to identify image os type, So image_os_type is taken from user. - end - def before_exec_command # setup the create options @create_options = { From 139ffa6761f61f881aa29749f72db4ce47eb5110 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Fri, 23 Aug 2013 14:29:53 +0530 Subject: [PATCH 04/22] Unmarked pending integration tests Conflicts: spec/integration/openstack_spec.rb --- spec/integration/openstack_spec.rb | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index f99e38fb..8981feb1 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -18,8 +18,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -=begin - def append_openstack_creds(is_list_cmd = false) openstack_creds_cmd = " --openstack-username #{@openstack_config['os_creds']['openstack_username']} --openstack-password #{@openstack_config['os_creds']['openstack_password']} --openstack-api-endpoint #{@openstack_config['os_creds']['openstack_auth_url']}" openstack_creds_cmd = openstack_creds_cmd + " -c #{temp_dir}/knife.rb" @@ -84,7 +82,6 @@ def rm_known_host context 'flavor list --help' do let(:command) { "knife openstack flavor list --help" } it 'should list all the options available for flavors list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -92,7 +89,6 @@ def rm_known_host context 'group list --help' do let(:command) { "knife openstack group list --help" } it 'should list all the options available for group list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -100,7 +96,6 @@ def rm_known_host context 'image list --help' do let(:command) { "knife openstack image list --help" } it 'should list all the options available for image list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -122,7 +117,6 @@ def rm_known_host context 'server list --help' do let(:command) { "knife openstack server list --help" } it 'should list all the options available for server list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -200,7 +194,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -331,14 +324,12 @@ def rm_known_host after(:each) { cmd_out = "#{cmd_stdout}" } it 'should successfully create the (windows VM) server with the provided options.' do - pending 'not yet implemented' match_status("should succeed") end context "delete server after create" do let(:command) { delete_instance_cmd(cmd_out) } it "should successfully delete the server." do - pending 'not yet implemented' match_status("should succeed") end end @@ -358,7 +349,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -379,7 +369,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -400,7 +389,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -420,7 +408,6 @@ def rm_known_host append_openstack_creds() + " --image-os-type windows" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'successfully create the (windows VM) server with the provided options and bootstrap.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -438,7 +425,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -459,7 +445,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -479,7 +464,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -499,7 +483,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -550,7 +533,6 @@ def rm_known_host context 'server list' do let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the servers.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -558,7 +540,6 @@ def rm_known_host context 'flavor list' do let(:command) { "knife openstack flavor list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the available flavors.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -566,7 +547,6 @@ def rm_known_host context 'image list' do let(:command) { "knife openstack image list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the available images.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -574,7 +554,6 @@ def rm_known_host context 'group list' do let(:command) { "knife openstack group list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the available security groups.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -587,5 +566,3 @@ def rm_known_host end end end - -=end From 799b010bf143c87c46e846f46ce240584cbbdafc Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 28 Aug 2013 10:53:51 +0530 Subject: [PATCH 05/22] Implemented changes to add chef data in server list --- lib/chef/knife/openstack_server_list.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/chef/knife/openstack_server_list.rb b/lib/chef/knife/openstack_server_list.rb index 831a2df2..10e28be2 100644 --- a/lib/chef/knife/openstack_server_list.rb +++ b/lib/chef/knife/openstack_server_list.rb @@ -21,6 +21,7 @@ require 'chef/knife/cloud/server/list_command' require 'chef/knife/openstack_helpers' require 'chef/knife/cloud/openstack_service_options' +require 'chef/knife/cloud/server/list_options' class Chef class Knife @@ -28,6 +29,7 @@ class Cloud class OpenstackServerList < ServerListCommand include OpenstackHelpers include OpenstackServiceOptions + include ServerListOptions banner "knife openstack server list (options)" @@ -43,6 +45,7 @@ def before_exec_command {:label => 'Keypair', :key => 'key_name'}, {:label => 'State', :key => 'state'} ] + super end def get_public_ip_address (addresses) From 21bfdccbf9ba609f9ad096eac5750361e0881458 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 28 Aug 2013 19:11:30 +0530 Subject: [PATCH 06/22] Updated integration tests --- spec/integration/openstack_spec.rb | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index 8981feb1..be2d0a25 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -36,7 +36,7 @@ def append_openstack_creds_for_windows def get_ssh_credentials " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ - " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}" + " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}" end def get_ssh_credentials_for_windows_image @@ -135,7 +135,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds + " --sudo"} + append_openstack_creds + " --sudo --image-os-type linux"} after(:each) { cmd_out = "#{cmd_stdout}" } it 'should successfully create the server with the provided options.' do match_status("should succeed") @@ -158,7 +158,7 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + get_ssh_credentials + - " --identity-file #{temp_dir}/openstack.pem" } + " --identity-file #{temp_dir}/openstack.pem --sudo --image-os-type linux" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -173,7 +173,7 @@ def rm_known_host " --template-file " + get_linux_template_file_path + " --server-url http://localhost:8889" + " --yes" + - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -191,7 +191,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --groups #{SecureRandom.hex(4)}"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -208,7 +208,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -225,7 +225,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -241,9 +241,9 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ - " --ssh-key #{SecureRandom.hex(6)}"+ + " --openstack-ssh-key-id #{SecureRandom.hex(6)}"+ " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -259,9 +259,9 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ - " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}"+ + " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}"+ " --identity-file #{temp_dir}/incorrect_openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw AuthenticationFailed Error message and stop execution.' do match_status("should fail") @@ -279,7 +279,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-private-network"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should bootstrap sucessfully with private ip address.' do pending "not yet done" @@ -298,7 +298,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-floating-ip"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should associate a floating IP address to the new OpenStack node.' do pending 'empty floating ip pool' @@ -318,7 +318,7 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + - " --yes --server-create-timeout 1800" + + " --yes --server-create-timeout 1800 --image-os-type windows" + get_winrm_credentials+ append_openstack_creds_for_windows() } after(:each) { cmd_out = "#{cmd_stdout}" } @@ -342,7 +342,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + " --yes" + get_winrm_credentials } @@ -360,7 +360,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + " --yes" + " --winrm-user #{SecureRandom.hex(6)}"+ @@ -380,7 +380,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + " --yes" + " --winrm-user #{@openstack_config['os_winrm_params']['winrm_user']}"+ @@ -403,7 +403,7 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes --server-create-timeout 1800" + " --identity-file #{temp_dir}/openstack.pem"+ - " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}"+ + " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}"+ get_ssh_credentials_for_windows_image+ append_openstack_creds() + " --image-os-type windows" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } @@ -419,7 +419,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['ssh_enabled_windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --identity-file #{temp_dir}/openstack.pem"+ append_openstack_creds() } @@ -436,7 +436,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -456,7 +456,7 @@ def rm_known_host " -I #{SecureRandom.hex(18)}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -475,7 +475,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['invalid_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -494,7 +494,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -515,7 +515,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ From 90dab0312396fe60a23a8d5d33e6e4fb4c61e91c Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Fri, 30 Aug 2013 17:28:48 +0530 Subject: [PATCH 07/22] Marked some integration tests as a pending --- spec/integration/openstack_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index be2d0a25..baa2b202 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -362,13 +362,14 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + - " --yes" + + " --yes --server-create-timeout 1800" + " --winrm-user #{SecureRandom.hex(6)}"+ " --winrm-password #{@openstack_config['os_winrm_params']['winrm_password']}" + append_openstack_creds_for_windows() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do + pending "Fails due to OC-9708 bug in knife-windows." match_status("should fail") end end @@ -382,13 +383,14 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + - " --yes" + + " --yes --server-create-timeout 1800" + " --winrm-user #{@openstack_config['os_winrm_params']['winrm_user']}"+ " --winrm-password #{SecureRandom.hex(6)}" + append_openstack_creds_for_windows() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do + pending "Fails due to OC-9708 bug in knife-windows." match_status("should fail") end end @@ -533,6 +535,7 @@ def rm_known_host context 'server list' do let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" match_status("should succeed") end end From 2da47ef7db8ef15e8c3dab1a122e3e0ae757eece Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Fri, 30 Aug 2013 19:29:24 +0530 Subject: [PATCH 08/22] Added rspec functional tests for chef-data and chef-node-attribute option --- spec/functional/server_list_func_spec.rb | 52 +++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/spec/functional/server_list_func_spec.rb b/spec/functional/server_list_func_spec.rb index c4eb047b..2d26f462 100644 --- a/spec/functional/server_list_func_spec.rb +++ b/spec/functional/server_list_func_spec.rb @@ -7,20 +7,62 @@ context "functionality" do before do - resources = [ TestResource.new({:id => "resource-1", :name => "ubuntu01", :addresses => {"public"=>[{"version"=>4, "addr"=>"172.31.6.132"}], "private"=>[{"version"=>4, "addr"=>"172.31.6.133"}]}, :flavor => {"id" => "1"}, :image => {"id" => "image1"}, :key_name => "keypair", :state => "ACTIVE"}), + @resources = [ TestResource.new({:id => "resource-1", :name => "ubuntu01", :addresses => {"public"=>[{"version"=>4, "addr"=>"172.31.6.132"}], "private"=>[{"version"=>4, "addr"=>"172.31.6.133"}]}, :flavor => {"id" => "1"}, :image => {"id" => "image1"}, :key_name => "keypair", :state => "ACTIVE"}), TestResource.new({:id => "resource-2", :name => "windows2008", :addresses => {"public"=>[{"version"=>4, "addr"=>"172.31.6.132"}]}, :flavor => {"id" => "id2"}, :image => {"id" => "image2"}, :key_name => "keypair", :state => "ACTIVE"}) ] - instance.stub(:query_resource).and_return(resources) + instance.stub(:query_resource).and_return(@resources) instance.stub(:puts) instance.stub(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new) instance.stub(:validate!) end it "lists formatted list of resources" do - instance.ui.should_receive(:list).with(["Instance ID", "Name", "Public IP", "Private IP", "Flavor", "Image", "Keypair", "State", - "resource-1", "ubuntu01", "172.31.6.132", "172.31.6.133", "1", "image1","keypair", "ACTIVE", - "resource-2", "windows2008", "172.31.6.132", nil, "id2", "image2", "keypair", "ACTIVE"], :uneven_columns_across, 8) + instance.ui.should_receive(:list).with(["Instance ID", "Name", "Public IP", "Private IP", "Flavor", "Image", "Keypair", "State", "resource-1", "ubuntu01", "172.31.6.132", "172.31.6.133", "1", "image1","keypair", "ACTIVE", "resource-2", "windows2008", "172.31.6.132", nil, "id2", "image2", "keypair", "ACTIVE"], :uneven_columns_across, 8) instance.run end + + context "when chef-data and chef-node-attribute set" do + before(:each) do + @resources.push(TestResource.new({:id => "server-4", :name => "server-4", :addresses => {"public"=>[{"version"=>4, "addr"=>"172.31.6.132"}], "private"=>[{"version"=>4, "addr"=>"172.31.6.133"}]}, :flavor => {"id" => "1"}, :image => {"id" => "image1"}, :key_name => "keypair", :state => "ACTIVE"})) + + @node = TestResource.new({:id => "server-4", :name => "server-4", :chef_environment => "_default", :fqdn => "testfqdnnode.us", :run_list => [], :tags => [], :platform => "ubuntu", :platform_family => "debian"}) + + Chef::Node.stub(:list).and_return({"server-4" => @node}) + instance.config[:chef_data] = true + end + + it "lists formatted list of resources on chef data option set" do + instance.ui.should_receive(:list).with(["Instance ID", "Name", "Public IP", "Private IP", "Flavor", "Image", "Keypair", "State", "Chef Node Name", "Environment", "FQDN", "Runlist", "Tags", "Platform", "resource-1", "ubuntu01", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "", "", "", "", "", "", "resource-2", "windows2008", "172.31.6.132", nil, "id2", "image2", "keypair", "ACTIVE", "", "", "", "", "", "", "server-4", "server-4", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "server-4", "_default", "testfqdnnode.us", "[]", "[]", "ubuntu"], :uneven_columns_across, 14) + + instance.run + end + + it "lists formatted list of resources on chef-data and chef-node-attribute option set" do + instance.config[:chef_node_attribute] = "platform_family" + @node.should_receive(:attribute?).with("platform_family").and_return(true) + + instance.ui.should_receive(:list).with(["Instance ID", "Name", "Public IP", "Private IP", "Flavor", "Image", "Keypair", "State", "Chef Node Name", "Environment", "FQDN", "Runlist", "Tags", "Platform", "platform_family", "resource-1", "ubuntu01", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "", "", "", "", "", "", "", "resource-2", "windows2008", "172.31.6.132", nil, "id2", "image2", "keypair", "ACTIVE", "", "", "", "", "", "", "", "server-4", "server-4", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "server-4", "_default", "testfqdnnode.us", "[]", "[]", "ubuntu", "debian"], :uneven_columns_across, 15) + + instance.run + end + + it "raise error on invalid chef-node-attribute set" do + instance.config[:chef_node_attribute] = "invalid_attribute" + @node.should_receive(:attribute?).with("invalid_attribute").and_return(false) + instance.ui.should_receive(:error).with("The Node does not have a invalid_attribute attribute.") + expect { instance.run }.to raise_error + end + + it "not display chef-data on chef-node-attribute set but chef-data option missing" do + instance.config[:chef_data] = false + instance.config[:chef_node_attribute] = "platform_family" + + instance.ui.should_not_receive(:list).with(["Instance ID", "Name", "Public IP", "Private IP", "Flavor", "Image", "Keypair", "State", "Chef Node Name", "Environment", "FQDN", "Runlist", "Tags", "Platform", "resource-1", "ubuntu01", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "", "", "", "", "", "", "resource-2", "windows2008", "172.31.6.132", nil, "id2", "image2", "keypair", "ACTIVE", "", "", "", "", "", "", "server-4", "server-4", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "server-4", "_default", "testfqdnnode.us", "[]", "[]", "ubuntu"], :uneven_columns_across, 14) + + instance.ui.should_receive(:list).with(["Instance ID", "Name", "Public IP", "Private IP", "Flavor", "Image", "Keypair", "State", "resource-1", "ubuntu01", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE", "resource-2", "windows2008", "172.31.6.132", nil, "id2", "image2", "keypair", "ACTIVE", "server-4", "server-4", "172.31.6.132", "172.31.6.133", "1", "image1", "keypair", "ACTIVE"], :uneven_columns_across, 8) + + instance.run + end + end end end \ No newline at end of file From ff53558c3acd068e0896388620d631f6d0de335c Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 21 Aug 2013 20:00:30 +0530 Subject: [PATCH 09/22] Removed openstack service stale rspec tests (cherry picked from commit e41dfe7bdd724346577a80b02ef9566ad1d2c672) --- spec/unit/openstack_service_spec.rb | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 spec/unit/openstack_service_spec.rb diff --git a/spec/unit/openstack_service_spec.rb b/spec/unit/openstack_service_spec.rb deleted file mode 100644 index d7d42185..00000000 --- a/spec/unit/openstack_service_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' -require 'chef/knife/cloud/openstack_service' -require 'chef/knife/cloud/fog/service' -require 'support/shared_examples_for_fog_service' - -describe Chef::Knife::Cloud::OpenstackService do - it_behaves_like Chef::Knife::Cloud::FogService, Chef::Knife::Cloud::OpenstackService.new -end \ No newline at end of file From 4c183c9ae45542e16bec2f707fa0184a5950a712 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Tue, 10 Sep 2013 12:49:29 +0530 Subject: [PATCH 10/22] Updated rspec tests for server create --- spec/unit/openstack_server_create_spec.rb | 224 ++++++++++++---------- 1 file changed, 122 insertions(+), 102 deletions(-) diff --git a/spec/unit/openstack_server_create_spec.rb b/spec/unit/openstack_server_create_spec.rb index 4a9b9b7b..5f72975f 100644 --- a/spec/unit/openstack_server_create_spec.rb +++ b/spec/unit/openstack_server_create_spec.rb @@ -1,5 +1,6 @@ # Author:: Prabhu Das () # Author:: Mukta Aphale () +# Author:: Siddheshwar More () # Copyright:: Copyright (c) 2013 Opscode, Inc. require File.expand_path('../../spec_helper', __FILE__) @@ -10,130 +11,149 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackServerCreate.new it_behaves_like Chef::Knife::Cloud::ServerCreateCommand, Chef::Knife::Cloud::OpenstackServerCreate.new - - let (:instance) {Chef::Knife::Cloud::OpenstackServerCreate.new} - - before(:each) do - instance.stub(:exit) - end - + describe "#create_service_instance" do it "return OpenstackService instance" do + instance = Chef::Knife::Cloud::OpenstackServerCreate.new expect(instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService) end end - describe "#validate!" do + describe "#validate_params!" do before(:each) do - Chef::Config[:knife][:openstack_username] = "testuser" - Chef::Config[:knife][:openstack_password] = "testpassword" - Chef::Config[:knife][:openstack_auth_url] = "tsturl" + @instance = Chef::Knife::Cloud::OpenstackServerCreate.new + @instance.ui.stub(:error) + Chef::Config[:knife][:bootstrap_protocol] = "ssh" + Chef::Config[:knife][:identity_file] = "identity_file" + Chef::Config[:knife][:image_os_type] = "linux" + Chef::Config[:knife][:openstack_ssh_key_id] = "openstack_ssh_key" end - it "validate openstack mandatory options" do - expect {instance.validate!}.to_not raise_error + after(:all) do + Chef::Config[:knife].delete(:bootstrap_protocol) + Chef::Config[:knife].delete(:identity_file) + Chef::Config[:knife].delete(:image_os_type) + Chef::Config[:knife].delete(:openstack_ssh_key_id) end - it "raise error on openstack_username missing and exit immediately." do - Chef::Config[:knife].delete(:openstack_username) - instance.ui.should_receive(:error).with("You did not provide a valid 'Openstack Username' value.") - expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) + it "run sucessfully on all params exist" do + expect { @instance.validate_params! }.to_not raise_error end - it "raise error on openstack_auth_url missing and exit immediately." do - Chef::Config[:knife].delete(:openstack_auth_url) - instance.ui.should_receive(:error).with("You did not provide a valid 'Openstack Auth Url' value.") - expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) + it "raise error if ssh key is missing" do + Chef::Config[:knife].delete(:openstack_ssh_key_id) + expect { @instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError, " You must provide SSH Key..") end - - it "validates ssh params" do - Chef::Config[:knife][:image_os_type] = "linux" - Chef::Config[:knife][:bootstrap_protocol] = "ssh" - instance.ui.should_receive(:error).with("You must provide either Identity file or SSH Password.") - expect { instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) + end + + describe "#before_exec_command" do + before(:each) do + @instance = Chef::Knife::Cloud::OpenstackServerCreate.new + @instance.ui.stub(:error) + @instance.config[:chef_node_name] = "chef_node_name" + Chef::Config[:knife][:image] = "image" + Chef::Config[:knife][:flavor] = "flavor" + Chef::Config[:knife][:openstack_security_groups] = "openstack_security_groups" + Chef::Config[:knife][:server_create_timeout] = "server_create_timeout" + Chef::Config[:knife][:openstack_ssh_key_id] = "openstack_ssh_key" end - it "raise_error on invalid image_os_type params" do - Chef::Config[:knife][:ssh_password] = "ssh_password" - Chef::Config[:knife][:openstack_ssh_key_id] = "ssh_key" - Chef::Config[:knife][:image_os_type] = "other_than_windows_linux" - instance.ui.should_receive(:error).with("You must provide --image-os-type option [windows/linux]") - expect { instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) + after(:all) do + Chef::Config[:knife].delete(:image) + Chef::Config[:knife].delete(:flavor) + Chef::Config[:knife].delete(:openstack_ssh_key_id) + Chef::Config[:knife].delete(:openstack_security_groups) + Chef::Config[:knife].delete(:server_create_timeout) end - it "raise_error on mising image_os_type params" do - Chef::Config[:knife][:image_os_type] = "other_than_windows_linux" - Chef::Config[:knife][:ssh_password] = "ssh_password" - Chef::Config[:knife][:openstack_ssh_key_id] = "ssh_key" - instance.ui.should_receive(:error).with("You must provide --image-os-type option [windows/linux]") - expect { instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) + it "set create_options" do + @instance.service = double + @instance.service.should_receive(:create_server_dependencies) + @instance.before_exec_command + @instance.create_options[:server_def][:name].should == @instance.config[:chef_node_name] + @instance.create_options[:server_def][:image_ref].should == Chef::Config[:knife][:image] + @instance.create_options[:server_def][:security_groups].should == Chef::Config[:knife][:openstack_security_groups] + @instance.create_options[:server_def][:flavor_ref].should == Chef::Config[:knife][:flavor] + @instance.create_options[:server_create_timeout].should == Chef::Config[:knife][:server_create_timeout] end + end - context "bootstrap protocol: Ssh " do - before(:each) do - Chef::Config[:knife][:bootstrap_protocol] = "ssh" - Chef::Config[:knife][:image_os_type] = 'linux' - end - - it "raise error when neither identity file nor SSH password is provided and exits immediately." do - Chef::Config[:knife][:identity_file] = nil - Chef::Config[:knife][:ssh_password] = nil - instance.ui.should_receive(:error).with("You must provide either Identity file or SSH Password.") - expect { instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) - end - - it "raise error when Identity file is provided but SSH key is not provided and exits immediately." do - Chef::Config[:knife][:identity_file] = "identity_file_path" - Chef::Config[:knife][:openstack_ssh_key_id] = nil - instance.ui.should_receive(:error).with("You must provide SSH Key.") - expect { instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) - end - - it "validates gracefully when SSH password is provided." do - Chef::Config[:knife][:identity_file] = nil - Chef::Config[:knife][:ssh_password] = "ssh_password" - instance.validate_params! - end - - it "validates gracefully when both Identity file and SSH key are provided." do - Chef::Config[:knife][:identity_file] = "identity_file_path" - Chef::Config[:knife][:openstack_ssh_key_id] = "ssh_key" - instance.validate! - end - - it "when no ssh User is provided , the default value should be 'root'." do - Chef::Config[:knife][:ssh_password] = "ssh_password" - instance.configure_chef - expect(instance.config[:ssh_user]).to eq('root') - instance.validate! - end + describe "#after_exec_command" do + before(:each) do + @instance = Chef::Knife::Cloud::OpenstackServerCreate.new + @instance.stub(:msg_pair) end - context "bootstrap protocol: Winrm " do - before(:each) do - instance.configure_chef - instance.config[:bootstrap_protocol] = 'winrm' - Chef::Config[:knife][:image_os_type] = 'windows' - end - - it "validates gracefully when winrm User and Winrm password are provided." do - instance.config[:winrm_user] = "winrm_user" - Chef::Config[:knife][:winrm_password] = "winrm_password" - instance.validate! - end - - it "when no winrm User is provided , the default value should be 'Administrator'." do - Chef::Config[:knife][:winrm_password] = "winrm_password" - expect(instance.config[:winrm_user]).to eq('Administrator') - instance.validate! - end - - it "raise error when winrm password is not provided and exits immediately." do - Chef::Config[:knife][:winrm_password] = nil - instance.config[:winrm_password] = nil - instance.ui.should_receive(:error).with("You must provide Winrm Password.") - expect { instance.validate_params! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError) - end + after(:all) do + Chef::Config[:knife].delete(:openstack_floating_ip) end + + it "don't set openstack_floating_ip on missing openstack_floating_ip option" do + #default openstack_floating_ip is '-1' + Chef::Config[:knife][:openstack_floating_ip] = "-1" + @instance.service = Chef::Knife::Cloud::Service.new + @instance.server = double + @instance.server.should_receive(:flavor).and_return({"id" => "2"}) + @instance.server.should_receive(:image).and_return({"id" => "image_id"}) + @instance.server.should_not_receive(:associate_address) + @instance.server.stub(:addresses).and_return({"public"=>[{"version"=>4, "addr"=>"127.0.1.1"}]}) + @instance.should_receive(:bootstrap) + @instance.after_exec_command + end + + it "set openstack_floating_ip on openstack_floating_ip option" do + Chef::Config[:knife][:openstack_floating_ip] = nil + @instance.service = Chef::Knife::Cloud::Service.new + @instance.server = double + @instance.server.should_receive(:flavor).and_return({"id" => "2"}) + @instance.server.should_receive(:image).and_return({"id" => "image_id"}) + @instance.server.stub(:addresses).and_return({"public"=>[{"version"=>4, "addr"=>"127.0.1.1"}]}) + @instance.should_receive(:bootstrap) + connection = double + @instance.service.stub(:connection).and_return(double) + free_floating = Object.new + free_floating.define_singleton_method(:fixed_ip) { return nil } + free_floating.define_singleton_method(:ip) { return "127.0.0.1" } + @instance.service.connection.should_receive(:addresses).and_return([free_floating]) + @instance.server.should_receive(:associate_address).with(free_floating.ip) + @instance.after_exec_command + end + + it "raise error on unavailability of free_floating ip" do + Chef::Config[:knife][:openstack_floating_ip] = nil + @instance.service = Chef::Knife::Cloud::Service.new + @instance.ui.stub(:fatal) + @instance.server = double + @instance.server.should_receive(:flavor).and_return({"id" => "2"}) + @instance.server.should_receive(:image).and_return({"id" => "image_id"}) + @instance.server.stub(:addresses).and_return({"public"=>[{"version"=>4, "addr"=>"127.0.1.1"}]}) + @instance.should_not_receive(:bootstrap) + connection = double + @instance.service.stub(:connection).and_return(double) + free_floating = Object.new + free_floating.define_singleton_method(:fixed_ip) { return "127.0.0.1" } + @instance.service.connection.should_receive(:addresses).and_return([free_floating]) + @instance.server.should_not_receive(:associate_address) + expect { @instance.after_exec_command }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ServerSetupError, "Unable to assign a Floating IP from allocated IPs.") + end + end + + describe "#before_bootstrap" do + before(:each) do + @instance = Chef::Knife::Cloud::OpenstackServerCreate.new + @instance.server = double + end + + it "set bootstrap_ip" do + @instance.server.stub(:addresses).and_return({"public"=>[{"version"=>4, "addr"=>"127.0.0.1"}]}) + @instance.before_bootstrap + @instance.config[:bootstrap_ip_address].should == "127.0.0.1" + end + + it "raise error on nil bootstrap_ip" do + @instance.ui.stub(:error) + @instance.server.stub(:addresses).and_return({"public"=>[{"version"=>4, "addr"=>nil}]}) + expect { @instance.before_bootstrap }.to raise_error(Chef::Knife::Cloud::CloudExceptions::BootstrapError, "No IP address available for bootstrapping.") + end end end From c9931879746706aa03c11440c0f2abd7c8463b75 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 11 Sep 2013 20:57:07 +0530 Subject: [PATCH 11/22] Added integration tests for chef-data, image-os-type, chef-node-name-prefix and delete-server-on-failure option --- spec/integration/openstack_spec.rb | 186 ++++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 1 deletion(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index baa2b202..f52b7078 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -149,6 +149,74 @@ def rm_known_host end end + context 'create server by using standard options and chef node name prefix default value(i.e openstack)' do + cmd_out = "" + let(:command) { "knife openstack server create "+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + get_ssh_credentials + + " --identity-file #{temp_dir}/openstack.pem"+ + append_openstack_creds + " --sudo"} + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server by using standard options and chef node name prefix user specified value' do + cmd_out = "" + let(:command) { "knife openstack server create "+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + " --chef-node-name-prefix test" + + get_ssh_credentials + + " --identity-file #{temp_dir}/openstack.pem"+ + append_openstack_creds + " --sudo"} + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server by using standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("linux") } + let(:command) { "knife openstack server create -N #{@name_node}"+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + " --delete-server-on-failure" + + get_ssh_credentials + + " --identity-file #{temp_dir}/openstack.pem"+ + append_openstack_creds + " --sudo"} + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server by using standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("linux") } + let(:command) { "knife openstack server create -N #{@name_node}"+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + " --delete-server-on-failure" + + get_ssh_credentials + + " --identity-file #{temp_dir}/incorrect_openstack.pem"+ + append_openstack_creds() + " --sudo" } + it 'should delete server on bootstrap failure' do + match_status("should fail") + end + end + context 'create server without openstack credentials' do cmd_out = "" before(:each) { create_node_name("linux") } @@ -335,6 +403,79 @@ def rm_known_host end end + context 'create server (for windows) with standard options and chef node name prefix default value(i.e openstack)' do + cmd_out = "" + let(:command) { "knife openstack server create " + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol winrm" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials+ + append_openstack_creds_for_windows() } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + + it 'should successfully create the (windows VM) server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server (for windows) with standard options and chef node name prefix user specified value' do + cmd_out = "" + let(:command) { "knife openstack server create " + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol winrm" + + " --chef-node-name-prefix test" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials+ + append_openstack_creds_for_windows() } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the (windows VM) server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server (for windows) with standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("windows") } + let(:command) { "knife openstack server create -N #{@name_node}" + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol winrm" + + " --delete-server-on-failure" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials+ + append_openstack_creds_for_windows() } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the (windows VM) server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server (for windows) with standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("windows") } + let(:command) { "knife openstack server create -N #{@name_node}" + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol invalid_bootstrap_protocol" + + " --delete-server-on-failure" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials + + append_openstack_creds_for_windows() } + it 'should delete created (windows VM) server on bootstrap failure.' do + match_status("should fail") + end + end + context 'create server (for windows) without openstack credentials' do cmd_out = "" before(:each) { create_node_name("windows") } @@ -395,7 +536,7 @@ def rm_known_host end end - context 'create server (for windows) using a ssh enabled windows image with ssh parameters' do + context 'create server (for windows) using a ssh enabled windows image with ssh parameters and valid image-os-type' do cmd_out = "" before(:each) { create_node_name("windows") } let(:command) { "knife openstack server create -N #{@name_node}"+ @@ -414,6 +555,25 @@ def rm_known_host end end + context 'create server (for windows) using a ssh enabled windows image with ssh parameters and invalid image-os-type' do + cmd_out = "" + before(:each) { create_node_name("windows") } + let(:command) { "knife openstack server create -N #{@name_node}"+ + " -I #{@openstack_config['os_params']['ssh_enabled_windows_image']}"+ + " -f #{@openstack_config['os_params']['windows_flavor']} "+ + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --yes --server-create-timeout 1800" + + " --identity-file #{temp_dir}/openstack.pem"+ + " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}"+ + get_ssh_credentials_for_windows_image+ + append_openstack_creds() + " --image-os-type invalid" } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'successfully create the (windows VM) server with the provided options and bootstrap.' do + match_status("should fail") + end + end + context 'create server (for windows) without ssh parameters' do cmd_out = "" before(:each) { create_node_name("windows") } @@ -539,6 +699,30 @@ def rm_known_host match_status("should succeed") end end + + context 'server list and chef-data' do + let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data" } + it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" + match_status("should succeed") + end + end + + context 'server list and chef-data option with valid chef-node-attribute' do + let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute platform_family" } + it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" + match_status("should succeed") + end + end + + context 'server list and chef-data option with invalid chef-node-attribute' do + let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute invalid" } + it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" + match_status("should fail") + end + end context 'flavor list' do let(:command) { "knife openstack flavor list" + append_openstack_creds(is_list_cmd = true) } From 7a2a5b3ce2666fa9018d64e87f097a4389e0d0be Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Mon, 16 Sep 2013 14:01:05 +0530 Subject: [PATCH 12/22] Updated Gemfile and integration tests --- Gemfile | 1 - spec/integration/openstack_spec.rb | 36 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index e8767e6c..ffa3f2a8 100644 --- a/Gemfile +++ b/Gemfile @@ -12,5 +12,4 @@ group :development do gem 'active_support' gem 'activesupport' gem 'knife-cloud', :git => 'https://github.com/opscode/knife-cloud.git' - gem 'knife-windows', :git => 'https://github.com/opscode/knife-windows.git', :branch => 'knife-cloud' end diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index f52b7078..4f7f1ebd 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -135,7 +135,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds + " --sudo --image-os-type linux"} + append_openstack_creds + " --sudo"} after(:each) { cmd_out = "#{cmd_stdout}" } it 'should successfully create the server with the provided options.' do match_status("should succeed") @@ -226,7 +226,7 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + get_ssh_credentials + - " --identity-file #{temp_dir}/openstack.pem --sudo --image-os-type linux" } + " --identity-file #{temp_dir}/openstack.pem --sudo" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -241,7 +241,7 @@ def rm_known_host " --template-file " + get_linux_template_file_path + " --server-url http://localhost:8889" + " --yes" + - append_openstack_creds() + " --sudo --image-os-type linux" } + append_openstack_creds() + " --sudo" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -259,7 +259,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --groups #{SecureRandom.hex(4)}"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -276,7 +276,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -293,7 +293,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -311,7 +311,7 @@ def rm_known_host " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ " --openstack-ssh-key-id #{SecureRandom.hex(6)}"+ " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -329,7 +329,7 @@ def rm_known_host " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}"+ " --identity-file #{temp_dir}/incorrect_openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw AuthenticationFailed Error message and stop execution.' do match_status("should fail") @@ -347,7 +347,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-private-network"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should bootstrap sucessfully with private ip address.' do pending "not yet done" @@ -366,7 +366,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-floating-ip"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should associate a floating IP address to the new OpenStack node.' do pending 'empty floating ip pool' @@ -386,7 +386,7 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + - " --yes --server-create-timeout 1800 --image-os-type windows" + + " --yes --server-create-timeout 1800" + get_winrm_credentials+ append_openstack_creds_for_windows() } after(:each) { cmd_out = "#{cmd_stdout}" } @@ -501,7 +501,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + " --yes --server-create-timeout 1800" + " --winrm-user #{SecureRandom.hex(6)}"+ @@ -522,7 +522,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + " --yes --server-create-timeout 1800" + " --winrm-user #{@openstack_config['os_winrm_params']['winrm_user']}"+ @@ -598,7 +598,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -618,7 +618,7 @@ def rm_known_host " -I #{SecureRandom.hex(18)}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -637,7 +637,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['invalid_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -656,7 +656,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889 " + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -677,7 +677,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ From 2b3046db7c5a686857c0c98fc1155f7cbbbbae5a Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Mon, 16 Sep 2013 18:58:15 +0530 Subject: [PATCH 13/22] Updated integration tests to remove known_host file --- spec/integration/openstack_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index 4f7f1ebd..b5a26c3b 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -50,7 +50,8 @@ def get_winrm_credentials end def rm_known_host - FileUtils.rm_rf("~/.ssh/known_hosts") + known_hosts = File.expand_path("~") + "/.ssh/known_hosts" + FileUtils.rm_rf(known_hosts) end describe 'knife-openstack' do @@ -124,7 +125,7 @@ def rm_known_host end describe 'Linux Platform Tests - knife' , :if => is_config_present do - after(:each) {rm_known_host} + before(:each) {rm_known_host} context 'create server with standard options' do cmd_out = "" before(:each) { create_node_name("linux") } @@ -376,7 +377,7 @@ def rm_known_host end describe 'Windows Platform Tests - knife' , :if => is_config_present do - after(:each) {rm_known_host} + before(:each) {rm_known_host} context 'create server (for windows) with standard options' do cmd_out = "" before(:each) { create_node_name("windows") } From a153f1c13cdeb8865ec35253f223dd9244b9785e Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Fri, 23 Aug 2013 14:29:53 +0530 Subject: [PATCH 14/22] Unmarked pending integration tests Conflicts: spec/integration/openstack_spec.rb --- spec/integration/openstack_spec.rb | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index f99e38fb..8981feb1 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -18,8 +18,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -=begin - def append_openstack_creds(is_list_cmd = false) openstack_creds_cmd = " --openstack-username #{@openstack_config['os_creds']['openstack_username']} --openstack-password #{@openstack_config['os_creds']['openstack_password']} --openstack-api-endpoint #{@openstack_config['os_creds']['openstack_auth_url']}" openstack_creds_cmd = openstack_creds_cmd + " -c #{temp_dir}/knife.rb" @@ -84,7 +82,6 @@ def rm_known_host context 'flavor list --help' do let(:command) { "knife openstack flavor list --help" } it 'should list all the options available for flavors list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -92,7 +89,6 @@ def rm_known_host context 'group list --help' do let(:command) { "knife openstack group list --help" } it 'should list all the options available for group list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -100,7 +96,6 @@ def rm_known_host context 'image list --help' do let(:command) { "knife openstack image list --help" } it 'should list all the options available for image list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -122,7 +117,6 @@ def rm_known_host context 'server list --help' do let(:command) { "knife openstack server list --help" } it 'should list all the options available for server list command.' do - pending 'not yet implemented' match_stdout(/--help/) end end @@ -200,7 +194,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -331,14 +324,12 @@ def rm_known_host after(:each) { cmd_out = "#{cmd_stdout}" } it 'should successfully create the (windows VM) server with the provided options.' do - pending 'not yet implemented' match_status("should succeed") end context "delete server after create" do let(:command) { delete_instance_cmd(cmd_out) } it "should successfully delete the server." do - pending 'not yet implemented' match_status("should succeed") end end @@ -358,7 +349,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -379,7 +369,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -400,7 +389,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -420,7 +408,6 @@ def rm_known_host append_openstack_creds() + " --image-os-type windows" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'successfully create the (windows VM) server with the provided options and bootstrap.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -438,7 +425,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -459,7 +445,6 @@ def rm_known_host after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -479,7 +464,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -499,7 +483,6 @@ def rm_known_host append_openstack_creds() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do - pending 'not yet implemented' match_status("should fail") end end @@ -550,7 +533,6 @@ def rm_known_host context 'server list' do let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the servers.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -558,7 +540,6 @@ def rm_known_host context 'flavor list' do let(:command) { "knife openstack flavor list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the available flavors.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -566,7 +547,6 @@ def rm_known_host context 'image list' do let(:command) { "knife openstack image list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the available images.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -574,7 +554,6 @@ def rm_known_host context 'group list' do let(:command) { "knife openstack group list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the available security groups.' do - pending 'not yet implemented' match_status("should succeed") end end @@ -587,5 +566,3 @@ def rm_known_host end end end - -=end From b703fdf18f315c53ef5b0872bd8d23e23c96078a Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 28 Aug 2013 19:11:30 +0530 Subject: [PATCH 15/22] Updated integration tests --- spec/integration/openstack_spec.rb | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index 8981feb1..be2d0a25 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -36,7 +36,7 @@ def append_openstack_creds_for_windows def get_ssh_credentials " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ - " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}" + " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}" end def get_ssh_credentials_for_windows_image @@ -135,7 +135,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds + " --sudo"} + append_openstack_creds + " --sudo --image-os-type linux"} after(:each) { cmd_out = "#{cmd_stdout}" } it 'should successfully create the server with the provided options.' do match_status("should succeed") @@ -158,7 +158,7 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + get_ssh_credentials + - " --identity-file #{temp_dir}/openstack.pem" } + " --identity-file #{temp_dir}/openstack.pem --sudo --image-os-type linux" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -173,7 +173,7 @@ def rm_known_host " --template-file " + get_linux_template_file_path + " --server-url http://localhost:8889" + " --yes" + - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -191,7 +191,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --groups #{SecureRandom.hex(4)}"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -208,7 +208,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -225,7 +225,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -241,9 +241,9 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ - " --ssh-key #{SecureRandom.hex(6)}"+ + " --openstack-ssh-key-id #{SecureRandom.hex(6)}"+ " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -259,9 +259,9 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ - " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}"+ + " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}"+ " --identity-file #{temp_dir}/incorrect_openstack.pem"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw AuthenticationFailed Error message and stop execution.' do match_status("should fail") @@ -279,7 +279,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-private-network"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should bootstrap sucessfully with private ip address.' do pending "not yet done" @@ -298,7 +298,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-floating-ip"+ - append_openstack_creds() } + append_openstack_creds() + " --sudo --image-os-type linux"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should associate a floating IP address to the new OpenStack node.' do pending 'empty floating ip pool' @@ -318,7 +318,7 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + - " --yes --server-create-timeout 1800" + + " --yes --server-create-timeout 1800 --image-os-type windows" + get_winrm_credentials+ append_openstack_creds_for_windows() } after(:each) { cmd_out = "#{cmd_stdout}" } @@ -342,7 +342,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + " --yes" + get_winrm_credentials } @@ -360,7 +360,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + " --yes" + " --winrm-user #{SecureRandom.hex(6)}"+ @@ -380,7 +380,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + " --yes" + " --winrm-user #{@openstack_config['os_winrm_params']['winrm_user']}"+ @@ -403,7 +403,7 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes --server-create-timeout 1800" + " --identity-file #{temp_dir}/openstack.pem"+ - " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}"+ + " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}"+ get_ssh_credentials_for_windows_image+ append_openstack_creds() + " --image-os-type windows" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } @@ -419,7 +419,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['ssh_enabled_windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --identity-file #{temp_dir}/openstack.pem"+ append_openstack_creds() } @@ -436,7 +436,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -456,7 +456,7 @@ def rm_known_host " -I #{SecureRandom.hex(18)}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -475,7 +475,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['invalid_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -494,7 +494,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -515,7 +515,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889" + + " --server-url http://localhost:8889 --image-os-type windows" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ From 9d3275ba9b9247232e3917d64c986e54f7132a28 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Fri, 30 Aug 2013 17:28:48 +0530 Subject: [PATCH 16/22] Marked some integration tests as a pending --- spec/integration/openstack_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index be2d0a25..baa2b202 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -362,13 +362,14 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + - " --yes" + + " --yes --server-create-timeout 1800" + " --winrm-user #{SecureRandom.hex(6)}"+ " --winrm-password #{@openstack_config['os_winrm_params']['winrm_password']}" + append_openstack_creds_for_windows() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do + pending "Fails due to OC-9708 bug in knife-windows." match_status("should fail") end end @@ -382,13 +383,14 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889 --image-os-type windows" + " --bootstrap-protocol winrm" + - " --yes" + + " --yes --server-create-timeout 1800" + " --winrm-user #{@openstack_config['os_winrm_params']['winrm_user']}"+ " --winrm-password #{SecureRandom.hex(6)}" + append_openstack_creds_for_windows() } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should fail to bootstrap and stop execution.' do + pending "Fails due to OC-9708 bug in knife-windows." match_status("should fail") end end @@ -533,6 +535,7 @@ def rm_known_host context 'server list' do let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" match_status("should succeed") end end From f23730901e8afb532109548c4f9ce708808e04da Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 11 Sep 2013 20:57:07 +0530 Subject: [PATCH 17/22] Added integration tests for chef-data, image-os-type, chef-node-name-prefix and delete-server-on-failure option --- spec/integration/openstack_spec.rb | 186 ++++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 1 deletion(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index baa2b202..f52b7078 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -149,6 +149,74 @@ def rm_known_host end end + context 'create server by using standard options and chef node name prefix default value(i.e openstack)' do + cmd_out = "" + let(:command) { "knife openstack server create "+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + get_ssh_credentials + + " --identity-file #{temp_dir}/openstack.pem"+ + append_openstack_creds + " --sudo"} + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server by using standard options and chef node name prefix user specified value' do + cmd_out = "" + let(:command) { "knife openstack server create "+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + " --chef-node-name-prefix test" + + get_ssh_credentials + + " --identity-file #{temp_dir}/openstack.pem"+ + append_openstack_creds + " --sudo"} + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server by using standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("linux") } + let(:command) { "knife openstack server create -N #{@name_node}"+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + " --delete-server-on-failure" + + get_ssh_credentials + + " --identity-file #{temp_dir}/openstack.pem"+ + append_openstack_creds + " --sudo"} + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server by using standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("linux") } + let(:command) { "knife openstack server create -N #{@name_node}"+ + " -I #{@openstack_config['os_params']['linux_image']} -f #{@openstack_config['os_params']['linux_flavor']} "+ + " --template-file " + get_linux_template_file_path + + " --server-url http://localhost:8889" + + " --yes" + + " --delete-server-on-failure" + + get_ssh_credentials + + " --identity-file #{temp_dir}/incorrect_openstack.pem"+ + append_openstack_creds() + " --sudo" } + it 'should delete server on bootstrap failure' do + match_status("should fail") + end + end + context 'create server without openstack credentials' do cmd_out = "" before(:each) { create_node_name("linux") } @@ -335,6 +403,79 @@ def rm_known_host end end + context 'create server (for windows) with standard options and chef node name prefix default value(i.e openstack)' do + cmd_out = "" + let(:command) { "knife openstack server create " + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol winrm" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials+ + append_openstack_creds_for_windows() } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + + it 'should successfully create the (windows VM) server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server (for windows) with standard options and chef node name prefix user specified value' do + cmd_out = "" + let(:command) { "knife openstack server create " + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol winrm" + + " --chef-node-name-prefix test" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials+ + append_openstack_creds_for_windows() } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the (windows VM) server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server (for windows) with standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("windows") } + let(:command) { "knife openstack server create -N #{@name_node}" + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol winrm" + + " --delete-server-on-failure" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials+ + append_openstack_creds_for_windows() } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'should successfully create the (windows VM) server with the provided options.' do + match_status("should succeed") + end + end + + context 'create server (for windows) with standard options and delete-server-on-failure' do + cmd_out = "" + before(:each) { create_node_name("windows") } + let(:command) { "knife openstack server create -N #{@name_node}" + + " -I #{@openstack_config['os_params']['windows_image']} " + + " -f #{@openstack_config['os_params']['windows_flavor']} " + + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --bootstrap-protocol invalid_bootstrap_protocol" + + " --delete-server-on-failure" + + " --yes --server-create-timeout 1800" + + get_winrm_credentials + + append_openstack_creds_for_windows() } + it 'should delete created (windows VM) server on bootstrap failure.' do + match_status("should fail") + end + end + context 'create server (for windows) without openstack credentials' do cmd_out = "" before(:each) { create_node_name("windows") } @@ -395,7 +536,7 @@ def rm_known_host end end - context 'create server (for windows) using a ssh enabled windows image with ssh parameters' do + context 'create server (for windows) using a ssh enabled windows image with ssh parameters and valid image-os-type' do cmd_out = "" before(:each) { create_node_name("windows") } let(:command) { "knife openstack server create -N #{@name_node}"+ @@ -414,6 +555,25 @@ def rm_known_host end end + context 'create server (for windows) using a ssh enabled windows image with ssh parameters and invalid image-os-type' do + cmd_out = "" + before(:each) { create_node_name("windows") } + let(:command) { "knife openstack server create -N #{@name_node}"+ + " -I #{@openstack_config['os_params']['ssh_enabled_windows_image']}"+ + " -f #{@openstack_config['os_params']['windows_flavor']} "+ + " --template-file " + get_windows_msi_template_file_path + + " --server-url http://localhost:8889" + + " --yes --server-create-timeout 1800" + + " --identity-file #{temp_dir}/openstack.pem"+ + " --ssh-key #{@openstack_config['os_ssh_params']['key_pair']}"+ + get_ssh_credentials_for_windows_image+ + append_openstack_creds() + " --image-os-type invalid" } + after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } + it 'successfully create the (windows VM) server with the provided options and bootstrap.' do + match_status("should fail") + end + end + context 'create server (for windows) without ssh parameters' do cmd_out = "" before(:each) { create_node_name("windows") } @@ -539,6 +699,30 @@ def rm_known_host match_status("should succeed") end end + + context 'server list and chef-data' do + let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data" } + it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" + match_status("should succeed") + end + end + + context 'server list and chef-data option with valid chef-node-attribute' do + let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute platform_family" } + it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" + match_status("should succeed") + end + end + + context 'server list and chef-data option with invalid chef-node-attribute' do + let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute invalid" } + it 'should successfully list all the servers.' do + pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" + match_status("should fail") + end + end context 'flavor list' do let(:command) { "knife openstack flavor list" + append_openstack_creds(is_list_cmd = true) } From 08d10588c5159e81a45a4c10b91771179edd3161 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Mon, 16 Sep 2013 14:01:05 +0530 Subject: [PATCH 18/22] Updated Gemfile and integration tests --- Gemfile | 1 - spec/integration/openstack_spec.rb | 36 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index e8767e6c..ffa3f2a8 100644 --- a/Gemfile +++ b/Gemfile @@ -12,5 +12,4 @@ group :development do gem 'active_support' gem 'activesupport' gem 'knife-cloud', :git => 'https://github.com/opscode/knife-cloud.git' - gem 'knife-windows', :git => 'https://github.com/opscode/knife-windows.git', :branch => 'knife-cloud' end diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index f52b7078..4f7f1ebd 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -135,7 +135,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds + " --sudo --image-os-type linux"} + append_openstack_creds + " --sudo"} after(:each) { cmd_out = "#{cmd_stdout}" } it 'should successfully create the server with the provided options.' do match_status("should succeed") @@ -226,7 +226,7 @@ def rm_known_host " --server-url http://localhost:8889" + " --yes" + get_ssh_credentials + - " --identity-file #{temp_dir}/openstack.pem --sudo --image-os-type linux" } + " --identity-file #{temp_dir}/openstack.pem --sudo" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -241,7 +241,7 @@ def rm_known_host " --template-file " + get_linux_template_file_path + " --server-url http://localhost:8889" + " --yes" + - append_openstack_creds() + " --sudo --image-os-type linux" } + append_openstack_creds() + " --sudo" } after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -259,7 +259,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --groups #{SecureRandom.hex(4)}"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -276,7 +276,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -293,7 +293,7 @@ def rm_known_host " --yes" + get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -311,7 +311,7 @@ def rm_known_host " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ " --openstack-ssh-key-id #{SecureRandom.hex(6)}"+ " --identity-file #{temp_dir}/openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw validation message and stop execution.' do match_status("should fail") @@ -329,7 +329,7 @@ def rm_known_host " --ssh-user #{@openstack_config['os_ssh_params']['ssh_user']}"+ " --openstack-ssh-key-id #{@openstack_config['os_ssh_params']['key_pair']}"+ " --identity-file #{temp_dir}/incorrect_openstack.pem"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should throw AuthenticationFailed Error message and stop execution.' do match_status("should fail") @@ -347,7 +347,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-private-network"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should bootstrap sucessfully with private ip address.' do pending "not yet done" @@ -366,7 +366,7 @@ def rm_known_host get_ssh_credentials + " --identity-file #{temp_dir}/openstack.pem"+ " --openstack-floating-ip"+ - append_openstack_creds() + " --sudo --image-os-type linux"} + append_openstack_creds() + " --sudo"} after(:each) { run(delete_instance_cmd("#{cmd_stdout}")) } it 'should associate a floating IP address to the new OpenStack node.' do pending 'empty floating ip pool' @@ -386,7 +386,7 @@ def rm_known_host " --template-file " + get_windows_msi_template_file_path + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + - " --yes --server-create-timeout 1800 --image-os-type windows" + + " --yes --server-create-timeout 1800" + get_winrm_credentials+ append_openstack_creds_for_windows() } after(:each) { cmd_out = "#{cmd_stdout}" } @@ -501,7 +501,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + " --yes --server-create-timeout 1800" + " --winrm-user #{SecureRandom.hex(6)}"+ @@ -522,7 +522,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']} " + " -f #{@openstack_config['os_params']['windows_flavor']} " + " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --bootstrap-protocol winrm" + " --yes --server-create-timeout 1800" + " --winrm-user #{@openstack_config['os_winrm_params']['winrm_user']}"+ @@ -598,7 +598,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -618,7 +618,7 @@ def rm_known_host " -I #{SecureRandom.hex(18)}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -637,7 +637,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['invalid_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -656,7 +656,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889 " + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ @@ -677,7 +677,7 @@ def rm_known_host " -I #{@openstack_config['os_params']['windows_image']}"+ " -f #{@openstack_config['os_params']['windows_flavor']} "+ " --template-file " + get_windows_msi_template_file_path + - " --server-url http://localhost:8889 --image-os-type windows" + + " --server-url http://localhost:8889" + " --yes" + " --bootstrap-protocol winrm" + get_winrm_credentials+ From 4c76231e5133b433880c68b7fc85fdb40d6b3bd9 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Mon, 16 Sep 2013 18:58:15 +0530 Subject: [PATCH 19/22] Updated integration tests to remove known_host file --- spec/integration/openstack_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index 4f7f1ebd..b5a26c3b 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -50,7 +50,8 @@ def get_winrm_credentials end def rm_known_host - FileUtils.rm_rf("~/.ssh/known_hosts") + known_hosts = File.expand_path("~") + "/.ssh/known_hosts" + FileUtils.rm_rf(known_hosts) end describe 'knife-openstack' do @@ -124,7 +125,7 @@ def rm_known_host end describe 'Linux Platform Tests - knife' , :if => is_config_present do - after(:each) {rm_known_host} + before(:each) {rm_known_host} context 'create server with standard options' do cmd_out = "" before(:each) { create_node_name("linux") } @@ -376,7 +377,7 @@ def rm_known_host end describe 'Windows Platform Tests - knife' , :if => is_config_present do - after(:each) {rm_known_host} + before(:each) {rm_known_host} context 'create server (for windows) with standard options' do cmd_out = "" before(:each) { create_node_name("windows") } From 3d6ad78d5c32976b179af0be9ac3625c0bd00359 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 18 Sep 2013 18:33:55 +0530 Subject: [PATCH 20/22] Updated Gemfile --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ffa3f2a8..9a0c2888 100644 --- a/Gemfile +++ b/Gemfile @@ -12,4 +12,5 @@ group :development do gem 'active_support' gem 'activesupport' gem 'knife-cloud', :git => 'https://github.com/opscode/knife-cloud.git' -end + gem 'knife-windows', :git => 'https://github.com/opscode/knife-windows.git' +end \ No newline at end of file From 37522897f79a2e3fc376773ed3e556e949f2af48 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 18 Sep 2013 18:47:43 +0530 Subject: [PATCH 21/22] skip integration tests if config file is missing. --- spec/integration/openstack_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index b5a26c3b..e6904e4a 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -54,7 +54,7 @@ def rm_known_host FileUtils.rm_rf(known_hosts) end -describe 'knife-openstack' do +describe 'knife-openstack' , :if => is_config_present do include KnifeTestBed include RSpec::KnifeTestUtils @@ -124,7 +124,7 @@ def rm_known_host end end - describe 'Linux Platform Tests - knife' , :if => is_config_present do + describe 'Linux Platform Tests - knife' do before(:each) {rm_known_host} context 'create server with standard options' do cmd_out = "" @@ -376,7 +376,7 @@ def rm_known_host end end - describe 'Windows Platform Tests - knife' , :if => is_config_present do + describe 'Windows Platform Tests - knife' do before(:each) {rm_known_host} context 'create server (for windows) with standard options' do cmd_out = "" From 9bef8c75afdbad55c38d89a7f2222b81e3621124 Mon Sep 17 00:00:00 2001 From: siddheshwar-more Date: Wed, 18 Sep 2013 18:54:04 +0530 Subject: [PATCH 22/22] Unmarked pending server list integration tests --- spec/integration/openstack_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/integration/openstack_spec.rb b/spec/integration/openstack_spec.rb index e6904e4a..35908d45 100644 --- a/spec/integration/openstack_spec.rb +++ b/spec/integration/openstack_spec.rb @@ -696,7 +696,6 @@ def rm_known_host context 'server list' do let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) } it 'should successfully list all the servers.' do - pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" match_status("should succeed") end end @@ -704,7 +703,6 @@ def rm_known_host context 'server list and chef-data' do let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data" } it 'should successfully list all the servers.' do - pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" match_status("should succeed") end end @@ -712,7 +710,6 @@ def rm_known_host context 'server list and chef-data option with valid chef-node-attribute' do let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute platform_family" } it 'should successfully list all the servers.' do - pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" match_status("should succeed") end end @@ -720,7 +717,6 @@ def rm_known_host context 'server list and chef-data option with invalid chef-node-attribute' do let(:command) { "knife openstack server list" + asppend_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute invalid" } it 'should successfully list all the servers.' do - pending "Currently failing due to OC-9451 bug, which is fixed but not yet merged into master" match_status("should fail") end end