Skip to content

Commit f9a3dd2

Browse files
authored
Merge pull request #416 from puppetlabs/maint-add_nightly_pr_testing
2 parents 460d0af + 6307065 commit f9a3dd2

20 files changed

+323
-69
lines changed

.fixtures.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ fixtures:
44
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
55
provision: 'https://github.com/puppetlabs/provision.git'
66
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
7+
mount_iso: 'https://github.com/puppetlabs/puppetlabs-mount_iso.git'
8+
archive: 'https://github.com/voxpupuli/puppet-archive.git'
79
symlinks:
810
sqlserver: "#{source_dir}"

.github/workflows/nightly.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: "nightly"
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
env:
8+
SERVICE_URL: https://facade-maint-config-windows-use-ssh-6f3kfepqcq-ew.a.run.app/v1/provision
9+
10+
jobs:
11+
setup_matrix:
12+
name: "Setup Test Matrix"
13+
runs-on: ubuntu-latest
14+
outputs:
15+
matrix: ${{ steps.get-matrix.outputs.matrix }}
16+
17+
steps:
18+
19+
- name: Checkout Source
20+
uses: actions/checkout@v2
21+
if: ${{ github.repository_owner == 'puppetlabs' }}
22+
23+
- name: Activate Ruby 2.7
24+
uses: ruby/setup-ruby@v1
25+
if: ${{ github.repository_owner == 'puppetlabs' }}
26+
with:
27+
ruby-version: "2.7"
28+
bundler-cache: true
29+
30+
- name: Print bundle environment
31+
if: ${{ github.repository_owner == 'puppetlabs' }}
32+
run: |
33+
echo ::group::bundler environment
34+
bundle env
35+
echo ::endgroup::
36+
37+
- name: Setup Acceptance Test Matrix
38+
id: get-matrix
39+
run: |
40+
bundle exec matrix_from_metadata_v2
41+
bundle exec matrix_from_metadata_v2
42+
43+
Acceptance:
44+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
45+
needs:
46+
- setup_matrix
47+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
48+
49+
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
53+
54+
55+
steps:
56+
57+
- name: Checkout Source
58+
uses: actions/checkout@v2
59+
60+
- name: Activate Ruby 2.7
61+
uses: ruby/setup-ruby@v1
62+
with:
63+
ruby-version: "2.7"
64+
bundler-cache: true
65+
66+
- name: Print bundle environment
67+
run: |
68+
echo ::group::bundler environment
69+
bundle env
70+
echo ::endgroup::
71+
72+
- name: Provision test environment
73+
run: |
74+
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]"
75+
76+
- name: Install agent
77+
run: |
78+
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
79+
80+
- name: Install module
81+
run: |
82+
bundle exec rake 'litmus:install_module'
83+
84+
- name: Authenitcate with GCP
85+
run: |
86+
echo '${{ secrets.GCP_CONNECTION }}' >> creds.json
87+
bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
88+
bundle exec bolt command run "gcloud auth activate-service-account --key-file C:\\creds.json" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
89+
90+
- name: Download OS ISO
91+
run: |
92+
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
93+
94+
- name: Download SQLServer ISO
95+
run: |
96+
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
97+
98+
- name: Set Environment Variable
99+
run: |
100+
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
101+
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
102+
103+
- name: Run acceptance tests
104+
run: |
105+
bundle exec rake 'litmus:acceptance:parallel'
106+
107+
- name: Remove test environment
108+
if: ${{ always() }}
109+
continue-on-error: true
110+
run: |
111+
bundle exec rake 'litmus:tear_down'

.github/workflows/pr_test.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: "PR Testing"
2+
3+
on: [pull_request]
4+
5+
env:
6+
SERVICE_URL: https://facade-maint-config-windows-use-ssh-6f3kfepqcq-ew.a.run.app/v1/provision
7+
8+
jobs:
9+
setup_matrix:
10+
name: "Setup Test Matrix"
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.get-matrix.outputs.matrix }}
14+
15+
steps:
16+
17+
- name: Checkout Source
18+
uses: actions/checkout@v2
19+
if: ${{ github.repository_owner == 'puppetlabs' }}
20+
21+
- name: Activate Ruby 2.7
22+
uses: ruby/setup-ruby@v1
23+
if: ${{ github.repository_owner == 'puppetlabs' }}
24+
with:
25+
ruby-version: "2.7"
26+
bundler-cache: true
27+
28+
- name: Print bundle environment
29+
if: ${{ github.repository_owner == 'puppetlabs' }}
30+
run: |
31+
echo ::group::bundler environment
32+
bundle env
33+
echo ::endgroup::
34+
35+
- name: Setup Acceptance Test Matrix
36+
id: get-matrix
37+
run: |
38+
bundle exec matrix_from_metadata_v2
39+
bundle exec matrix_from_metadata_v2
40+
41+
Acceptance:
42+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
43+
needs:
44+
- setup_matrix
45+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
46+
47+
runs-on: ubuntu-latest
48+
strategy:
49+
fail-fast: false
50+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
51+
52+
53+
steps:
54+
55+
- name: Checkout Source
56+
uses: actions/checkout@v2
57+
58+
- name: Activate Ruby 2.7
59+
uses: ruby/setup-ruby@v1
60+
with:
61+
ruby-version: "2.7"
62+
bundler-cache: true
63+
64+
- name: Print bundle environment
65+
run: |
66+
echo ::group::bundler environment
67+
bundle env
68+
echo ::endgroup::
69+
70+
- name: Provision test environment
71+
run: |
72+
bundle exec rake "litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]"
73+
74+
- name: Install agent
75+
run: |
76+
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
77+
78+
- name: Install module
79+
run: |
80+
bundle exec rake 'litmus:install_module'
81+
82+
- name: Authenitcate with GCP
83+
run: |
84+
echo '${{ secrets.GCP_CONNECTION }}' >> creds.json
85+
bundle exec bolt file upload creds.json C:\\creds.json --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
86+
bundle exec bolt command run "gcloud auth activate-service-account --key-file C:\\creds.json" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
87+
88+
- name: Download OS ISO
89+
run: |
90+
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
91+
92+
- name: Download SQLServer ISO
93+
run: |
94+
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
95+
96+
- name: Set Environment Variable
97+
run: |
98+
pass=`grep -oP '(?<=password: ).*' spec/fixtures/litmus_inventory.yaml`
99+
bundle exec bolt command run "[Environment]::SetEnvironmentVariable('pass', '$pass', 'Machine')" --targets ssh_nodes --inventoryfile spec/fixtures/litmus_inventory.yaml
100+
101+
- name: Run acceptance tests
102+
run: |
103+
bundle exec rake 'litmus:acceptance:parallel'
104+
105+
- name: Remove test environment
106+
if: ${{ always() }}
107+
continue-on-error: true
108+
run: |
109+
bundle exec rake 'litmus:tear_down'

lib/puppet/provider/sqlserver.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class Puppet::Provider::Sqlserver < Puppet::Provider # rubocop:disable Style/Doc
1919
end
2020

2121
def try_execute(command, msg = nil, obfuscate_strings = nil, acceptable_exit_codes = [0])
22-
res = execute(command.compact, failonfail: false)
22+
command&.compact
23+
res = execute(command, failonfail: false)
2324

2425
unless acceptable_exit_codes.include?(res.exitstatus)
2526
msg = "Failure occured when trying to install SQL Server #{@resource[:name]}" if msg.nil?

lib/puppet/provider/sqlserver_features/mssql.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def modify_features(action, features)
6565
'/IACCEPTSQLSERVERLICENSETERMS',
6666
"/FEATURES=#{features.join(',')}"]
6767
if action == 'install'
68+
cmd_args << '/UPDATEENABLED=False'
6869
if not_nil_and_not_empty?(@resource[:is_svc_account])
6970
cmd_args << "/ISSVCACCOUNT=#{@resource[:is_svc_account]}"
7071
end

lib/puppet/provider/sqlserver_instance/mssql.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def basic_cmd_args(features, action)
142142
'/IACCEPTSQLSERVERLICENSETERMS',
143143
"/INSTANCENAME=#{@resource[:name]}"]
144144
cmd_args << "/FEATURES=#{features.join(',')}" unless features.empty?
145+
cmd_args << '/UPDATEENABLED=False' if action == 'install'
146+
cmd_args
145147
end
146148

147149
def build_cmd_args(features, action = 'install')

lib/puppet_x/sqlserver/features.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def self.get_shared_features(version)
149149
'SDK_Full' => 'SDK', # Client Tools SDK
150150
'MDSCoreFeature' => 'MDS', # Master Data Services
151151
'Tools_Legacy_Full' => 'BC', # Client Tools Backwards Compatibility
152-
'SQL_SSMS_Full' => 'ADV_SSMS', # Management Tools - Complete (Does not exist in SQL 2016)
152+
'SQL_SSMS_Full' => 'ADV_SSMS', # Management Tools - Complete (Does not exist in SQL 2016+)
153153
'SQL_SSMS_Adv' => 'SSMS', # Management Tools - Basic (Does not exist in SQL 2016)
154154
'SQL_DQ_CLIENT_Full' => 'DQC', # Data Quality Client
155155
'SQL_BOL_Components' => 'BOL', # Documentation Components

lib/puppet_x/sqlserver/sql_connection.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def open(config)
3131

3232
def get_connection_string(config)
3333
params = {
34-
'Provider' => 'SQLNCLI11',
34+
'Provider' => 'MSOLEDBSQL',
3535
'Initial Catalog' => config[:database] || 'master',
3636
'Application Name' => 'Puppet',
3737
'Data Source' => '.',
@@ -50,8 +50,8 @@ def get_connection_string(config)
5050
# SQL Server based authentication
5151
raise ArgumentError, _('admin_user must not be empty or nil') unless admin_user != ''
5252
raise ArgumentError, _('admin_pass must not be empty or nil') unless admin_pass != ''
53-
params.store('User ID', admin_user)
54-
params.store('Password', admin_pass)
53+
params.store('UID', admin_user)
54+
params.store('PWD', admin_pass)
5555
end
5656

5757
if !config[:instance_name].nil? && config[:instance_name] !~ %r{^MSSQLSERVER$}

spec/acceptance/sqlserver_config_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
describe 'sqlserver::config test' do
1313
def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
14+
user = Helper.instance.run_shell('$env:UserName').stdout.chomp
1415
pp = <<-MANIFEST
1516
sqlserver_instance{'#{inst_name}':
1617
ensure => '#{ensure_val}',
1718
source => 'H:',
1819
features => ['DQ', 'FullText', 'Replication', 'SQLEngine'],
19-
sql_sysadmin_accounts => ['Administrator'],
20+
sql_sysadmin_accounts => ['#{user}'],
2021
security_mode => 'SQL',
2122
sa_pwd => 'Pupp3t1@',
2223
windows_feature_source => 'I:\\sources\\sxs',
2324
}
2425
MANIFEST
25-
2626
apply_manifest(pp, catch_failures: true)
2727
end
2828

@@ -32,7 +32,7 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
3232
ensure_sqlserver_instance(inst_name)
3333

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

3838
# get database user
@@ -55,14 +55,14 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
5555
instance => '#{inst_name}',
5656
login_type => 'SQL_LOGIN',
5757
login => '#{@admin_user}',
58-
password => Sensitive('#{@admin_pass}'),
58+
password => '#{@admin_pass}',
5959
svrroles => {'sysadmin' => 1},
6060
}
6161
MANIFEST
6262
apply_manifest(pp, catch_failures: true)
6363
end
6464

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

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

8383
run_sql_query(query: query, server: hostname, instance: inst_name, \
84-
sql_admin_user: @admin_user, sql_admin_pass: @admin_pass, expected_row_count: 1)
84+
sql_admin_user: @admin_user, sql_admin_pass: @admin_pass, expected_row_count: 1)
8585
end
8686

8787
it 'Validate New Config WITHOUT using instance_name in sqlserver::config' do

0 commit comments

Comments
 (0)