Skip to content

Commit 1eb41d4

Browse files
committed
testing: skip snapshot tests for non-existent artifacts
1 parent 7de964c commit 1eb41d4

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Rakefile

+16-5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ task :intake => %i[
105105
desc 'Run snapshot tests'
106106
RSpec::Core::RakeTask.new('beaker:snapshot') do |c|
107107
c.pattern = 'spec/acceptance/snapshot.rb'
108+
if Rake::Task.task_defined? 'artifacts:snapshot:not_found'
109+
puts 'No snapshot artifacts found, skipping snapshot tests.'
110+
exit(0)
111+
end
108112
end
109113
task 'beaker:snapshot' => [
110114
'artifacts:prep',
@@ -140,11 +144,17 @@ namespace :artifacts do
140144

141145
namespace :snapshot do
142146
dls = Nokogiri::HTML(open('https://www.elastic.co/downloads/elasticsearch'))
143-
dls
144-
.at_css('#preview-release-id')
145-
.at_css('.downloads')
146-
.xpath('li/a[contains(text(), "rpm") or contains(text(), "deb")]')
147-
.each do |anchor|
147+
div = dls.at_css('#preview-release-id')
148+
149+
if div.nil?
150+
puts 'No preview release available; skipping snapshot download'
151+
%w[deb rpm].each { |ext| task ext }
152+
task 'not_found'
153+
else
154+
div
155+
.at_css('.downloads')
156+
.xpath('li/a[contains(text(), "rpm") or contains(text(), "deb")]')
157+
.each do |anchor|
148158
filename = artifact(anchor.attr('href'))
149159
link = artifact("elasticsearch-snapshot.#{anchor.text.split(' ').first.downcase}")
150160
checksum = filename + '.sha1'
@@ -166,6 +176,7 @@ namespace :artifacts do
166176
File.delete checksum if File.exist? checksum
167177
get "#{anchor.attr('href')}.sha1", checksum
168178
end
179+
end
169180
end
170181
end
171182

0 commit comments

Comments
 (0)