Skip to content

(MODULES-2464) create database with partial containment #143

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

Closed
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
79 changes: 79 additions & 0 deletions spec/acceptance/sqlserver_database_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require 'spec_helper_acceptance'
require 'securerandom'
require 'erb'

host = find_only_one("sql_host")

# database name
DB_NAME = ("DB" + SecureRandom.hex(4)).upcase

#database user:
DB_LOGIN_USER = "loginuser" + SecureRandom.hex(2)

describe "sqlserver_database test", :node => host do

def ensure_sqlserver_database(host, ensure_val = 'present')
pp = <<-MANIFEST
sqlserver::config{'MSSQLSERVER':
admin_user => 'sa',
admin_pass => 'Pupp3t1@',
}
sqlserver::sp_configure{ 'spconfig1':
config_name => 'contained database authentication',
value => 1,
reconfigure => true,
instance => 'MSSQLSERVER',
}

sqlserver::database{ '#{DB_NAME}':
instance => 'MSSQLSERVER',
collation_name => 'SQL_Estonian_CP1257_CS_AS',
compatibility => '100',
containment => 'PARTIAL',
require => Sqlserver::Sp_configure['spconfig1']
}
MANIFEST

apply_manifest_on(host, pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end
end

context "server_url =>", {:testrail => ['89078']} do

before(:all) do
# Create new database
@table_name = 'Tables_' + SecureRandom.hex(3)
@query = "USE #{DB_NAME}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"

ensure_sqlserver_database(host)
end

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

it "Run a simple tsql command via sqlserver_tsql:" do
pp = <<-MANIFEST
sqlserver::config{'MSSQLSERVER':
instance_name => 'MSSQLSERVER',
admin_user => 'sa',
admin_pass => 'Pupp3t1@',
}
sqlserver_tsql{'testsqlserver_tsql':
instance => 'MSSQLSERVER',
database => '#{DB_NAME}',
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
}
MANIFEST
apply_manifest_on(host, pp) do |r|
expect(r.stderr).not_to match(/Error/i)
end

puts "validate the result of tsql command and table #{@table_name} should be created:"
run_sql_query(host, {:query => @query, :sql_admin_user => @admin_user, \
:sql_admin_pass => @admin_pass, :expected_row_count => 1})
end
end
end