Skip to content

Commit

Permalink
task(gen3-qa-in-a-box): Run tests within a container/pod with seleniu…
Browse files Browse the repository at this point in the history
…m-standlone (#668)
  • Loading branch information
Marcelo R Costa authored Aug 6, 2021
1 parent fb1bf0c commit dea6be4
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 39 deletions.
38 changes: 25 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/cdis/alpine:3.12.1
FROM quay.io/cdis/debian:bullseye

USER root

Expand All @@ -9,8 +9,8 @@ ARG group=sdet
ARG uid=1000
ARG gid=1000

RUN addgroup -g ${gid} ${group} \
&& adduser --home "$SDET_HOME" --uid ${uid} --ingroup ${group} --disabled-password --shell /bin/sh ${user}
RUN addgroup --gid ${gid} ${group} \
&& useradd -m -d "$SDET_HOME" -u ${uid} -g ${group} -s /bin/bash ${user}

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -30,37 +30,42 @@ ENV PYTHONUNBUFFERED=1 \
# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"

RUN apk add --update --no-cache python3 \
RUN apt-get update \
&& apt-get install -y python3 python3-pip \
&& ln -sf python3 /usr/bin/python \
&& python3 -m ensurepip \
&& pip3 install --no-cache --upgrade pip setuptools

# install everything else
RUN set -xe && apk add --no-cache --virtual .build-deps \
RUN set -xe && apt-get update && apt-get upgrade -y && apt-get install -y \
zip \
unzip \
less \
vim \
gcc \
xvfb \
libxi6 \
libgconf-2-4 \
libc-dev \
libffi-dev \
make \
openssl-dev \
pcre-dev \
zlib-dev \
linux-headers \
libssl-dev \
libghc-regex-pcre-dev \
zlib1g-dev \
linux-headers-amd64 \
curl \
wget \
jq \
nodejs \
npm
npm \
openjdk-11-jre-headless

# Copy the gen3-qa framework scripts (test suites + service and utils modules)
COPY codecept.conf.js \
package.json \
COPY package.json \
package-lock.json \
test_setup.js \
.eslintrc.js ${SDET_HOME}/
# gen3-qa-in-a-box requires a couple of changes to its webdriver config
COPY gen3.qa.in.a.box.codecept.conf.js ${SDET_HOME}/codecept.conf.js
COPY helpers ${SDET_HOME}/helpers/
COPY hooks ${SDET_HOME}/hooks/
COPY services ${SDET_HOME}/services/
Expand All @@ -74,9 +79,16 @@ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-
RUN mkdir -p ${SDET_HOME}/controller/gen3qa-controller
WORKDIR ${SDET_HOME}/controller

# Install google chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get -y update \
&& apt-get -y install google-chrome-stable

# utilize the selenium sidecar as there is no selenium-hub in prod-tier environments
RUN cd ${SDET_HOME} \
&& npm install \
&& npx selenium-standalone install \
&& sed -i "s/ host: 'selenium-hub',/ host: 'localhost',/" codecept.conf.js

# poetry artifacts
Expand Down
131 changes: 131 additions & 0 deletions gen3.qa.in.a.box.codecept.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
const { Env } = require('./utils/env');

Env.setupEnvVariables();

// Set hostname according to namespace
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: `https://${process.env.HOSTNAME}`,
smartWait: 30000,
browser: 'chrome',
// fullPageScreenshots: true,
disableScreenshots: true,
desiredCapabilities: {
chromeOptions: {
args: [
'--headless', // for dev, you can comment this line to open actual chrome for easier test
'--disable-gpu', // https://stackoverflow.com/questions/51959986/how-to-solve-selenium-chromedriver-timed-out-receiving-message-from-renderer-exc
'--whitelisted-ips=*',
'--disable-features=VizDisplayCompositor', // https://stackoverflow.com/a/55371396/491553
'--window-size=1280,720',
'--no-sandbox',
// '--enable-features=NetworkService,NetworkServiceInProcess',
'--disable-infobars', // https://stackoverflow.com/a/43840128/1689770
'--disable-dev-shm-usage', // https://stackoverflow.com/a/50725918/1689770
'--disable-browser-side-navigation', // https://stackoverflow.com/a/49123152/1689770
],
},
},
restart: true, // restart browser for every test
timeouts: {
script: 6000,
// 'page load': 10000,
},
port: 4444,
},
REST: {
endpoint: `https://${process.env.HOSTNAME}`,
timeout: 300000,
defaultHeaders: {
common: {
Accept: 'application/json',
},
get: {},
head: {},
delete: {},
post: { 'Content-Type': 'application/json' },
patch: { 'Content-Type': 'application/json' },
put: { 'Content-Type': 'application/json' },
},
},
CDISHelper: {
require: './helpers/cdisHelper.js',
},
browserLogHelper: {
require: './helpers/browserLogHelper.js',
},
},
include: {
// General Utils
nodes: './utils/nodes.js',
users: './utils/user.js',
google: './utils/google.js',
files: './utils/file.js',
dataUpload: './utils/dataUpload.js',

// APIs
sheepdog: './services/apis/sheepdog/sheepdogService.js',
indexd: './services/apis/indexd/indexdService.js',
drs: './services/apis/drs/drsService.js',
peregrine: './services/apis/peregrine/peregrineService.js',
pidgin: './services/apis/pidgin/pidginService.js',
fence: './services/apis/fence/fenceService.js',
dataClient: './services/apis/dataClient/dataClientService.js',
etl: './services/apis/etl/etlService.js',
manifestService: './services/apis/manifestService/manifestServiceService.js',
guppy: './services/apis/guppy/guppyService.js',
mds: './services/apis/mds/mdsService.js',
auditService: './services/apis/auditService/auditService.js',

// Pages
home: './services/portal/home/homeService.js',
indexing: './services/portal/indexing/indexingService.js',
login: './services/portal/login/loginService.js',
explorer: './services/portal/explorer/explorerService.js',
portalDataUpload: './services/portal/dataUpload/dataUploadService.js',
portalExportToWorkspace: './services/portal/exportToWorkspace/exportToWorkspaceService.js',
portalCoreMetadataPage: './services/portal/coreMetadataPage/coreMetadataPageService.js',
discovery: './services/portal/discovery/discoveryService.js',
},
mocha: {
reporterOptions: {
'codeceptjs-cli-reporter': {
stdout: '-',
options: {
verbose: true,
steps: true,
},
},
'mocha-junit-reporter': {
stdout: 'output/result[hash].xml',
options: {
mochaFile: 'output/result[hash].xml',
verbose: true,
steps: true,
},
},
},
},
bootstrap: require('./test_setup.js'), // eslint-disable-line global-require
hooks: [
require('./hooks/test_results.js'), // eslint-disable-line global-require
],
tests: './suites/**/*.js',
gherkin: {
features: './suites/bdd/**/*.feature',
steps: './suites/bdd/**/*.js',
},
plugins: {
allure: {},
tryTo: {
enabled: true,
},
screenshotOnFail: {
enabled: true,
},
},
timeout: 60000,
name: 'selenium',
};
128 changes: 103 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dea6be4

Please sign in to comment.