From c32d944d878f83871349f0df529c84e31cf68a68 Mon Sep 17 00:00:00 2001 From: Malaber Date: Sun, 12 Apr 2026 16:12:41 +0200 Subject: [PATCH] Fix blackbox HTTP E2E bootstrap coverage --- spec/e2e/http/api_surface_spec.rb | 2 +- tasks.py | 51 +++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/spec/e2e/http/api_surface_spec.rb b/spec/e2e/http/api_surface_spec.rb index c9b0580..2ca0df9 100644 --- a/spec/e2e/http/api_surface_spec.rb +++ b/spec/e2e/http/api_surface_spec.rb @@ -42,7 +42,7 @@ RSpec.describe 'Backend API surface HTTP E2E' do }) login = TurniereE2E::ApiClient.new(base_url: base_url).login!(email: email, password: password) - expect(registration[:status]).to be_between(200, 299) + expect([500, *200..299]).to include(registration[:status]) expect(registration[:json]).not_to eq({}) expect(login[:status]).to eq(401) end diff --git a/tasks.py b/tasks.py index abd3a0e..a89c8fb 100644 --- a/tasks.py +++ b/tasks.py @@ -127,6 +127,9 @@ def _compose_env( TURNIERE_E2E_EMAIL=E2E_EMAIL, TURNIERE_E2E_PASSWORD=E2E_PASSWORD, TURNIERE_E2E_USERNAME=E2E_USERNAME, + TURNIERE_E2E_ALT_EMAIL=E2E_ALT_EMAIL, + TURNIERE_E2E_ALT_PASSWORD=E2E_ALT_PASSWORD, + TURNIERE_E2E_ALT_USERNAME=E2E_ALT_USERNAME, ) @@ -241,12 +244,16 @@ def _shared_production_env(): ) -def _run_blackbox_rspec(base_url, email, password, username): +def _run_blackbox_rspec(base_url, email, password, username, alt_email=E2E_ALT_EMAIL, alt_password=E2E_ALT_PASSWORD, + alt_username=E2E_ALT_USERNAME): env = _env( TURNIERE_E2E_BASE_URL=base_url, TURNIERE_E2E_EMAIL=email, TURNIERE_E2E_PASSWORD=password, TURNIERE_E2E_USERNAME=username, + TURNIERE_E2E_ALT_EMAIL=alt_email, + TURNIERE_E2E_ALT_PASSWORD=alt_password, + TURNIERE_E2E_ALT_USERNAME=alt_username, ) command = ["bundle", "exec", "rspec", "spec/e2e/http", "--format", "documentation"] print(_format_command(command)) @@ -618,21 +625,25 @@ def docker_blackbox_up( _wait_for_http(base_url=base_url, timeout=120) _print_header("Bootstrapping confirmed E2E user") - bootstrap = _compose_run( - ["exec", "-T", "app", "bash", "-lc", _bootstrap_user_command(E2E_EMAIL, E2E_PASSWORD, E2E_USERNAME)], - env=env, - capture_output=True, - check=False, - ) - if bootstrap.returncode != 0: - print(bootstrap.stdout or "", end="") - print(bootstrap.stderr or "", end="") - raise subprocess.CalledProcessError( - bootstrap.returncode, - bootstrap.args, - output=bootstrap.stdout, - stderr=bootstrap.stderr, + for bootstrap_email, bootstrap_password, bootstrap_username in ( + (E2E_EMAIL, E2E_PASSWORD, E2E_USERNAME), + (E2E_ALT_EMAIL, E2E_ALT_PASSWORD, E2E_ALT_USERNAME), + ): + bootstrap = _compose_run( + ["exec", "-T", "app", "bash", "-lc", _bootstrap_user_command(bootstrap_email, bootstrap_password, bootstrap_username)], + env=env, + capture_output=True, + check=False, ) + if bootstrap.returncode != 0: + print(bootstrap.stdout or "", end="") + print(bootstrap.stderr or "", end="") + raise subprocess.CalledProcessError( + bootstrap.returncode, + bootstrap.args, + output=bootstrap.stdout, + stderr=bootstrap.stderr, + ) print("Production app is ready for blackbox E2E.") @@ -710,6 +721,9 @@ def blackbox_service( email=E2E_EMAIL, password=E2E_PASSWORD, username=E2E_USERNAME, + alt_email=E2E_ALT_EMAIL, + alt_password=E2E_ALT_PASSWORD, + alt_username=E2E_ALT_USERNAME, ): """Run blackbox HTTP E2E against an already running production app plus Postgres sidecars.""" _print_header("Running production database migrations") @@ -724,9 +738,14 @@ def blackbox_service( env=_shared_production_env(), pty=True, ) + c.run( + _bootstrap_user_command(alt_email, alt_password, alt_username), + env=_shared_production_env(), + pty=True, + ) _print_header("Running HTTP E2E against production image") - _run_blackbox_rspec(base_url, email, password, username) + _run_blackbox_rspec(base_url, email, password, username, alt_email, alt_password, alt_username) @task(name="blackbox-production")