Skip to content

Commit b157d3e

Browse files
author
Ryan Gard
committed
Merge pull request #134 from phongdly/MODULES-2391/SQLSERVER-Create_Automated_Tested_for_sqlserver-instance
(MODULES-2391) Create Automated Tests For sqlserver_instance 2015-08-26
2 parents a566c8a + d2ba03b commit b157d3e

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
require 'spec_helper_acceptance'
2+
require 'securerandom'
3+
require 'erb'
4+
5+
host = find_only_one("sql_host")
6+
inst_name = ("MSSQL" + SecureRandom.hex(4)).upcase
7+
8+
describe "sqlserver_instance", :node => host do
9+
version = host['sql_version'].to_s
10+
11+
def ensure_sqlserver_instance(host, features, inst_name, ensure_val = 'present')
12+
manifest = <<-MANIFEST
13+
sqlserver_instance{'#{inst_name}':
14+
name => '#{inst_name}',
15+
ensure => <%= ensure_val %>,
16+
source => 'H:',
17+
features => [ <%= mssql_features %> ],
18+
sql_sysadmin_accounts => ['Administrator'],
19+
agt_svc_account => 'Administrator',
20+
agt_svc_password => 'Qu@lity!',
21+
}
22+
MANIFEST
23+
24+
mssql_features = features.map{ |x| "'#{x}'"}.join(', ')
25+
26+
pp = ERB.new(manifest).result(binding)
27+
28+
apply_manifest_on(host, pp) do |r|
29+
expect(r.stderr).not_to match(/Error/i)
30+
end
31+
end
32+
33+
context "server_url =>", {:testrail => ['88978', '89028', '89031', '89043', '89061']} do
34+
35+
features = ['SQL', 'SQLEngine', 'Replication', 'FullText', 'DQ']
36+
37+
before(:all) do
38+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
39+
end
40+
41+
after(:all) do
42+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
43+
end
44+
45+
it "create #{inst_name} instance" do
46+
ensure_sqlserver_instance(host, features, inst_name)
47+
48+
validate_sql_install(host, {:version => version}) do |r|
49+
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
50+
end
51+
end
52+
53+
it "remove #{inst_name} instance" do
54+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
55+
56+
validate_sql_install(host, {:version => version}) do |r|
57+
expect(r.stdout).not_to match(/#{Regexp.new(inst_name)}/)
58+
end
59+
end
60+
end
61+
62+
context "server_url =>", {:testrail => ['89032']} do
63+
features = ['SQL']
64+
65+
before(:all) do
66+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
67+
end
68+
69+
after(:all) do
70+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
71+
end
72+
73+
it "create #{inst_name} instance with only one SQL feature" do
74+
ensure_sqlserver_instance(host, features, inst_name)
75+
76+
validate_sql_install(host, {:version => version}) do |r|
77+
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
78+
end
79+
end
80+
end
81+
82+
context "server_url =>", {:testrail => ['89034']} do
83+
features = ['RS']
84+
85+
before(:all) do
86+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
87+
end
88+
89+
after(:all) do
90+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
91+
end
92+
93+
it "create #{inst_name} instance with only one RS feature" do
94+
ensure_sqlserver_instance(host, features, inst_name)
95+
96+
validate_sql_install(host, {:version => version}) do |r|
97+
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
98+
end
99+
end
100+
end
101+
102+
context "server_url =>", {:testrail => ['89033']} do
103+
features = ['AS']
104+
105+
before(:all) do
106+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
107+
end
108+
109+
after(:all) do
110+
ensure_sqlserver_instance(host, features, inst_name, 'absent')
111+
end
112+
113+
#skip below test due to ticket MODULES-2379, when the ticket was resolved
114+
# will change xit to it
115+
xit "create #{inst_name} instance with only one AS feature" do
116+
ensure_sqlserver_instance(host, features, inst_name)
117+
118+
validate_sql_install(host, {:version => version}) do |r|
119+
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/)
120+
end
121+
end
122+
end
123+
end

0 commit comments

Comments
 (0)