-
Notifications
You must be signed in to change notification settings - Fork 21
(FM-8199) - Port module to Litmus #345
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
fixtures: | ||
repositories: | ||
"stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' | ||
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' | ||
provision: 'https://github.com/puppetlabs/provision.git' | ||
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git' | ||
symlinks: | ||
sqlserver: "#{source_dir}" |
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,81 @@ | ||
|
||
name: "release" | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'release' | ||
|
||
jobs: | ||
LitmusAcceptance2012Sql: | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
ruby_version: [2.5.x] | ||
puppet_gem_version: [~> 6.0] | ||
platform: [release_checks_sql_2012] | ||
agent_family: ['puppet5', 'puppet6'] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Litmus Parallel | ||
uses: puppetlabs/action-litmus_parallel@master | ||
with: | ||
platform: ${{ matrix.platform }} | ||
agent_family: ${{ matrix.agent_family }} | ||
additional_command: ${{ matrix.additional_command }} | ||
LitmusAcceptance2014Sql: | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
ruby_version: [2.5.x] | ||
puppet_gem_version: [~> 6.0] | ||
platform: [release_checks_sql_2014] | ||
agent_family: ['puppet5', 'puppet6'] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Litmus Parallel | ||
uses: puppetlabs/action-litmus_parallel@master | ||
with: | ||
platform: ${{ matrix.platform }} | ||
agent_family: ${{ matrix.agent_family }} | ||
additional_command: ${{ matrix.additional_command }} | ||
LitmusAcceptance2016Sql: | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
ruby_version: [2.5.x] | ||
puppet_gem_version: [~> 6.0] | ||
platform: [release_checks_sql_2016_parity] | ||
agent_family: ['puppet5', 'puppet6'] | ||
additional_command: ['bundle exec rake litmus:add_feature[sqlversion_2016]'] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Litmus Parallel | ||
uses: puppetlabs/action-litmus_parallel@master | ||
with: | ||
platform: ${{ matrix.platform }} | ||
agent_family: ${{ matrix.agent_family }} | ||
additional_command: ${{ matrix.additional_command }} | ||
|
||
Spec: | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
check: [parallel_spec, 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop'] | ||
ruby_version: [2.5.x] | ||
puppet_gem_version: [~> 5.0, ~> 6.0] | ||
exclude: | ||
- puppet_gem_version: ~> 5.0 | ||
check: 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop' | ||
- ruby_version: 2.5.x | ||
puppet_gem_version: ~> 5.0 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Spec Tests | ||
uses: puppetlabs/action-litmus_spec@master | ||
with: | ||
puppet_gem_version: ${{ matrix.puppet_gem_version }} | ||
check: ${{ matrix.check }} |
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
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
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 |
---|---|---|
@@ -1,110 +1,112 @@ | ||
module PuppetX::Sqlserver | ||
CONNECTION_CLOSED = 0 | ||
|
||
class SqlConnection # rubocop:disable Style/Documentation | ||
def open_and_run_command(query, config) | ||
begin | ||
open(config) | ||
execute(query) | ||
rescue win32_exception => e | ||
return ResultOutput.new(true, e.message, @connection) | ||
ensure | ||
close | ||
module PuppetX # rubocop:disable Style/ClassAndModuleChildren | ||
michaeltlombardi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
module Sqlserver | ||
CONNECTION_CLOSED = 0 | ||
|
||
class SqlConnection # rubocop:disable Style/Documentation | ||
def open_and_run_command(query, config) | ||
begin | ||
open(config) | ||
execute(query) | ||
rescue win32_exception => e | ||
return ResultOutput.new(true, e.message, @connection) | ||
ensure | ||
close | ||
end | ||
|
||
ResultOutput.new(false, nil, @connection) | ||
end | ||
|
||
ResultOutput.new(false, nil, @connection) | ||
end | ||
|
||
private | ||
|
||
def connection | ||
@connection ||= create_connection | ||
end | ||
private | ||
|
||
def open(config) | ||
connection_string = get_connection_string(config) | ||
connection.Open(connection_string) if connection_closed? | ||
end | ||
|
||
def get_connection_string(config) | ||
params = { | ||
'Provider' => 'SQLNCLI11', | ||
'Initial Catalog' => config[:database] || 'master', | ||
'Application Name' => 'Puppet', | ||
'Data Source' => '.', | ||
'DataTypeComptibility' => 80, | ||
} | ||
|
||
admin_user = config[:admin_user] || '' | ||
admin_pass = config[:admin_pass] || '' | ||
|
||
if config[:admin_login_type] == 'WINDOWS_LOGIN' | ||
# Windows based authentication | ||
raise ArgumentError, _('admin_user must be empty or nil') unless admin_user == '' | ||
raise ArgumentError, _('admin_pass must be empty or nil') unless admin_pass == '' | ||
params.store('Integrated Security', 'SSPI') | ||
else | ||
# SQL Server based authentication | ||
raise ArgumentError, _('admin_user must not be empty or nil') unless admin_user != '' | ||
raise ArgumentError, _('admin_pass must not be empty or nil') unless admin_pass != '' | ||
params.store('User ID', admin_user) | ||
params.store('Password', admin_pass) | ||
def connection | ||
@connection ||= create_connection | ||
end | ||
|
||
if !config[:instance_name].nil? && config[:instance_name] !~ %r{^MSSQLSERVER$} | ||
params['Data Source'] = ".\\#{config[:instance_name]}" | ||
def open(config) | ||
connection_string = get_connection_string(config) | ||
connection.Open(connection_string) if connection_closed? | ||
end | ||
|
||
params.map { |k, v| "#{k}=#{v}" }.join(';') | ||
end | ||
def get_connection_string(config) | ||
params = { | ||
'Provider' => 'SQLNCLI11', | ||
'Initial Catalog' => config[:database] || 'master', | ||
'Application Name' => 'Puppet', | ||
'Data Source' => '.', | ||
'DataTypeComptibility' => 80, | ||
} | ||
|
||
admin_user = config[:admin_user] || '' | ||
admin_pass = config[:admin_pass] || '' | ||
|
||
if config[:admin_login_type] == 'WINDOWS_LOGIN' | ||
# Windows based authentication | ||
raise ArgumentError, _('admin_user must be empty or nil') unless admin_user == '' | ||
raise ArgumentError, _('admin_pass must be empty or nil') unless admin_pass == '' | ||
params.store('Integrated Security', 'SSPI') | ||
else | ||
# SQL Server based authentication | ||
raise ArgumentError, _('admin_user must not be empty or nil') unless admin_user != '' | ||
raise ArgumentError, _('admin_pass must not be empty or nil') unless admin_pass != '' | ||
params.store('User ID', admin_user) | ||
params.store('Password', admin_pass) | ||
end | ||
|
||
if !config[:instance_name].nil? && config[:instance_name] !~ %r{^MSSQLSERVER$} | ||
params['Data Source'] = ".\\#{config[:instance_name]}" | ||
end | ||
|
||
params.map { |k, v| "#{k}=#{v}" }.join(';') | ||
end | ||
|
||
def close | ||
connection.Close unless connection_closed? | ||
rescue win32_exception # rubocop:disable Lint/HandleExceptions | ||
end | ||
def close | ||
connection.Close unless connection_closed? | ||
rescue win32_exception # rubocop:disable Lint/HandleExceptions | ||
end | ||
|
||
def connection_closed? | ||
connection.State == CONNECTION_CLOSED | ||
end | ||
def connection_closed? | ||
connection.State == CONNECTION_CLOSED | ||
end | ||
|
||
def create_connection | ||
require 'win32ole' | ||
WIN32OLE.new('ADODB.Connection') | ||
end | ||
def create_connection | ||
require 'win32ole' | ||
WIN32OLE.new('ADODB.Connection') | ||
end | ||
|
||
def execute(sql) | ||
connection.Execute(sql, nil, nil) | ||
end | ||
def execute(sql) | ||
connection.Execute(sql, nil, nil) | ||
end | ||
|
||
def parse_column_names(result) | ||
result.Fields.extend(Enumerable).map(&:Name) | ||
end | ||
def parse_column_names(result) | ||
result.Fields.extend(Enumerable).map(&:Name) | ||
end | ||
|
||
# having as a method instead of hard coded allows us to stub and test outside of Windows | ||
def win32_exception | ||
::WIN32OLERuntimeError | ||
# having as a method instead of hard coded allows us to stub and test outside of Windows | ||
def win32_exception | ||
::WIN32OLERuntimeError | ||
end | ||
end | ||
end | ||
|
||
class ResultOutput # rubocop:disable Style/Documentation | ||
attr_reader :exitstatus, :error_message | ||
class ResultOutput # rubocop:disable Style/Documentation | ||
attr_reader :exitstatus, :error_message | ||
|
||
def initialize(has_errors, error_message, connection) | ||
@exitstatus = has_errors ? 1 : 0 | ||
def initialize(has_errors, error_message, connection) | ||
@exitstatus = has_errors ? 1 : 0 | ||
|
||
@error_message = extract_messages(connection) || error_message | ||
end | ||
@error_message = extract_messages(connection) || error_message | ||
end | ||
|
||
def extract_messages(connection) | ||
return nil if connection.nil? || connection.Errors.count.zero? | ||
def extract_messages(connection) | ||
return nil if connection.nil? || connection.Errors.count.zero? | ||
|
||
error_count = connection.Errors.count - 1 | ||
error_count = connection.Errors.count - 1 | ||
|
||
((0..error_count).map { |i| connection.Errors(i).Description.to_s }).join("\n") | ||
end | ||
((0..error_count).map { |i| connection.Errors(i).Description.to_s }).join("\n") | ||
end | ||
|
||
def has_errors # rubocop:disable Style/PredicateName | ||
@exitstatus != 0 | ||
def has_errors # rubocop:disable Style/PredicateName | ||
@exitstatus != 0 | ||
end | ||
end | ||
end | ||
end |
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,31 @@ | ||
default: | ||
provisioner: vagrant | ||
images: ['gusztavvargadr/windows-server'] | ||
release_checks_sql_2012: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64'] | ||
vars: 'sqlversion: sqlserver_2012' | ||
release_checks_sql_2014_parity: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64'] | ||
vars: 'sqlversion: sqlserver_2014' | ||
release_checks_sql_2014: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64'] | ||
vars: 'sqlversion: sqlserver_2014' | ||
release_checks_sql_2016_parity: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64', 'win-2016-x86_64'] | ||
vars: 'sqlversion: sqlserver_2016' | ||
release_checks_sql_2016: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64'] | ||
vars: 'sqlversion: sqlserver_2016' | ||
release_checks_sql_2017: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64'] | ||
vars: 'sqlversion: sqlserver_2017' | ||
release_checks_sql_2019: | ||
provisioner: vmpooler | ||
images: ['win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64'] | ||
vars: 'sqlversion: sqlserver_2019' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
More of a query because I was working with this gem recently - should they not be in all modules? I'm guessing the PDK removed 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.
It's still included in :development. :system_tests is just no longer a thing with litmus