Skip to content

(MODULES-6356) Fixes a problem still remaining from MODULES-2904 #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/provider/sqlserver_instance/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def format_cmd_args_array(switch, arr, cmd_args, use_discrete = false)
if use_discrete
arr.map.with_index { |var,i|
if i == 0
cmd_args << "#{switch}=\"#{var}\""
cmd_args << "#{switch}=#{var}"
else
cmd_args << "\"#{var}\""
cmd_args << "#{var}"
end
}
else
Expand Down
8 changes: 5 additions & 3 deletions spec/acceptance/sqlserver_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def sql_query_is_user_sysadmin(username)
context "Create an instance", {:testrail => ['88978', '89028', '89031', '89043', '89061']} do

before(:context) do
@ExtraAdminUser = 'ExtraSQLAdmin'
# Use a username with a space to test argument parsing works correctly
@ExtraAdminUser = 'Extra SQLAdmin'
pp = <<-MANIFEST
user { '#{@ExtraAdminUser}':
ensure => present,
Expand All @@ -83,7 +84,8 @@ def sql_query_is_user_sysadmin(username)
features = ['SQLEngine', 'Replication', 'FullText', 'DQ']

it "create #{inst_name} instance", :tier_high => true do
ensure_sqlserver_instance(features, inst_name,'present',"['Administrator','ExtraSQLAdmin']")
host_computer_name = on(host, 'CMD /C ECHO %COMPUTERNAME%').stdout.chomp
ensure_sqlserver_instance(features, inst_name,'present',"['Administrator','#{host_computer_name}\\#{@ExtraAdminUser}']")

validate_sql_install(host, {:version => version}) do |r|
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
Expand All @@ -95,7 +97,7 @@ def sql_query_is_user_sysadmin(username)
end

it "#{inst_name} instance has ExtraSQLAdmin as a sysadmin", :tier_low => true do
run_sql_query(host, run_sql_query_opts(inst_name, sql_query_is_user_sysadmin('ExtraSQLAdmin'), expected_row_count = 1))
run_sql_query(host, run_sql_query_opts(inst_name, sql_query_is_user_sysadmin(@ExtraAdminUser), expected_row_count = 1))
end

it "remove #{inst_name} instance", :tier_high => true do
Expand Down
29 changes: 18 additions & 11 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
# Install PE
run_puppet_install_helper

# Install PE License onto Master
install_pe_license(master)
# Install PE License onto Master, if one exists.
install_pe_license(master) unless hosts_as("master").empty?

# Determine root path of local module source.
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# In CI install from staging forge, otherwise from local
staging = { :module_name => 'puppetlabs-sqlserver' }
local = { :module_name => 'sqlserver', :source => proj_root }

unless ENV['MODULE_provision'] == 'no'
hosts_as("sql_host").each do |agent|
Expand Down Expand Up @@ -66,16 +72,8 @@
on(agent, puppet("module install #{dep}"))
end

# Determine root path of local module source.
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

# In CI install from staging forge, otherwise from local
staging = { :module_name => 'puppetlabs-sqlserver' }
local = { :module_name => 'sqlserver', :source => proj_root }

# Install sqlserver dependencies.
on(agent, puppet('module install puppetlabs-stdlib'))
on(master, puppet('module install puppetlabs-stdlib'))

# Mount windows 2012R2 ISO to allow install of .NET 3.5 Windows Feature
iso_opts = {
Expand All @@ -88,6 +86,15 @@
# Install sqlserver module from local source.
# See FM-5062 for more details.
copy_module_to(agent, local)
copy_module_to(master, local)
end

hosts_as("master").each do |host|
# Install sqlserver dependencies.
on(host, puppet('module install puppetlabs-stdlib'))

# Install sqlserver module from local source.
# See FM-5062 for more details.
local = { :module_name => 'sqlserver', :source => proj_root }
copy_module_to(host, local)
end
end
4 changes: 2 additions & 2 deletions spec/unit/puppet/provider/sqlserver_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def stub_uninstall(args, installed_features, exit_code = 0)
cmd_args << "/SECURITYMODE=SQL"
end

# wrap each arg in doublequotes
admin_args = execute_args[:sql_sysadmin_accounts].map { |a| "\"#{a}\"" }
# Extrace the SQL Sysadmins
admin_args = execute_args[:sql_sysadmin_accounts].map { |a| "#{a}" }
# prepend first arg only with CLI switch
admin_args[0] = "/SQLSYSADMINACCOUNTS=" + admin_args[0]
cmd_args += admin_args
Expand Down