From f7ffe27c2e4075789ccd9e798c8a88c9e1d85a4e Mon Sep 17 00:00:00 2001
From: Stan Hu <stanhu@gmail.com>
Date: Thu, 21 Dec 2017 23:40:56 -0800
Subject: [PATCH] Disable /dev/shm in CI

According to the Chrome source code (https://chromium.googlesource.com/chromium/src/base/+/master/base_switches.cc#120):

The /dev/shm partition is too small in certain VM environments, causing Chrome
to fail or crash (see http://crbug.com/715363). Use this flag to work-around
this issue (a temporary directory will always be used to create anonymous
shared memory files).

Addresses gitlab-org/gitlab-ee#4252 but doesn't appear to cure it completely.
---
 features/support/capybara.rb | 3 +++
 spec/support/capybara.rb     | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/features/support/capybara.rb b/features/support/capybara.rb
index 5a77b859113..4e2b3c67af5 100644
--- a/features/support/capybara.rb
+++ b/features/support/capybara.rb
@@ -29,6 +29,9 @@ Capybara.register_driver :chrome do |app|
     options.add_argument("disable-gpu")
   end
 
+  # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252
+  options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER']
+
   Capybara::Selenium::Driver.new(
     app,
     browser: :chrome,
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index 935b170a0f6..5189c57b7db 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -33,6 +33,9 @@ Capybara.register_driver :chrome do |app|
     options.add_argument("disable-gpu")
   end
 
+  # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252
+  options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER']
+
   Capybara::Selenium::Driver.new(
     app,
     browser: :chrome,
-- 
2.30.9