From ac6315fbe48cdbbc65d6a7b7ef2ddc6d411675c5 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:09:57 +0530 Subject: [PATCH] CAT-1208 : Fix CI to failures --- spec/acceptance/sqlserver_config_spec.rb | 7 ++++++- spec/spec_helper_acceptance_local.rb | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/sqlserver_config_spec.rb b/spec/acceptance/sqlserver_config_spec.rb index 6788563f..6bf9a8d3 100644 --- a/spec/acceptance/sqlserver_config_spec.rb +++ b/spec/acceptance/sqlserver_config_spec.rb @@ -21,9 +21,14 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present') security_mode => 'SQL', sa_pwd => 'Pupp3t1@', windows_feature_source => 'I:\\sources\\sxs', + install_switches => { + 'SkipInstallerRunCheck' => 'True', + }, } MANIFEST - apply_manifest(pp, catch_failures: true) + retry_on_error_matching(10, 5, %r{apply manifest failed}) do + apply_manifest(pp, catch_failures: true) + end end context 'Testing sqlserver::config' do diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 7d46cc36..18a9767f 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -21,6 +21,19 @@ class Helper SQL_ADMIN_PASS = 'Pupp3t1@' USER = Helper.instance.run_shell('$env:UserName').stdout.chomp +def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, error_matcher = nil) + try = 0 + begin + try += 1 + yield + rescue StandardError => e + raise unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher) + + sleep retry_wait_interval_secs + retry + end +end + RSpec.configure do |c| c.before(:suite) do Helper.instance.run_shell('puppet module install puppetlabs-mount_iso') @@ -81,7 +94,9 @@ def mount_iso(opts = {}) drive_letter => '#{drive_letter}', } MANIFEST - Helper.instance.apply_manifest(pp) + retry_on_error_matching(10, 5, %r{apply manifest failed}) do + Helper.instance.apply_manifest(pp) + end end def base_install(sql_version) @@ -152,7 +167,9 @@ def install_sqlserver(features) windows_feature_source => 'I:\\sources\\sxs', } MANIFEST - Helper.instance.apply_manifest(pp) + retry_on_error_matching(10, 5, %r{apply manifest failed}) do + Helper.instance.apply_manifest(pp) + end end def run_sql_query(opts = {}, &block)