From dea6be4b0bb4eb5a63eded808b249dfe4a1193b0 Mon Sep 17 00:00:00 2001 From: Marcelo R Costa Date: Fri, 6 Aug 2021 16:15:59 -0500 Subject: [PATCH] task(gen3-qa-in-a-box): Run tests within a container/pod with selenium-standlone (#668) --- Dockerfile | 38 ++++++--- gen3.qa.in.a.box.codecept.conf.js | 131 ++++++++++++++++++++++++++++++ package-lock.json | 128 +++++++++++++++++++++++------ package.json | 2 +- 4 files changed, 260 insertions(+), 39 deletions(-) create mode 100644 gen3.qa.in.a.box.codecept.conf.js diff --git a/Dockerfile b/Dockerfile index 2507f3fb9..1df93b255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/cdis/alpine:3.12.1 +FROM quay.io/cdis/debian:bullseye USER root @@ -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 @@ -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/ @@ -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 diff --git a/gen3.qa.in.a.box.codecept.conf.js b/gen3.qa.in.a.box.codecept.conf.js new file mode 100644 index 000000000..22c2ccdb2 --- /dev/null +++ b/gen3.qa.in.a.box.codecept.conf.js @@ -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', +}; diff --git a/package-lock.json b/package-lock.json index fea3702fb..a78bb03ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5308,6 +5308,12 @@ "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", "dev": true }, + "is-port-reachable": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-port-reachable/-/is-port-reachable-3.0.0.tgz", + "integrity": "sha512-056IzLiWHdgVd6Eq1F9HtJl+cIkvi5X2MJ/A1fjQtByHkzQE1wGardnPhqrarOGDF88BOW+297X7PDvZ2vcyVg==", + "dev": true + }, "is-potential-custom-element-name": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz", @@ -6168,6 +6174,12 @@ "integrity": "sha1-I+89lTVWUgOmbO/VuDD4SJEa+0g=", "dev": true }, + "lodash.mapvalues": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", + "integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=", + "dev": true + }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", @@ -8413,26 +8425,33 @@ "dev": true }, "selenium-standalone": { - "version": "6.20.1", - "resolved": "https://registry.npmjs.org/selenium-standalone/-/selenium-standalone-6.20.1.tgz", - "integrity": "sha512-2pEKCHWFRKX993bWVb0zz8NYL1cio9zfHbDlrsu5ab1aoXlz41kMi/5Y5sqSDahz+6H/eHucMwFzQJ2YpqaMKg==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/selenium-standalone/-/selenium-standalone-7.1.0.tgz", + "integrity": "sha512-Pc7U48qwB4LVy/XczBrPPXwUhEPl3XQSik8SjLfj2qzBEtZqrjyzOlnnXq4aVCdr5wH9FiFJm8LwheJbK2+/oQ==", "dev": true, "requires": { - "async": "^3.0.0", - "commander": "^2.19.0", - "cross-spawn": "^7.0.0", - "debug": "^4.1.1", - "lodash": "^4.17.11", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", + "commander": "^7.2.0", + "cross-spawn": "^7.0.3", + "debug": "^4.3.1", + "fs-extra": "^10.0.0", + "got": "^11.8.2", + "is-port-reachable": "^3.0.0", + "lodash.mapvalues": "^4.6.0", + "lodash.merge": "^4.6.2", + "minimist": "^1.2.5", + "mkdirp": "^1.0.4", "progress": "2.0.3", - "request": "2.88.2", - "tar-stream": "2.1.4", - "urijs": "^1.19.1", - "which": "^2.0.0", + "tar-stream": "2.2.0", + "which": "^2.0.2", "yauzl": "^2.10.0" }, "dependencies": { + "commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -8444,15 +8463,61 @@ "which": "^2.0.1" } }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "ms": "2.1.2" } }, + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "got": { + "version": "11.8.2", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.2.tgz", + "integrity": "sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==", + "dev": true, + "requires": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.1", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true + }, "path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -8473,6 +8538,25 @@ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dev": true, + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true } } }, @@ -9669,12 +9753,6 @@ } } }, - "urijs": { - "version": "1.19.7", - "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.7.tgz", - "integrity": "sha512-Id+IKjdU0Hx+7Zx717jwLPsPeUqz7rAtuVBRLLs+qn+J2nf9NGITWVCxcijgYxBqe83C7sqsQPs6H1pyz3x9gA==", - "dev": true - }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", diff --git a/package.json b/package.json index 1a15401f7..d2ee7dc95 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "cli-progress": "^3.8.2", "prettier": "^1.19.1", "request": "^2.88.2", - "selenium-standalone": "^6.20.0", + "selenium-standalone": "^7.1.0", "ssl-root-cas": "^1.3.1", "tsv": "^0.2.0", "unirest": "^0.6.0",