Skip to content

Commit 4733e6e

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

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
+79
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_database 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+
42+
context "server_url =>", {:testrail => ['89078']} do
43+
44+
before(:all) do
45+
# Create new database
46+
@table_name = 'Tables_' + SecureRandom.hex(3)
47+
@query = "USE #{DB_NAME}; SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '#{@table_name}';"
48+
49+
ensure_sqlserver_database(host)
50+
end
51+
52+
after(:all) do
53+
# remove the newly created instance
54+
ensure_sqlserver_database(host, 'absent')
55+
end
56+
57+
it "Run a simple tsql command via sqlserver_tsql:" do
58+
pp = <<-MANIFEST
59+
sqlserver::config{'MSSQLSERVER':
60+
instance_name => 'MSSQLSERVER',
61+
admin_user => 'sa',
62+
admin_pass => 'Pupp3t1@',
63+
}
64+
sqlserver_tsql{'testsqlserver_tsql':
65+
instance => 'MSSQLSERVER',
66+
database => '#{DB_NAME}',
67+
command => "CREATE TABLE #{@table_name} (id INT, name VARCHAR(20), email VARCHAR(20));",
68+
}
69+
MANIFEST
70+
apply_manifest_on(host, pp) do |r|
71+
expect(r.stderr).not_to match(/Error/i)
72+
end
73+
74+
puts "validate the result of tsql command and table #{@table_name} should be created:"
75+
run_sql_query(host, {:query => @query, :sql_admin_user => @admin_user, \
76+
:sql_admin_pass => @admin_pass, :expected_row_count => 1})
77+
end
78+
end
79+
end

0 commit comments

Comments
 (0)