Browse Source

Use headless option for cors functional test runner

Some selenium webdrivers (e.g. Chrome, Firefox) support a headless
option so we can expose that as an option for the test runner too.

Use this in an attempt to fix "Error: cannot open display: :99" errors
seen in the gate.

Related-Bug: #1918864
Change-Id: I2a549ce829eb0bc38406575582202e1d8dd1a0e2
changes/84/781084/4
Alistair Coles 3 months ago
committed by Tim Burke
parent
commit
e572938af3
2 changed files with 12 additions and 2 deletions
  1. +11
    -1
      test/cors/main.py
  2. +1
    -1
      tools/playbooks/cors/run.yaml

+ 11
- 1
test/cors/main.py View File

@ -180,9 +180,19 @@ def run(args, url):
browsers = list(ALL_BROWSERS) if 'all' in args.browsers else args.browsers
ran_one = False
for browser_name in browsers:
kwargs = {}
try:
options = getattr(
selenium.webdriver, browser_name.title() + 'Options')()
options.headless = True
kwargs['options'] = options
except AttributeError:
# not all browser types have Options class
pass
driver = getattr(selenium.webdriver, browser_name.title())
try:
browser = driver()
browser = driver(**kwargs)
except Exception as e:
if not ('needs to be in PATH' in str(e) or
'SafariDriver was not found' in str(e)):


+ 1
- 1
tools/playbooks/cors/run.yaml View File

@ -9,7 +9,7 @@
- name: Run CORS tests
shell: >
xvfb-run python
python
{{ ansible_env.HOME }}/{{ zuul.project.src_dir }}/test/cors/main.py
--output {{ ansible_env.HOME }}/cors-test-results.txt
all

Loading…
Cancel
Save