Fix feature specs locally when host is not localhost
What does this merge request do and why?
This MR fixes an issue where feature specs sometimes fail locally because the hot module reloader address is not allowed by the CSP. This happens when the hostname is changed from localhost
.
Fixes #1875 (closed)
How to set up and validate locally
-
Ensure your
gdk.yml
is using ahostname
other thanlocalhost
. -
Check out this merge request's branch.
-
Run
gdk reconfigure
to check if regenerating all configuration is successful.The below shows what will happen if your hostname is
gdk.test
(though I only ran the part of reconfigure that this MR affects):➜ gdk git:(main) ✗ make gitlab/config/gitlab.yml ℹ️ 'gitlab/config/gitlab.yml' has incoming changes: ------------------------------------------------------------------------------------------------------------- @@ -971,6 +971,10 @@ test: host: localhost port: 80 + content_security_policy: + directives: + connect_src: "'self' http://localhost:* ws://localhost:* wss://localhost:* ws://gdk.test:* wss://gdk.test:*" + # When you run tests we clone and set up gitlab-shell # In order to set it up correctly you need to specify # your system username you use to run GitLab ------------------------------------------------------------------------------------------------------------- ⚠️ WARNING: 'gitlab/config/gitlab.yml' has been overwritten. To recover the previous version, run: cp -f '/Users/mkozonogitlab/Developer/gdk/.backups/gitlab__config__gitlab.yml.20230630120407' \ '/Users/mkozonogitlab/Developer/gdk/gitlab/config/gitlab.yml' If you want to protect this file from being overwritten, see: https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/configuration.md#overwriting-configuration-files -------------------------------------------------------------------------------------------------------------
-
In the gitlab directory, run an affected feature spec like
bin/rspec ee/spec/features/projects/new_project_spec.rb:150
It should succeed like this:
➜ gitlab git:(mk/add-3k-backup-runbook) ✗ bin/rspec ee/spec/features/projects/new_project_spec.rb:150 [TEST PROF INFO] Spring detected Running via Spring preloader in process 24277 Run options: include {:focus=>true, :locations=>{"./ee/spec/features/projects/new_project_spec.rb"=>[150]}} Test environment set up in 5.93115 seconds Starting the Capybara driver server... 2023-06-30 11:58:01 WARN Selenium [:logger_info] Details on how to use and modify Selenium logger: https://selenium.dev/documentation/webdriver/troubleshooting/logging#ruby 2023-06-30 11:58:01 WARN Selenium applicable driver not found; attempting to install with Selenium Manager Capybara starting Puma... * Version 6.3.0 , codename: Mugi No Toki Itaru * Min threads: 0, max threads: 4 * Listening on unix:///var/folders/42/22jv0xts5730z1h5clsrr8wh0000gn/T/20230630-24277-v1k7mt . Finished in 25.66 seconds (files took 1.78 seconds to load) 1 example, 0 failures [TEST PROF INFO] Time spent in factories: 00:00.618 (2.27% of total time)
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise an issue to follow-up. -
Documentation added/updated, if needed. -
Announcement added, if change is notable. -
gdk doctor
test added, if needed. -
Add the ~highlight
label if this MR should be included in theCHANGELOG.md
.
Edited by Michael Kozono