-
Notifications
You must be signed in to change notification settings - Fork 21
(MODULES-2391) Create Automated Tests For sqlserver_instance 2015-08-26 #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ce0eb22
22057c0
ccd1f3b
03bf779
cb9c607
96c854d
d2ba03b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
require 'spec_helper_acceptance' | ||
require 'securerandom' | ||
require 'erb' | ||
|
||
host = find_only_one("sql_host") | ||
inst_name = "MSSQL" + SecureRandom.hex(4) | ||
inst_name = inst_name.upcase | ||
|
||
describe "sqlserver_instance", :node => host do | ||
version = host['sql_version'].to_s | ||
|
||
def ensure_sqlserver_instance(host, features, inst_name, ensure_val = 'present') | ||
manifest = <<-MANIFEST | ||
sqlserver_instance{'<%= inst_value %>': | ||
name => '<%= inst_value %>', | ||
ensure => <%= ensure_value %>, | ||
source => 'H:', | ||
features => [ <%= mssql_features %> ], | ||
sql_sysadmin_accounts => ['Administrator'], | ||
agt_svc_account => 'Administrator', | ||
agt_svc_password => 'Qu@lity!', | ||
} | ||
MANIFEST | ||
|
||
inst_value = inst_name | ||
ensure_value = ensure_val | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still have this value assigned for no reason, just use ensure_val instead of creating another variable. |
||
mssql_features = features.map{ |x| "'#{x}'"}.join(', ') | ||
|
||
pp = ERB.new(manifest).result(binding) | ||
|
||
apply_manifest_on(host, pp) do |r| | ||
expect(r.stderr).not_to match(/Error/i) | ||
end | ||
end | ||
|
||
context "can create sqlserver instance: #{inst_name}" do | ||
|
||
features = ['SQL', 'SQLEngine', 'Replication', 'FullText', 'DQ'] | ||
|
||
before(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method will always return true because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... I reused the method without catching it accepts exit code 1. I'll talk to Travis on this one when he's back. |
||
end | ||
|
||
after(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
it "create #{inst_name} instance" do | ||
ensure_sqlserver_instance(host, features, inst_name) | ||
|
||
validate_sql_install(host, {:version => version}) do |r| | ||
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/) | ||
end | ||
end | ||
|
||
it "remove #{inst_name} instance" do | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
|
||
validate_sql_install(host, {:version => version}) do |r| | ||
expect(r.stdout).not_to match(/#{Regexp.new(inst_name)}/) | ||
end | ||
end | ||
end | ||
|
||
context "can create instance with only SQL feature" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reword to "can create instance with only one SQL feature". |
||
features = ['SQL'] | ||
|
||
before(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
after(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
it "create #{inst_name} instance" do | ||
ensure_sqlserver_instance(host, features, inst_name) | ||
|
||
validate_sql_install(host, {:version => version}) do |r| | ||
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/) | ||
end | ||
end | ||
end | ||
|
||
context "can create instance with only RS feature" do | ||
features = ['RS'] | ||
|
||
before(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
after(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
it "create #{inst_name} instance" do | ||
ensure_sqlserver_instance(host, features, inst_name) | ||
|
||
validate_sql_install(host, {:version => version}) do |r| | ||
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/) | ||
end | ||
end | ||
end | ||
|
||
context "can create instance with only AS feature" do | ||
features = ['AS'] | ||
|
||
before(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
after(:all) do | ||
ensure_sqlserver_instance(host, features, inst_name, 'absent') | ||
remove_sql_features(host, {:features => features, :version => version}) | ||
end | ||
|
||
it "create #{inst_name} instance" do | ||
ensure_sqlserver_instance(host, features, inst_name) | ||
|
||
validate_sql_install(host, {:version => version}) do |r| | ||
expect(r.stdout).to match(/#{Regexp.new(inst_name)}/) | ||
end | ||
end | ||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use the same values, there isn't much reason to create additional resources for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I changed back and forth the way to get the instance name and forgot to clean it. Will change it to use the same value, run it again and update the PR