@@ -105,6 +105,10 @@ task :intake => %i[
105
105
desc 'Run snapshot tests'
106
106
RSpec ::Core ::RakeTask . new ( 'beaker:snapshot' ) do |c |
107
107
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
108
112
end
109
113
task 'beaker:snapshot' => [
110
114
'artifacts:prep' ,
@@ -140,11 +144,17 @@ namespace :artifacts do
140
144
141
145
namespace :snapshot do
142
146
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 |
148
158
filename = artifact ( anchor . attr ( 'href' ) )
149
159
link = artifact ( "elasticsearch-snapshot.#{ anchor . text . split ( ' ' ) . first . downcase } " )
150
160
checksum = filename + '.sha1'
@@ -166,6 +176,7 @@ namespace :artifacts do
166
176
File . delete checksum if File . exist? checksum
167
177
get "#{ anchor . attr ( 'href' ) } .sha1" , checksum
168
178
end
179
+ end
169
180
end
170
181
end
171
182
0 commit comments