diff --git a/cookbooks/aws-parallelcluster-environment/test/controls/lustre_spec.rb b/cookbooks/aws-parallelcluster-environment/test/controls/lustre_spec.rb index 0d1f5b707..616ed9fc5 100644 --- a/cookbooks/aws-parallelcluster-environment/test/controls/lustre_spec.rb +++ b/cookbooks/aws-parallelcluster-environment/test/controls/lustre_spec.rb @@ -19,10 +19,12 @@ its('version') { should cmp >= minimal_lustre_client_version } end - describe yum.repo('aws-fsx') do - it { should exist } - it { should be_enabled } - its('baseurl') { should include 'fsx-lustre-client-repo.s3.amazonaws.com' } + with_retry(retries: 3, delay: 5) do + describe yum.repo('aws-fsx') do + it { should exist } + it { should be_enabled } + its('baseurl') { should include 'fsx-lustre-client-repo.s3.amazonaws.com' } + end end end end @@ -47,10 +49,12 @@ its('version') { should cmp >= minimal_lustre_client_version } end - describe yum.repo('aws-fsx') do - it { should exist } - it { should be_enabled } - its('baseurl') { should include 'fsx-lustre-client-repo.s3.amazonaws.com' } + with_retry(retries: 3, delay: 5) do + describe yum.repo('aws-fsx') do + it { should exist } + it { should be_enabled } + its('baseurl') { should include 'fsx-lustre-client-repo.s3.amazonaws.com' } + end end end end diff --git a/cookbooks/aws-parallelcluster-shared/test/libraries/retry_helper.rb b/cookbooks/aws-parallelcluster-shared/test/libraries/retry_helper.rb new file mode 100644 index 000000000..618c32a55 --- /dev/null +++ b/cookbooks/aws-parallelcluster-shared/test/libraries/retry_helper.rb @@ -0,0 +1,15 @@ +# Helper method to retry flaky InSpec checks +def with_retry(retries: 3, delay: 5) + attempts = 0 + begin + attempts += 1 + yield + rescue => e + if attempts < retries + sleep delay + retry + else + raise e + end + end +end