Skip to content

Commit

Permalink
Fix up selenium test scripts to be compatible with Mac. (#1180)
Browse files Browse the repository at this point in the history
* Remove debug mode from selenium scripts, use standalone-chromium instead of chrome.

* Update documentation for removed option

* Adjustment to dockerfile

* Address PR feedback
  • Loading branch information
jimmyfagan authored Mar 26, 2024
1 parent 65d6ad3 commit df66443
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 63 deletions.
6 changes: 3 additions & 3 deletions Dockerfile.selenium
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM selenium/standalone-chrome-debug
FROM selenium/standalone-chrome

ENV PYTHONUNBUFFERED 1
# libpq-dev: ubuntu dev lib for psypsycopg2 sdist build
USER root
RUN apt-get update ; apt-get install -yq python3.8 python3.8-venv python3-pip git curl libpq-dev libffi-dev
RUN apt-get update ; apt-get install -yq git curl libpq-dev libffi-dev
RUN apt-get update ; apt-get install -yq python3 python3-venv
RUN ln -s /usr/bin/python3 /usr/local/bin/python
RUN useradd -m -s /bin/bash DEV
USER DEV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pipeline {

environment {
USE_MSLSX = false
USE_DEBUG = false
DJANGO_LOG_JSON_FORMAT_PRETTY = true
DJANGO_SETTINGS_MODULE = "hhs_oauth_server.settings.logging_it"
OAUTHLIB_INSECURE_TRANSPORT = true
Expand Down
11 changes: 3 additions & 8 deletions apps/integration_tests/selenium_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ def setup_method(self, method):

self.hostname_url = os.environ['HOSTNAME_URL']
self.use_mslsx = os.environ['USE_MSLSX']
self.use_debug = os.environ['USE_DEBUG']
self.login_seq = SEQ_LOGIN_MSLSX if self.use_mslsx == 'true' else SEQ_LOGIN_SLSX
print("use_mslsx={}, use_debug={}, hostname_url={}".format(self.use_mslsx, self.use_debug, self.hostname_url))
print("use_mslsx={}, hostname_url={}".format(self.use_mslsx, self.hostname_url))

opt = webdriver.ChromeOptions()
opt.add_argument("--disable-dev-shm-usage")
Expand All @@ -62,12 +61,8 @@ def setup_method(self, method):
opt.add_argument('--window-size=1920,1080')
opt.add_argument("--whitelisted-ips=''")

if self.use_debug == 'true':
self.driver = webdriver.Remote(
command_executor='http://chrome:4444/wd/hub', options=opt)
else:
opt.add_argument('--headless')
self.driver = webdriver.Chrome(options=opt)
self.driver = webdriver.Remote(
command_executor='http://chrome:4444/wd/hub', options=opt)

self.actions = {
Action.LOAD_PAGE: self._load_page,
Expand Down
12 changes: 1 addition & 11 deletions docker-compose.selenium.remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ services:
- docker-compose/selenium-env-vars.env
volumes:
- .:/code

selenium-remote-tests-debug:
build:
context: ./
dockerfile: Dockerfile.selenium
command: pytest ./apps/integration_tests/selenium_tests.py
env_file:
- docker-compose/selenium-env-vars.env
volumes:
- .:/code
depends_on:
- chrome

chrome:
image: selenium/standalone-chrome-debug
image: seleniarm/standalone-chromium
hostname: chrome
ports:
- "4444:4444"
Expand Down
15 changes: 1 addition & 14 deletions docker-compose.selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ version: '3'

services:
selenium-tests:
build:
context: ./
dockerfile: Dockerfile.selenium
command: pytest ./apps/integration_tests/selenium_tests.py
env_file:
- docker-compose/selenium-env-vars.env
volumes:
- .:/code
depends_on:
bb2slsx:
condition: service_healthy

selenium-tests-debug:
build:
context: ./
dockerfile: Dockerfile.selenium
Expand All @@ -30,7 +17,7 @@ services:
condition: service_started

chrome:
image: selenium/standalone-chrome-debug
image: seleniarm/standalone-chromium
hostname: chrome
ports:
- "4444:4444"
Expand Down
4 changes: 1 addition & 3 deletions docker-compose/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,10 @@ You can run selenium tests against a remote bb2 server by following below steps:

From the base directory of the local repo run:
```
./docker-compose/run_selenium_tests_remote.sh SBX (run selenium tests against bb2 server on SBX)
./docker-compose/run_selenium_tests_remote.sh -d SBX (run selenium tests in debug against bb2 server on SBX)
./docker-compose/run_selenium_tests_remote.sh -d SBX
```
The argument can be the remote ENV's name, it can also be the URL alternatively:
```
./docker-compose/run_selenium_tests_remote.sh https://sandbox.bluebutton.cms.gov/
./docker-compose/run_selenium_tests_remote.sh -d https://sandbox.bluebutton.cms.gov/
```

9 changes: 1 addition & 8 deletions docker-compose/run_selenium_tests_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ display_usage() {
echo "Options:"
echo
echo "-h Print this Help."
echo "-d Run tests in selenium debug mode (vnc view web UI interaction at http://localhost:5900)."
echo "-p Use new permissions screen (defaults to old style screen)."
echo
}
Expand Down Expand Up @@ -73,7 +72,6 @@ echo_msg
set -e -u -o pipefail

export USE_MSLSX=true
export USE_DEBUG=false
export USE_NEW_PERM_SCREEN=false
export SERVICE_NAME="selenium-tests"
export TESTS_LIST="./apps/integration_tests/selenium_tests.py"
Expand All @@ -83,15 +81,11 @@ export BB2_SERVER_STD2FILE=""
set_slsx

# Parse command line option
while getopts "hdp" option; do
while getopts "hp" option; do
case $option in
h)
display_usage
exit;;
d)
export USE_DEBUG=true
export SERVICE_NAME="selenium-tests-debug"
shift;break;;
p)
export USE_NEW_PERM_SCREEN=true;;
\?)
Expand Down Expand Up @@ -215,7 +209,6 @@ export DJANGO_SLSX_CLIENT_SECRET=${DJANGO_SLSX_CLIENT_SECRET}

echo "Selenium tests ..."
echo "MSLSX=" ${USE_MSLSX}
echo "DEBUG=" ${USE_DEBUG}
echo "SERVICE NAME=" ${SERVICE_NAME}
echo "USE_NEW_PERM_SCREEN=" ${USE_NEW_PERM_SCREEN}

Expand Down
16 changes: 2 additions & 14 deletions docker-compose/run_selenium_tests_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ display_usage() {
echo "Options:"
echo
echo "-h Print this Help."
echo "-d Run tests in selenium debug mode (vnc view web UI interaction at http://localhost:5900)."
echo "-p Test for newer permissions screen. Defaults to older screen."
echo
echo "Examples:"
Expand All @@ -49,7 +48,6 @@ echo_msg
# Set bash builtins for safety
set -e -u -o pipefail

export USE_DEBUG=false
export USE_NEW_PERM_SCREEN=false
export SERVICE_NAME="selenium-tests-remote"
# TODO optionally add the Spanish selenium tests here if desired
Expand All @@ -58,13 +56,11 @@ export TESTS_LIST="./apps/integration_tests/selenium_tests.py"
export HOSTNAME_URL="https://sandbox.bluebutton.cms.gov/"


while getopts "hdp" option; do
while getopts "hp" option; do
case $option in
h)
display_usage;
exit;;
d)
export USE_DEBUG=true;;
p)
export USE_NEW_PERM_SCREEN=true;;
\?)
Expand Down Expand Up @@ -103,23 +99,15 @@ fi
# Set SYSTEM
SYSTEM=$(uname -s)

echo "USE_DEBUG=" ${USE_DEBUG}
echo "USE_NEW_PERM_SCREEN=" ${USE_NEW_PERM_SCREEN}
echo "BB2 Server URL=" ${HOSTNAME_URL}

export USE_DEBUG
export USE_NEW_PERM_SCREEN
export USE_MSLSX=false

# stop all before run selenium remote tests
docker-compose -f docker-compose.selenium.remote.yml down --remove-orphans

if $USE_DEBUG
then
docker-compose -f docker-compose.selenium.remote.yml run selenium-remote-tests-debug bash -c "pytest ${TESTS_LIST}"
else
docker-compose -f docker-compose.selenium.remote.yml run selenium-remote-tests bash -c "pytest ${TESTS_LIST}"
fi
docker-compose -f docker-compose.selenium.remote.yml run selenium-remote-tests bash -c "pytest ${TESTS_LIST}"

# Stop containers after use
echo_msg
Expand Down
1 change: 0 additions & 1 deletion docker-compose/selenium-env-vars.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Selenium tests related ENV vars file for the "tests" service containter.
HOSTNAME_URL=${HOSTNAME_URL}
USE_MSLSX=${USE_MSLSX}
USE_DEBUG=${USE_DEBUG}
USE_NEW_PERM_SCREEN=${USE_NEW_PERM_SCREEN}
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE}

Expand Down

0 comments on commit df66443

Please sign in to comment.