4
4
5
5
host = find_only_one ( "sql_host" )
6
6
7
+ def new_random_instance_name
8
+ ( "MSSQL" + SecureRandom . hex ( 4 ) ) . upcase . to_s
9
+ end
10
+
7
11
describe "sqlserver_instance" , :node => host do
8
12
version = host [ 'sql_version' ] . to_s
9
13
10
- def new_random_instance_name
11
- return ( "MSSQL" + SecureRandom . hex ( 4 ) ) . upcase . to_s
12
- end
13
14
14
15
def ensure_sqlserver_instance ( host , features , inst_name , ensure_val = 'present' )
15
16
manifest = <<-MANIFEST
@@ -24,7 +25,7 @@ def ensure_sqlserver_instance(host, features, inst_name, ensure_val = 'present')
24
25
}
25
26
MANIFEST
26
27
27
- mssql_features = features . map { |x | "'#{ x } '" } . join ( ', ' )
28
+ mssql_features = features . map { |x | "'#{ x } '" } . join ( ', ' )
28
29
29
30
pp = ERB . new ( manifest ) . result ( binding )
30
31
@@ -34,87 +35,83 @@ def ensure_sqlserver_instance(host, features, inst_name, ensure_val = 'present')
34
35
end
35
36
36
37
context "Create an instance" , { :testrail => [ '88978' , '89028' , '89031' , '89043' , '89061' ] } do
38
+ inst_name = new_random_instance_name
39
+ features = [ 'SQL' , 'SQLEngine' , 'Replication' , 'FullText' , 'DQ' ]
37
40
38
- before ( :all ) do
39
- @inst_name = new_random_instance_name
40
- @features = [ 'SQL' , 'SQLEngine' , 'Replication' , 'FullText' , 'DQ' ]
41
- end
42
-
43
- it "create #{ @inst_name } instance" do
44
- ensure_sqlserver_instance ( host , @features , @inst_name )
41
+ it "create #{ inst_name } instance" do
42
+ ensure_sqlserver_instance ( host , features , inst_name )
45
43
46
44
validate_sql_install ( host , { :version => version } ) do |r |
47
- expect ( r . stdout ) . to match ( /#{ Regexp . new ( @ inst_name) } / )
45
+ expect ( r . stdout ) . to match ( /#{ Regexp . new ( inst_name ) } / )
48
46
end
49
47
end
50
48
51
- it "remove #{ @ inst_name} instance" do
52
- ensure_sqlserver_instance ( host , @ features, @ inst_name, 'absent' )
49
+ it "remove #{ inst_name } instance" do
50
+ ensure_sqlserver_instance ( host , features , inst_name , 'absent' )
53
51
52
+ # Ensure all features for this instance are removed and the defaults are left alone
54
53
validate_sql_install ( host , { :version => version } ) do |r |
55
- expect ( r . stdout ) . not_to match ( /#{ Regexp . new ( @inst_name ) } / )
54
+ expect ( r . stdout ) . to match ( /MSSQLSERVER\s +Database Engine Services/ )
55
+ expect ( r . stdout ) . to match ( /MSSQLSERVER\s +SQL Server Replication/ )
56
+ expect ( r . stdout ) . to match ( /MSSQLSERVER\s +Data Quality Services/ )
57
+ expect ( r . stdout ) . not_to match ( /#{ inst_name } \s +Database Engine Services/ )
58
+ expect ( r . stdout ) . not_to match ( /#{ inst_name } \s +SQL Server Replication/ )
59
+ expect ( r . stdout ) . not_to match ( /#{ inst_name } \s +Data Quality Services/ )
56
60
end
57
61
end
58
62
end
59
63
60
64
context "Feature has only one 'SQL'" , { :testrail => [ '89032' ] } do
61
-
62
- before ( :all ) do
63
- @inst_name = new_random_instance_name
64
- @features = [ 'SQL' ]
65
- end
65
+ inst_name = new_random_instance_name
66
+ features = [ 'SQL' ]
66
67
67
68
after ( :all ) do
68
- ensure_sqlserver_instance ( host , @ features, @ inst_name, 'absent' )
69
+ ensure_sqlserver_instance ( host , features , inst_name , 'absent' )
69
70
end
70
71
71
- it "create #{ @ inst_name} instance with only one SQL feature" do
72
- ensure_sqlserver_instance ( host , @ features, @ inst_name)
72
+ it "create #{ inst_name } instance with only one SQL feature" do
73
+ ensure_sqlserver_instance ( host , features , inst_name )
73
74
74
75
validate_sql_install ( host , { :version => version } ) do |r |
75
- expect ( r . stdout ) . to match ( /#{ Regexp . new ( @inst_name ) } / )
76
+ expect ( r . stdout ) . to match ( /#{ inst_name } \s +Database Engine Services/ )
77
+ expect ( r . stdout ) . to match ( /#{ inst_name } \s +SQL Server Replication/ )
78
+ expect ( r . stdout ) . to match ( /#{ inst_name } \s +Data Quality Services/ )
76
79
end
77
80
end
78
81
end
79
82
80
83
context "Feature has only one 'RS'" , { :testrail => [ '89034' ] } do
81
-
82
- before ( :all ) do
83
- @inst_name = new_random_instance_name
84
- @features = [ 'RS' ]
85
- end
84
+ inst_name = new_random_instance_name
85
+ features = [ 'RS' ]
86
86
87
87
after ( :all ) do
88
- ensure_sqlserver_instance ( host , @ features, @ inst_name, 'absent' )
88
+ ensure_sqlserver_instance ( host , features , inst_name , 'absent' )
89
89
end
90
90
91
- it "create #{ @ inst_name} instance with only one RS feature" do
92
- ensure_sqlserver_instance ( host , @ features, @ inst_name)
91
+ it "create #{ inst_name } instance with only one RS feature" do
92
+ ensure_sqlserver_instance ( host , features , inst_name )
93
93
94
94
validate_sql_install ( host , { :version => version } ) do |r |
95
- expect ( r . stdout ) . to match ( /#{ Regexp . new ( @ inst_name) } / )
95
+ expect ( r . stdout ) . to match ( /#{ inst_name } \s +Reporting Services / )
96
96
end
97
97
end
98
98
end
99
99
100
100
context "Feature has only one 'AS'" , { :testrail => [ '89033' ] } do
101
-
102
- before ( :all ) do
103
- @inst_name = new_random_instance_name
104
- @features = [ 'AS' ]
105
- end
101
+ inst_name = new_random_instance_name
102
+ features = [ 'AS' ]
106
103
107
104
after ( :all ) do
108
- ensure_sqlserver_instance ( host , @ features, @ inst_name, 'absent' )
105
+ ensure_sqlserver_instance ( host , features , inst_name , 'absent' )
109
106
end
110
107
111
108
#skip below test due to ticket MODULES-2379, when the ticket was resolved
112
109
# will change xit to it
113
- xit "create #{ @ inst_name} instance with only one AS feature" do
114
- ensure_sqlserver_instance ( host , @ features, @ inst_name)
110
+ xit "create #{ inst_name } instance with only one AS feature" do
111
+ ensure_sqlserver_instance ( host , features , inst_name )
115
112
116
113
validate_sql_install ( host , { :version => version } ) do |r |
117
- expect ( r . stdout ) . to match ( /#{ Regexp . new ( @ inst_name) } / )
114
+ expect ( r . stdout ) . to match ( /#{ Regexp . new ( inst_name ) } / )
118
115
end
119
116
end
120
117
end
0 commit comments