diff --git a/.gitlab/ci/rails/shared.gitlab-ci.yml b/.gitlab/ci/rails/shared.gitlab-ci.yml index ab1f1af7fd8dbd73fe6545560067d1891bf32c90..c650f9c373cbcd36d318c20bdb577a35735d0b8d 100644 --- a/.gitlab/ci/rails/shared.gitlab-ci.yml +++ b/.gitlab/ci/rails/shared.gitlab-ci.yml @@ -112,7 +112,20 @@ include: # spec/lib, yet background migration tests are also sitting there, # and they should run on their own jobs so we don't need to run them # in unit tests again. - - rspec_section rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~level:background_migration --tag ~click_house" + - | + echo "=== Setting up Chrome memory optimization ===" + df -h /dev/shm + # Create a 1GB RAM-based tmpfs for Chrome (you have 3.9GB available) + mkdir -p /tmp/chrome-mem + if mount -t tmpfs -o size=1G tmpfs /tmp/chrome-mem; then + echo "✓ Created 1GB RAM disk at /tmp/chrome-mem" + export CHROME_TMPDIR=/tmp/chrome-mem + df -h /tmp/chrome-mem + else + echo "⚠ Could not create tmpfs, using regular disk" + export CHROME_TMPDIR=/tmp + fi + rspec_section rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~level:background_migration --tag ~click_house" after_script: # We need this at the very top, because the section_start/section_end logic is defined there. - source scripts/utils.sh diff --git a/.gitlab/ci/version.yml b/.gitlab/ci/version.yml index 3d7ac30ab2d579de2ff48a31e7c4c6daa57e80ba..aab3b3de2c6b5616cc4871066d3f770a542f490a 100644 --- a/.gitlab/ci/version.yml +++ b/.gitlab/ci/version.yml @@ -1,6 +1,6 @@ variables: BUILD_OS: "debian" - CHROME_VERSION: "123" + CHROME_VERSION: "138" DOCKER_VERSION: "27.4.1" EXIFTOOL_VERSION: "12.60" GCLOUD_VERSION: "413" diff --git a/qa/Dockerfile b/qa/Dockerfile index a10db24c2f0566b468584e9b6a7a173bb120e86c..4a66992bddabfa5a1654885a6a6a71b75b5538bc 100644 --- a/qa/Dockerfile +++ b/qa/Dockerfile @@ -1,5 +1,5 @@ ARG BUILD_OS=debian -ARG CHROME_VERSION=123 +ARG CHROME_VERSION=138 ARG DOCKER_VERSION=24.0.5 ARG GCLOUD_VERSION=413 ARG GIT_VERSION=2.51 diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb index e49b4707e2ed865c2dddc8682120118d19d8813e..4245839cfd93b4f6ef5d9b6e280fdb78fac0ee30 100644 --- a/spec/features/snippets/user_creates_snippet_spec.rb +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -146,9 +146,7 @@ def fill_form # not anymore as requests when they come straight from memory cache. # accept_confirm is needed because of https://gitlab.com/gitlab-org/gitlab/-/issues/262102 reqs = inspect_requests do - visit("#{link}?ran=#{SecureRandom.base64(20)}") do - page.driver.browser.switch_to.alert.accept - end + visit("#{link}?ran=#{SecureRandom.base64(20)}") end expect(reqs.first.status_code).to eq(200) end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 7d58a81ede157753a7213b495b07f681a309e2eb..4156516090324e662a2a3672a2b49c2ea8fc91ce 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -41,12 +41,38 @@ # Chrome won't work properly in a Docker container in sandbox mode options.add_argument("no-sandbox") + options.add_argument("--disable-features=ParallelDownloading") + options.add_argument("--disable-http2") # HTTP/1.1 has different connection behavior options.add_argument("disable-search-engine-choice-screen") # Ensure the Chrome locale is `en` so all dates are deterministic regardless of local settings options.add_preference('intl.accept_languages', 'en') + if ENV['CI'] || ENV['CI_SERVER'] + # Use the RAM disk if available, otherwise fallback to /tmp + chrome_dir = ENV['CHROME_TMPDIR'] || '/tmp' + + # Create unique directories for this process + process_dir = "#{chrome_dir}/chrome-#{Process.pid}-#{Time.now.to_i}" + FileUtils.mkdir_p(process_dir) + + # Use RAM-based directories for everything + options.add_argument("--user-data-dir=#{process_dir}/profile") + options.add_argument("--disk-cache-dir=#{process_dir}/cache") + options.add_argument("--crash-dumps-dir=#{process_dir}/crashes") + + # REMOVE or conditionally add disable-dev-shm-usage + # Since we're using our own tmpfs, we might not need this flag + if ENV['CHROME_TMPDIR'] && ENV['CHROME_TMPDIR'].include?('chrome-mem') + puts "Using RAM disk, skipping disable-dev-shm-usage flag" + # Don't add the flag - let Chrome use the fast path + else + puts "Using disk, adding disable-dev-shm-usage flag" + options.add_argument("disable-dev-shm-usage") + end + end + unless ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i || ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i # Run headless by default unless WEBDRIVER_HEADLESS specified options.add_argument("headless") @@ -60,9 +86,6 @@ options.add_argument("disable-backgrounding-occluded-windows") end - # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab/issues/4252 - options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER'] - # Set chrome default download path if ENV['DEFAULT_CHROME_DOWNLOAD_PATH'] options.add_preference("download.default_directory", ENV['DEFAULT_CHROME_DOWNLOAD_PATH'])