Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #381 from alphagov/webdrivers-tlc
Browse files Browse the repository at this point in the history
Some TLC
  • Loading branch information
kevindew committed May 6, 2020
2 parents 48dabe9 + 0bd885d commit 2203547
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 120 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ inherit_gem:
inherit_mode:
merge:
- Exclude

AllCops:
Exclude:
- "apps/**/*"
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
FROM ruby:2.6.6
RUN apt-get update -qq && apt-get upgrade -y

RUN curl -sL https://deb.nodesource.com/setup_9.x | bash -
RUN apt-get install -y build-essential libpq-dev libxml2-dev libxslt1-dev \
libfontconfig1 libfontconfig1-dev nodejs unzip xvfb

# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
Expand Down
87 changes: 52 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,112 +1,129 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.0)
backticks (1.0.2)
byebug (11.0.1)
capybara (3.29.0)
byebug (11.1.3)
capybara (3.32.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
capybara-screenshot (1.0.23)
capybara-screenshot (1.0.24)
capybara (>= 1.0, < 4)
launchy
capybara-select2 (1.0.1)
capybara
rspec
childprocess (3.0.0)
concurrent-ruby (1.1.5)
concurrent-ruby (1.1.6)
diff-lcs (1.3)
docker-api (1.34.2)
excon (>= 0.47.0)
multi_json
docker-compose (1.1.12)
backticks (~> 1.0)
excon (0.72.0)
excon (0.73.0)
faker (1.9.6)
i18n (>= 0.7)
httparty (0.17.1)
httparty (0.18.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.7.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
launchy (2.4.3)
addressable (~> 2.3)
mime-types (3.3)
launchy (2.5.0)
addressable (~> 2.7)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mime-types-data (3.2020.0425)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
multi_json (1.14.1)
multi_xml (0.6.0)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
parallel (1.19.0)
parallel_tests (2.29.2)
parallel (1.19.1)
parallel_tests (2.32.0)
parallel
parser (2.7.0.4)
parser (2.7.1.2)
ast (~> 2.4.0)
plek (2.1.1)
ptools (1.3.5)
public_suffix (4.0.1)
public_suffix (4.0.4)
rack (2.2.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rainbow (3.0.0)
rake (13.0.1)
regexp_parser (1.6.0)
rotp (5.1.0)
addressable (~> 2.5)
regexp_parser (1.7.0)
rexml (3.2.4)
rotp (6.0.0)
addressable (~> 2.7)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
rspec-support (3.9.3)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.77.0)
rubocop (0.82.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-govuk (2.0.0)
rubocop (= 0.77)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-govuk (3.8.0)
rubocop (= 0.82.0)
rubocop-rails (~> 2)
rubocop-rake (~> 0.5.1)
rubocop-rspec (~> 1.28)
rubocop-rails (2.4.2)
rubocop-rails (2.5.2)
activesupport
rack (>= 1.1)
rubocop (>= 0.72.0)
rubocop-rspec (1.38.1)
rubocop-rake (0.5.1)
rubocop
rubocop-rspec (1.39.0)
rubocop (>= 0.68.1)
ruby-progressbar (1.10.1)
rubyzip (2.0.0)
selenium-webdriver (3.142.6)
rubyzip (2.3.0)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
unicode-display_width (1.6.1)
webdrivers (4.1.3)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
webdrivers (4.3.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.3.0)

PLATFORMS
ruby
Expand Down
20 changes: 9 additions & 11 deletions diet-error-handler/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
handle_notice(notice)

status 201
json Hash.new
json({})
end

# Airbrake/Errbit v3 endpoint - DEPRECATED
Expand All @@ -42,15 +42,13 @@
# Airbrake/Errbit v2 endpoint - DEPRECATED
# @TODO remove this and associated code when no apps use errbit
post "/notifier_api/v2/notices" do
begin
notice = Notice.from_v2(request.body.read.to_s)
handle_notice(notice)
status 200
body "Success"
rescue Nokogiri::XML::SyntaxError
status 422
body "The provided XML was not well formed"
end
notice = Notice.from_v2(request.body.read.to_s)
handle_notice(notice)
status 200
body "Success"
rescue Nokogiri::XML::SyntaxError
status 422
body "The provided XML was not well formed"
end

def decompress_body(body)
Expand Down Expand Up @@ -79,7 +77,7 @@ def write_to_log(notice)
timestamp: notice.timestamp,
errors: notice.errors.map { |e| e.merge(message: abridged_message(e[:message])) },
context: notice.context,
}
}
File.open(ERROR_LOG, "a") { |f| f << abridged_notice.to_yaml }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/retry_while_false.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class RetryWhileFalse
## Inspired by (/copied from) https://github.com/natritmeyer/site_prism/blob/master/lib/site_prism/waiter.rb
def self.call(reload_seconds: 30, interval_seconds: nil)
start_time = Time.now.utc
interval_seconds = interval_seconds || 0.5
interval_seconds ||= 0.5
loop do
return true if yield
break unless Time.now.utc - start_time <= reload_seconds
Expand Down
16 changes: 11 additions & 5 deletions lib/tasks/docker.rake
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
require_relative "../docker_service"

namespace :docker do
desc "Wait until database containers are indicating they are healthy"
task :wait_for_dbs do
DockerService.wait_for_healthy_services(services: %w(elasticsearch6 mongo mysql postgres redis))
DockerService.wait_for_healthy_services(services: %w[elasticsearch6 mongo mysql postgres redis])
end

desc "Wait for the RabbitMQ container to indicate it is healthy"
task :wait_for_rabbitmq do
DockerService.wait_for_healthy_services(services: %w(rabbitmq))
DockerService.wait_for_healthy_services(services: %w[rabbitmq])
end

desc "Wait for the Publishing API container to indicate it is healthy"
task :wait_for_publishing_api do
DockerService.wait_for_healthy_services(services: %w(publishing-api))
DockerService.wait_for_healthy_services(services: %w[publishing-api])
end

desc "Wait for the Whitheall Admin container to indicate it is healthy"
task :wait_for_whitehall_admin do
DockerService.wait_for_healthy_services(services: %w(whitehall-admin), reload_seconds: 180)
DockerService.wait_for_healthy_services(services: %w[whitehall-admin], reload_seconds: 180)
end

desc "Wait for all apps to indicate they are healthy"
task :wait_for_apps do
DockerService.wait_for_healthy_services(except: %w(publishing-e2e-tests))
DockerService.wait_for_healthy_services(except: %w[publishing-e2e-tests])
end

desc "Remove images built locally for this run"
task :remove_built_app_images do
removed_images = DockerService.remove_built_app_images
puts "Removed #{removed_images.join(',')}" unless removed_images.empty?
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/govuk.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require "plek"
require_relative "../retry_while_false"

namespace :govuk do
desc "Wait until router is serving routes that are non server errors"
task :wait_for_router do
outcome = RetryWhileFalse.call(reload_seconds: 60, interval_seconds: 1) do
live = HTTParty.head(Plek.find("www")).code
Expand Down
102 changes: 50 additions & 52 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
require "selenium-webdriver"
require "webdrivers"

Dir["./spec/support/*.rb"].each { |f| require f }
Dir["./spec/support/*.rb"].sort.each { |f| require f }

RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
Expand Down Expand Up @@ -61,57 +61,55 @@

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
# is tagged with `:focus`, all examples get run. RSpec also provides
# aliases for `it`, `describe`, and `context` that include `:focus`
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
config.filter_run_when_matching :focus
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
config.disable_monkey_patching!
# This setting enables warnings. It's recommended, but in some cases may
# be too noisy due to issues in dependencies.
config.warnings = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
# # This allows you to limit a spec run to individual examples or groups
# # you care about by tagging them with `:focus` metadata. When nothing
# # is tagged with `:focus`, all examples get run. RSpec also provides
# # aliases for `it`, `describe`, and `context` that include `:focus`
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
# config.filter_run_when_matching :focus
#
# # Allows RSpec to persist some state between runs in order to support
# # the `--only-failures` and `--next-failure` CLI options. We recommend
# # you configure your source control system to ignore this file.
# config.example_status_persistence_file_path = "spec/examples.txt"
#
# # Limits the available syntax to the non-monkey patched syntax that is
# # recommended. For more details, see:
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
# config.disable_monkey_patching!
#
# # This setting enables warnings. It's recommended, but in some cases may
# # be too noisy due to issues in dependencies.
# config.warnings = true
#
# # Many RSpec users commonly either run the entire suite or an individual
# # file, and it's useful to allow more verbose output when running an
# # individual spec file.
# if config.files_to_run.one?
# # Use the documentation formatter for detailed output,
# # unless a formatter has already been configured
# # (e.g. via a command-line flag).
# config.default_formatter = 'doc'
# end
#
# # Print the 10 slowest examples and example groups at the
# # end of the spec run, to help surface which specs are running
# # particularly slow.
# config.profile_examples = 10
#
# # Run specs in random order to surface order dependencies. If you find an
# # order dependency and want to debug it, you can fix the order by providing
# # the seed, which is printed after each run.
# # --seed 1234
# config.order = :random
#
# # Seed global randomization in this process using the `--seed` CLI option.
# # Setting this allows you to use `--seed` to deterministically reproduce
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed

config.add_setting :reload_page_wait_time, default: 60
end
Expand Down
Loading

0 comments on commit 2203547

Please sign in to comment.