Skip to content

(Maint) - Add nightly and PR testing #416

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 5 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ fixtures:
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'
mount_iso: 'https://github.com/puppetlabs/puppetlabs-mount_iso.git'
archive: 'https://github.com/voxpupuli/puppet-archive.git'
symlinks:
sqlserver: "#{source_dir}"
111 changes: 111 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: "nightly"

on:
schedule:
- cron: '0 0 * * *'

env:
SERVICE_URL: https://facade-maint-config-windows-use-ssh-6f3kfepqcq-ew.a.run.app/v1/provision

jobs:
setup_matrix:
name: "Setup Test Matrix"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}

steps:

- name: Checkout Source
uses: actions/checkout@v2
if: ${{ github.repository_owner == 'puppetlabs' }}

- name: Activate Ruby 2.7
uses: ruby/setup-ruby@v1
if: ${{ github.repository_owner == 'puppetlabs' }}
with:
ruby-version: "2.7"
bundler-cache: true

- name: Print bundle environment
if: ${{ github.repository_owner == 'puppetlabs' }}
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::

- name: Setup Acceptance Test Matrix
id: get-matrix
run: |
bundle exec matrix_from_metadata_v2
bundle exec matrix_from_metadata_v2

Acceptance:
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
needs:
- setup_matrix
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}


steps:

- name: Checkout Source
uses: actions/checkout@v2

- name: Activate Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
bundler-cache: true

- name: Print bundle environment
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::

- name: Provision test environment
run: |
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]"

- name: Install agent
run: |
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'

- name: Install module
run: |
bundle exec rake 'litmus:install_module'

- name: Authenitcate with GCP
run: |
echo '${{ secrets.GCP_CONNECTION }}' >> creds.json
bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
bundle exec bolt command run "gcloud auth activate-service-account --key-file C:\\creds.json" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Download OS ISO
run: |
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/windows/en_windows_server_2019_updated_july_2020_x64_dvd_94453821.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Download SQLServer ISO
run: |
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/puppetlabs-sqlserver/SQLServer2019CTP2.4-x64-ENU.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Set Environment Variable
run: |
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Run acceptance tests
run: |
bundle exec rake 'litmus:acceptance:parallel'

- name: Remove test environment
if: ${{ always() }}
continue-on-error: true
run: |
bundle exec rake 'litmus:tear_down'
109 changes: 109 additions & 0 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: "PR Testing"

on: [pull_request]

env:
SERVICE_URL: https://facade-maint-config-windows-use-ssh-6f3kfepqcq-ew.a.run.app/v1/provision

jobs:
setup_matrix:
name: "Setup Test Matrix"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}

steps:

- name: Checkout Source
uses: actions/checkout@v2
if: ${{ github.repository_owner == 'puppetlabs' }}

- name: Activate Ruby 2.7
uses: ruby/setup-ruby@v1
if: ${{ github.repository_owner == 'puppetlabs' }}
with:
ruby-version: "2.7"
bundler-cache: true

- name: Print bundle environment
if: ${{ github.repository_owner == 'puppetlabs' }}
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::

- name: Setup Acceptance Test Matrix
id: get-matrix
run: |
bundle exec matrix_from_metadata_v2
bundle exec matrix_from_metadata_v2

Acceptance:
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
needs:
- setup_matrix
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}


steps:

- name: Checkout Source
uses: actions/checkout@v2

- name: Activate Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
bundler-cache: true

- name: Print bundle environment
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::

- name: Provision test environment
run: |
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]"

- name: Install agent
run: |
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'

- name: Install module
run: |
bundle exec rake 'litmus:install_module'

- name: Authenitcate with GCP
run: |
echo '${{ secrets.GCP_CONNECTION }}' >> creds.json
bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
bundle exec bolt command run "gcloud auth activate-service-account --key-file C:\\creds.json" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Download OS ISO
run: |
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/windows/en_windows_server_2019_updated_july_2020_x64_dvd_94453821.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Download SQLServer ISO
run: |
bundle exec bolt command run 'gsutil -q cp gs://artifactory-modules/puppetlabs-sqlserver/SQLServer2019CTP2.4-x64-ENU.iso C:\\' --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Set Environment Variable
run: |
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml

- name: Run acceptance tests
run: |
bundle exec rake 'litmus:acceptance:parallel'

- name: Remove test environment
if: ${{ always() }}
continue-on-error: true
run: |
bundle exec rake 'litmus:tear_down'
3 changes: 2 additions & 1 deletion lib/puppet/provider/sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Puppet::Provider::Sqlserver < Puppet::Provider # rubocop:disable Style/Doc
end

def try_execute(command, msg = nil, obfuscate_strings = nil, acceptable_exit_codes = [0])
res = execute(command.compact, failonfail: false)
command&.compact
res = execute(command, failonfail: false)

unless acceptable_exit_codes.include?(res.exitstatus)
msg = "Failure occured when trying to install SQL Server #{@resource[:name]}" if msg.nil?
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/provider/sqlserver_features/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def modify_features(action, features)
'/IACCEPTSQLSERVERLICENSETERMS',
"/FEATURES=#{features.join(',')}"]
if action == 'install'
cmd_args << '/UPDATEENABLED=False'
if not_nil_and_not_empty?(@resource[:is_svc_account])
cmd_args << "/ISSVCACCOUNT=#{@resource[:is_svc_account]}"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/provider/sqlserver_instance/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def basic_cmd_args(features, action)
'/IACCEPTSQLSERVERLICENSETERMS',
"/INSTANCENAME=#{@resource[:name]}"]
cmd_args << "/FEATURES=#{features.join(',')}" unless features.empty?
cmd_args << '/UPDATEENABLED=False' if action == 'install'
cmd_args
end

def build_cmd_args(features, action = 'install')
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_x/sqlserver/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def self.get_shared_features(version)
'SDK_Full' => 'SDK', # Client Tools SDK
'MDSCoreFeature' => 'MDS', # Master Data Services
'Tools_Legacy_Full' => 'BC', # Client Tools Backwards Compatibility
'SQL_SSMS_Full' => 'ADV_SSMS', # Management Tools - Complete (Does not exist in SQL 2016)
'SQL_SSMS_Full' => 'ADV_SSMS', # Management Tools - Complete (Does not exist in SQL 2016+)
'SQL_SSMS_Adv' => 'SSMS', # Management Tools - Basic (Does not exist in SQL 2016)
'SQL_DQ_CLIENT_Full' => 'DQC', # Data Quality Client
'SQL_BOL_Components' => 'BOL', # Documentation Components
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet_x/sqlserver/sql_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def open(config)

def get_connection_string(config)
params = {
'Provider' => 'SQLNCLI11',
'Provider' => 'MSOLEDBSQL',
'Initial Catalog' => config[:database] || 'master',
'Application Name' => 'Puppet',
'Data Source' => '.',
Expand All @@ -50,8 +50,8 @@ def get_connection_string(config)
# 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)
params.store('UID', admin_user)
params.store('PWD', admin_pass)
end

if !config[:instance_name].nil? && config[:instance_name] !~ %r{^MSSQLSERVER$}
Expand Down
14 changes: 7 additions & 7 deletions spec/acceptance/sqlserver_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

describe 'sqlserver::config test' do
def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
user = Helper.instance.run_shell('$env:UserName').stdout.chomp
pp = <<-MANIFEST
sqlserver_instance{'#{inst_name}':
ensure => '#{ensure_val}',
source => 'H:',
features => ['DQ', 'FullText', 'Replication', 'SQLEngine'],
sql_sysadmin_accounts => ['Administrator'],
sql_sysadmin_accounts => ['#{user}'],
security_mode => 'SQL',
sa_pwd => 'Pupp3t1@',
windows_feature_source => 'I:\\sources\\sxs',
}
MANIFEST

apply_manifest(pp, catch_failures: true)
end

Expand All @@ -32,7 +32,7 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
ensure_sqlserver_instance(inst_name)

# get credentials for new config
@admin_user = 'admin' + SecureRandom.hex(2)
@admin_user = 'test_user' + SecureRandom.hex(2)
@admin_pass = 'Pupp3t1@'

# get database user
Expand All @@ -55,14 +55,14 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
instance => '#{inst_name}',
login_type => 'SQL_LOGIN',
login => '#{@admin_user}',
password => Sensitive('#{@admin_pass}'),
password => '#{@admin_pass}',
svrroles => {'sysadmin' => 1},
}
MANIFEST
apply_manifest(pp, catch_failures: true)
end

it 'Validate New Config WITH using instance_name in sqlserver::config' do
it 'Validate New Config WITH instance_name in sqlserver::config' do
pp = <<-MANIFEST
sqlserver::config{'#{inst_name}':
admin_user => Sensitive('#{@admin_user}'),
Expand All @@ -77,11 +77,11 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
end

it 'Validate new login and database actualy created' do
hostname = ENV['TARGET_HOST']
hostname = Helper.instance.run_shell('hostname').stdout.upcase.strip
query = "USE #{db_name}; SELECT * from master..sysdatabases WHERE name = '#{db_name}'"

run_sql_query(query: query, server: hostname, instance: inst_name, \
sql_admin_user: @admin_user, sql_admin_pass: @admin_pass, expected_row_count: 1)
sql_admin_user: @admin_user, sql_admin_pass: @admin_pass, expected_row_count: 1)
end

it 'Validate New Config WITHOUT using instance_name in sqlserver::config' do
Expand Down
Loading