Skip to content

Commit 24d7d8a

Browse files
committed
(maint) Use agent facts when removing SQL instances
- Previously the test that removes instance was hard-coded to use 'MSSQLSERVER', but this makes the test a bit more fragile. Instead, use Beaker to load the agents facts, passing the module sqlserver/lib/facter directory in via FACTERLIB so that the names of all instances can be retrieved.
1 parent cc5faa1 commit 24d7d8a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spec/acceptance/sqlserver_features_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,12 @@ def bind_and_apply_failing_manifest(host, features, ensure_val = 'present')
241241
features = ['Tools', 'BC', 'Conn', 'SSMS', 'ADV_SSMS', 'SDK', 'IS', 'MDS']
242242

243243
before(:all) do
244-
# this assumes that only default MSSQLSERVER has been installed so far
245-
# be careful about running tests out of sequence
246-
remove_sql_instances(host, {:version => version, :instance_names => ['MSSQLSERVER']})
244+
# use agents fact to get instance names
245+
distmoduledir = on(host, "echo #{host['distmoduledir']}").raw_output.chomp
246+
facter_opts = {:environment => {'FACTERLIB' => "#{distmoduledir}/sqlserver/lib/facter" }}
247+
248+
names = eval(fact_on(host, 'sqlserver_instances', facter_opts)).values.inject(:merge).keys
249+
remove_sql_instances(host, {:version => version, :instance_names => names})
247250
end
248251

249252
after(:all) do

0 commit comments

Comments
 (0)