-
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
Merged
cowofevil
merged 7 commits into
puppetlabs:master
from
phongdly:MODULES-2391/SQLSERVER-Create_Automated_Tested_for_sqlserver-instance
Aug 26, 2015
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ce0eb22
(MODULES-2391) SQLSERVER - Create Automated Tests For sqlserver_insta…
phongdly 22057c0
(MODULES-2391) change inst_name to be same value
phongdly ccd1f3b
(MODULES-2391) skip test create instance with only AS feature
phongdly 03bf779
(MODULES-2391) removed ensure_value
phongdly cb9c607
(MODULES-2391) remove 'remove_sql_features' method
phongdly 96c854d
(MODULES-2391) add testrail context
phongdly d2ba03b
(MODULES-2391) added missing meta-tag
phongdly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_name}': | ||
name => '#{inst_name}', | ||
ensure => <%= ensure_val %>, | ||
source => 'H:', | ||
features => [ <%= mssql_features %> ], | ||
sql_sysadmin_accounts => ['Administrator'], | ||
agt_svc_account => 'Administrator', | ||
agt_svc_password => 'Qu@lity!', | ||
} | ||
MANIFEST | ||
|
||
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}) | ||
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 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. Ditto. |
||
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 with only RS feature" 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 | ||
|
||
#skip below test due to ticket MODULES-2379, when the ticket was resolved | ||
# will change xit to it | ||
xit "create #{inst_name} instance with only AS feature" 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This method will always return true because
:acceptable_exit_codes => [0, 1, 2]
. That doesn't seem right, can you explain why this always returns true?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.
Hmm... I reused the method without catching it accepts exit code 1. I'll talk to Travis on this one when he's back.
I'll update the code and remove the use of it in this PR which only need to create and delete instances