Skip to content

Commit c3ab92f

Browse files
committed
(MODULES-2464) create database with partial containment
1 parent 78077b9 commit c3ab92f

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
require 'spec_helper_acceptance'
2+
require 'securerandom'
3+
require 'erb'
4+
5+
host = find_only_one("sql_host")
6+
7+
# database name
8+
DB_NAME = ("DB" + SecureRandom.hex(4)).upcase
9+
10+
#database user:
11+
DB_LOGIN_USER = "loginuser" + SecureRandom.hex(2)
12+
13+
describe "sqlserver_tsql test", :node => host do
14+
15+
def ensure_sqlserver_database(host, ensure_val = 'present')
16+
pp = <<-MANIFEST
17+
sqlserver::config{'MSSQLSERVER':
18+
admin_user => 'sa',
19+
admin_pass => 'Pupp3t1@',
20+
}
21+
sqlserver::sp_configure{ 'spconfig1':
22+
config_name => 'contained database authentication',
23+
value => 1,
24+
reconfigure => true,
25+
instance => 'MSSQLSERVER',
26+
}
27+
28+
sqlserver::database{ '#{DB_NAME}':
29+
instance => 'MSSQLSERVER',
30+
collation_name => 'SQL_Estonian_CP1257_CS_AS',
31+
compatibility => '100',
32+
containment => 'PARTIAL',
33+
require => Sqlserver::Sp_configure['spconfig1']
34+
}
35+
MANIFEST
36+
37+
apply_manifest_on(host, pp) do |r|
38+
expect(r.stderr).not_to match(/Error/i)
39+
end
40+
end
41+
end
42+
43+
context "server_url =>", {:testrail => ['89078']} do
44+
45+
before(:all) do
46+
# Create new database
47+
@table_name = 'Tables_' + SecureRandom.hex(3)
48+
@query = "USE #{DB_NAME}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
49+
50+
ensure_sqlserver_database(host)
51+
end
52+
53+
after(:all) do
54+
# remove the newly created instance
55+
ensure_sqlserver_database(host, 'absent')
56+
end
57+
58+
it "Run a simple tsql command via sqlserver_tsql:" do
59+
pp = <<-MANIFEST
60+
sqlserver::config{'MSSQLSERVER':
61+
instance_name => 'MSSQLSERVER',
62+
admin_user => 'sa',
63+
admin_pass => 'Pupp3t1@',
64+
}
65+
sqlserver_tsql{'testsqlserver_tsql':
66+
instance => 'MSSQLSERVER',
67+
database => '#{DB_NAME}',
68+
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
69+
}
70+
MANIFEST
71+
apply_manifest_on(host, pp) do |r|
72+
expect(r.stderr).not_to match(/Error/i)
73+
end
74+
75+
puts "validate the result of tsql command and table #{@table_name} should be created:"
76+
run_sql_query(host, {:query => @query, :sql_admin_user => @admin_user, \
77+
:sql_admin_pass => @admin_pass, :expected_row_count => 1})
78+
end
79+
end

0 commit comments

Comments
 (0)