Skip to content

(FM-5062) Add testmode switcher to sqlserver module #223

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 1 commit into from
Jun 23, 2017
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: 4 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Gemfile:
optional:
':development':
- gem: yard
':system_tests':
- gem: beaker-testmode_switcher
version: '<= 0.2.0'
- gem: master_manipulator
Rakefile:
unmanaged: true
spec/spec_helper.rb:
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ group :system_tests do
gem "beaker-pe", :require => false
gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem "beaker-testmode_switcher", '<= 0.2.0', :require => false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will need to go into sync.yaml otherwise the next modsync will overwrite them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

gem 'master_manipulator', :require => false
end

gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
Expand Down
14 changes: 7 additions & 7 deletions spec/acceptance/sqlserver_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

describe "sqlserver::config test", :node => host do

def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')
def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
create_new_instance= <<-MANIFEST
sqlserver_instance{'#{inst_name}':
ensure => '#{ensure_val}',
Expand All @@ -25,7 +25,7 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')
}
MANIFEST

apply_manifest_on(host, create_new_instance) do |r|
execute_manifest(create_new_instance) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand All @@ -34,7 +34,7 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')

before(:all) do
# Create new instance
ensure_sqlserver_instance(host, inst_name)
ensure_sqlserver_instance(inst_name)

# get credentials for new config
@admin_user = "admin" + SecureRandom.hex(2)
Expand All @@ -46,7 +46,7 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')

after(:all) do
# remove the newly created instance
ensure_sqlserver_instance(host, 'absent')
ensure_sqlserver_instance('absent')
end

it "Create New Admin Login:" do
Expand All @@ -64,7 +64,7 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')
svrroles => {'sysadmin' => 1},
}
MANIFEST
apply_manifest_on(host, create_new_login) do |r|
execute_manifest(create_new_login) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand All @@ -80,7 +80,7 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')
instance => '#{inst_name}',
}
MANIFEST
apply_manifest_on(host, pp) do |r|
execute_manifest(pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand All @@ -103,7 +103,7 @@ def ensure_sqlserver_instance(host,inst_name, ensure_val = 'present')
instance => '#{inst_name}',
}
MANIFEST
apply_manifest_on(host, pp) do |r|
execute_manifest(pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/acceptance/sqlserver_database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

describe "Test sqlserver::database", :node => host do

def ensure_sqlserver_database(host, pp)
apply_manifest_on(host, pp) do |r|
def ensure_sqlserver_database(pp)
execute_manifest(pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand Down Expand Up @@ -39,7 +39,7 @@ def run_sql_query_opts (query, expected_row_count)
ensure => 'absent',
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)
end

it "Test Case C89019: Create a database" do
Expand All @@ -57,7 +57,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate the Database '#{@db_name}' and table '#{@table_name}' are successfully created:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand All @@ -73,7 +73,7 @@ def run_sql_query_opts (query, expected_row_count)
sqlserver::database{'#{@db_name}':
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate the Database '#{@db_name}' exists"
query = "SELECT database_id from sys.databases WHERE name = '#{@db_name}';"
Expand All @@ -88,7 +88,7 @@ def run_sql_query_opts (query, expected_row_count)
ensure => absent,
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate the Database '#{@db_name}' does not exist"
query = "SELECT database_id from sys.databases WHERE name = '#{@db_name}';"
Expand All @@ -111,7 +111,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate that a table can be created in the database:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand Down Expand Up @@ -142,7 +142,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate that a table can be created in the database:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand Down Expand Up @@ -180,7 +180,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate that a table can be created in the database:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand Down Expand Up @@ -219,7 +219,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate that a table can be created in the database:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand Down Expand Up @@ -258,7 +258,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate that a table can be created in the database:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand Down Expand Up @@ -297,7 +297,7 @@ def run_sql_query_opts (query, expected_row_count)
require => Sqlserver::Database['#{@db_name}'],
}
MANIFEST
ensure_sqlserver_database(host, pp)
ensure_sqlserver_database(pp)

puts "Validate that a table can be created in the database:"
query = "USE #{@db_name}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
Expand Down
24 changes: 12 additions & 12 deletions spec/acceptance/sqlserver_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def new_random_instance_name
describe "sqlserver_instance", :node => host do
version = host['sql_version'].to_s

def ensure_sqlserver_instance(host, features, inst_name, ensure_val = 'present', sysadmin_accounts = "['Administrator']")
def ensure_sqlserver_instance(features, inst_name, ensure_val = 'present', sysadmin_accounts = "['Administrator']")
manifest = <<-MANIFEST
sqlserver_instance{'#{inst_name}':
name => '#{inst_name}',
Expand All @@ -31,7 +31,7 @@ def ensure_sqlserver_instance(host, features, inst_name, ensure_val = 'present',

pp = ERB.new(manifest).result(binding)

apply_manifest_on(host, pp) do |r|
execute_manifest(pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand Down Expand Up @@ -68,7 +68,7 @@ def sql_query_is_user_sysadmin(username)
password => 'Puppet01!',
}
MANIFEST
apply_manifest_on(host,pp)
execute_manifest(pp)
end

after(:context) do
Expand All @@ -77,14 +77,14 @@ def sql_query_is_user_sysadmin(username)
ensure => absent,
}
MANIFEST
apply_manifest_on(host,pp)
execute_manifest(pp)
end

inst_name = new_random_instance_name
features = ['SQLEngine', 'Replication', 'FullText', 'DQ']

it "create #{inst_name} instance" do
ensure_sqlserver_instance(host, features, inst_name,'present',"['Administrator','ExtraSQLAdmin']")
ensure_sqlserver_instance(features, inst_name,'present',"['Administrator','ExtraSQLAdmin']")

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

it "remove #{inst_name} instance" do
ensure_sqlserver_instance(host, features, inst_name, 'absent')
ensure_sqlserver_instance(features, inst_name, 'absent')

# Ensure all features for this instance are removed and the defaults are left alone
validate_sql_install(host, {:version => version}) do |r|
Expand All @@ -115,15 +115,15 @@ def sql_query_is_user_sysadmin(username)
end

context "Feature has only one 'RS'", {:testrail => ['89034']} do
inst_name = new_random_instance_name
features = ['RS']
inst_name = new_random_instance_name
features = ['RS']

after(:all) do
ensure_sqlserver_instance(host, features, inst_name, 'absent')
ensure_sqlserver_instance(features, inst_name, 'absent')
end

it "create #{inst_name} instance with only one RS feature" do
ensure_sqlserver_instance(host, features, inst_name)
ensure_sqlserver_instance(features, inst_name)

validate_sql_install(host, {:version => version}) do |r|
expect(r.stdout).to match(/#{inst_name}\s+Reporting Services/)
Expand All @@ -136,13 +136,13 @@ def sql_query_is_user_sysadmin(username)
features = ['AS']

after(:all) do
ensure_sqlserver_instance(host, features, inst_name, 'absent')
ensure_sqlserver_instance(features, inst_name, 'absent')
end

#skip below test due to ticket MODULES-2379, when the ticket was resolved
# will change xit to it
xit "create #{inst_name} instance with only one AS feature" do
ensure_sqlserver_instance(host, features, inst_name)
ensure_sqlserver_instance(features, inst_name)

validate_sql_install(host, {:version => version}) do |r|
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
Expand Down
28 changes: 14 additions & 14 deletions spec/acceptance/sqlserver_login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# Covers testrail => ['89118', '89119', '89120', '89121', '89122', '89123', '89124', '89125', '89540']
describe "Test sqlserver::login", :node => host do

def ensure_manifest_apply(host, pp)
apply_manifest_on(host, pp) do |r|
def ensure_manifest_execute(pp)
execute_manifest(pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end
Expand Down Expand Up @@ -46,7 +46,7 @@ def remove_test_logins(host)
ensure => 'absent',
}
MANIFEST
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

def create_login_manifest (testcase,login_name,login_password,options = {})
Expand Down Expand Up @@ -114,7 +114,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
ensure => 'present',
}
MANIFEST
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

# Delete all test fixtures
Expand All @@ -137,7 +137,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
ensure => 'absent',
}
MANIFEST
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

['SQL_LOGIN user', 'WINDOWS_LOGIN user', 'WINDOWS_LOGIN group'].each do |testcase|
Expand All @@ -163,7 +163,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})

it "can create a default #{testcase}" do
pp = create_login_manifest(testcase,@login_under_test,@login_passwd)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

it "should exist in the principals table" do
Expand All @@ -181,7 +181,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})

it "is idempotent" do
pp = create_login_manifest(testcase,@login_under_test,@login_passwd)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end
end

Expand All @@ -192,7 +192,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
it "can create an #{testcase} with 'check_expiration','check_policy' set" do
options = { 'check_expiration' => true, 'check_policy' => true }
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

it "should have is_expiration_checked set" do
Expand All @@ -212,7 +212,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
it "can create a #{testcase} with 'default_database','default_language'" do
options = { 'default_database' => "#{db_name}", 'default_language' => 'Spanish' }
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

it "should exist in the principals table" do
Expand All @@ -237,7 +237,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
it "can create #{testcase} with optional 'disabled'" do
options = { 'disabled' => true }
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

if testcase == 'WINDOWS_LOGIN group'
Expand All @@ -261,7 +261,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
it "should create an initial #{testcase}" do
options = { 'svrroles' => '{\'sysadmin\' => 1}' }
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

it "should exist in the principals table on creation" do
Expand All @@ -272,7 +272,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
it "should modify a #{testcase} login" do
options = { 'disabled' => true, 'default_database' => "#{db_name}", 'default_language' => 'Spanish', 'check_expiration' => true, 'check_policy' => true, 'svrroles' => '{\'sysadmin\' => 1, \'serveradmin\' => 1}' }
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

if testcase == 'SQL_LOGIN user'
Expand Down Expand Up @@ -338,7 +338,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})

it "should create an initial #{testcase}" do
pp = create_login_manifest(testcase,@login_under_test,@login_passwd)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

it "should exist in the principals table on creation" do
Expand All @@ -349,7 +349,7 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
it "should remove a #{testcase} on ensure => absent" do
options = { 'ensure' => 'absent' }
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
ensure_manifest_apply(host, pp)
ensure_manifest_execute(pp)
end

it "should not exist in the principals table after deletion" do
Expand Down
Loading