Skip to content

Commit

Permalink
Merge pull request #8224 from DavidKang/bootstrap/circle-ci/spider-test
Browse files Browse the repository at this point in the history
 Run spider test in the new UI
  • Loading branch information
vpereira committed Sep 2, 2019
2 parents 1c55c79 + d69884a commit d5e33e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ jobs:
- run: *bootstrap_old_test_suite
- run:
name: Run spider
command: cd src/api; bundle exec rake test:spider
command: |
cd src/api
bundle exec rake test:spider
- <<: *store_minitest_artefacts

backend_test:
Expand Down
35 changes: 8 additions & 27 deletions src/api/test/functional/webui/spider_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
require 'benchmark'
require 'nokogiri'

# TODO: Remove this when switch_to_webui2 is removed
ENV['BOOTSTRAP'] = '1'

class Webui::SpiderTest < Webui::IntegrationTest
def getlinks(baseuri, body)
# skip some uninteresting projects
Expand Down Expand Up @@ -52,30 +55,8 @@ def getlinks(baseuri, body)

def raiseit(message, url)
# known issues
return if url =~ %r{/package/binary/BinaryprotectedProject/.*}
return if url =~ %r{/package/binary/download/*}
return if url =~ %r{/package/statistics/BinaryprotectedProject/.*}
return if url =~ %r{/package/statistics/SourceprotectedProject/.*}
return if url.end_with?('/package/binary/SourceprotectedProject/pack?arch=i586&filename=package-1.0-1.src.rpm&repository=repo')
return if url =~ %r{/package/revisions/SourceprotectedProject.*}
return if url.end_with?('/package/show/kde4/kdelibs?rev=1')
return if url.end_with?('/package/show/SourceprotectedProject/target')
return if url.end_with?('/package/users/SourceprotectedProject/pack')
return if url.end_with?('/package/view_file/BaseDistro:Update/pack2?file=my_file&rev=1')
return if url.end_with?('/package/view_file/Devel:BaseDistro:Update/pack2?file=my_file&rev=1')
return if url.end_with?('/package/view_file/Devel:BaseDistro:Update/Pack3?file=my_file&rev=1')
return if url.end_with?('/package/view_file/LocalProject/remotepackage?file=my_file&rev=1')
return if url.end_with?('/package/view_file/BaseDistro2.0:LinkedUpdateProject/pack2.linked?file=myfile&rev=1')
return if url.end_with?('/package/view_file/BaseDistro2.0/pack2.linked?file=myfile&rev=1')
return if url.end_with?('/package/view_file/BaseDistro2.0:LinkedUpdateProject/pack2.linked?file=package.spec&rev=1')
return if url.end_with?('/package/view_file/BaseDistro2.0/pack2.linked?file=package.spec&rev=1')
return if url.end_with?('/project/edit/RemoteInstance')
return if url.end_with?('/project/meta/HiddenRemoteInstance')
return if url.end_with?('/project/show/HiddenRemoteInstance')
return if url.end_with?('/project/edit/HiddenRemoteInstance')
return if url.end_with?('/user/show/unknown')
return if url.end_with?('/user/show/deleted')
return if url =~ %r{/source/}
return if url.end_with?('/request/add_reviewer_dialog?number=10')

warn "Found #{message} on #{url}, crawling path"
indent = ' '
Expand Down Expand Up @@ -105,7 +86,7 @@ def crawl
# puts "ignoring #{page.response_headers.inspect}"
next
end
page.first(:id, 'header-logo')
page.first('.navbar-brand')
rescue Timeout::Error
next
rescue ActionController::RoutingError
Expand All @@ -119,7 +100,7 @@ def crawl
# puts "HARDCORE!! #{theone}"
end
next unless body
flashes = body.css('div#flash-messages div.ui-state-error')
flashes = body.css('div#flash div.alert-error')
unless flashes.empty?
raiseit("flash alert #{flashes.first.content.strip}", theone)
end
Expand Down Expand Up @@ -150,7 +131,7 @@ def test_spider_anonymously
crawl
ActiveRecord::Base.clear_active_connections!

@pages_visited.keys.length.must_be :>, 490
@pages_visited.keys.length.must_be :>, 345
end

def test_spider_as_admin
Expand All @@ -161,6 +142,6 @@ def test_spider_as_admin
crawl
ActiveRecord::Base.clear_active_connections!

@pages_visited.keys.length.must_be :>, 900
@pages_visited.keys.length.must_be :>, 439
end
end

0 comments on commit d5e33e4

Please sign in to comment.