From 7def17c1e90b97948380dada61c139d82903bf25 Mon Sep 17 00:00:00 2001 From: Markus Danek Date: Tue, 9 May 2017 15:17:01 +0200 Subject: [PATCH] TT#15802 Run 'npm install' in Dockerfile instead in testrunner Change-Id: Iaf22d3c31978567008f7e996208fa2246827dd4f --- t/Dockerfile | 17 +++++++++++------ t/specs/wdio-setup.spec.js | 2 +- t/testrunner | 22 +++++++++++++--------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/t/Dockerfile b/t/Dockerfile index 10c8a974..73b238d2 100644 --- a/t/Dockerfile +++ b/t/Dockerfile @@ -5,7 +5,7 @@ FROM docker.mgm.sipwise.com/sipwise-jessie:latest # is updated with the current date. It will force refresh of all # of the base images and things like `apt-get update` won't be using # old cached versions when the Dockerfile is built. -ENV REFRESHED_AT 2016-12-12 +ENV REFRESHED_AT 2017-05-09 RUN echo "deb https://deb.sipwise.com/autobuild/ release-trunk-jessie main" >>/etc/apt/sources.list @@ -27,7 +27,7 @@ RUN ln -s selenium-server-standalone-2.53.1.jar selenium-server-standalone.jar RUN wget -O chromedriver_linux64.zip https://deb.sipwise.com/files/chromedriver_linux64_2.25.zip && unzip chromedriver_linux64.zip -ADD xvfb-chromium /usr/bin/xvfb-chromium +ADD ./t/xvfb-chromium /usr/bin/xvfb-chromium RUN ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome RUN ln -s /usr/bin/xvfb-chromium /usr/bin/chromium-browser @@ -35,7 +35,10 @@ RUN echo "cd /code && ./t/testrunner" >/root/.bash_history RUN ln -s /home/selenium/chromedriver /usr/bin/chromedriver -COPY jenkins_docker_run /home/selenium/ +COPY ./t/jenkins_docker_run /home/selenium/ + +ADD ./t/package.json /home/selenium/ +RUN npm install WORKDIR /home/selenium/ @@ -43,12 +46,14 @@ WORKDIR /home/selenium/ # Instructions for usage # ---------------------- # When you want to build the base image from scratch (jump to the next section if you don't want to build yourself!): -# % docker build --tag="ngcp-csc-jessie" . -# % docker run --rm -i -t -v $(pwd)/..:/code:rw ngcp-csc-jessie:latest bash +# NOTE: run the following commands from root folder of git repository: +# % docker build --tag="ngcp-csc-jessie" -f ./t/Dockerfile . +# % docker run --rm -i -t -v $(pwd):/code:ro -v /results ngcp-csc-jessie:latest bash # # Use the existing docker image: # % docker pull docker.mgm.sipwise.com/ngcp-csc-jessie -# % docker run --rm -i -t -v $(pwd)/..:/code:rw docker.mgm.sipwise.com/ngcp-csc-jessie:latest bash +# NOTE: run the following command from root folder of git repository: +# % docker run --rm -i -t -v $(pwd):/code:ro -v /results docker.mgm.sipwise.com/ngcp-csc-jessie:latest bash # # Inside docker: # cd /code && ./t/testrunner diff --git a/t/specs/wdio-setup.spec.js b/t/specs/wdio-setup.spec.js index 56b38c97..57bb3379 100644 --- a/t/specs/wdio-setup.spec.js +++ b/t/specs/wdio-setup.spec.js @@ -3,6 +3,6 @@ describe('webdriver.io page', function() { it('should have the right title - the fancy generator way', function () { browser.url('http://localhost:1841'); var title = browser.getTitle(); - assert.equal(title, 'NgcpCsc Dashboard'); + assert.equal(title, 'Sipwise Customer Portal'); }); }); diff --git a/t/testrunner b/t/testrunner index 93e764a0..f1723cc8 100755 --- a/t/testrunner +++ b/t/testrunner @@ -10,35 +10,39 @@ set -u pwd -PASSWORD="selenium" - pkill -f '/usr/bin/java -jar /home/selenium/selenium-server-standalone.jar' || true # NOTE: this could silently fail because selenium-server-standalone.jar is missing a daemonize option DISPLAY=:98 /usr/bin/java -jar /home/selenium/selenium-server-standalone.jar -trustAllSSLCertificates -log /home/selenium/selenium.log & sleep 5 +echo "### Copying and moving files" +cp -Rf . /tmp/code +ln -s /tmp/node_modules /tmp/code/node_modules +cd /tmp/code/ + echo "################################################################################" echo "Finished main setup, now running tests ..." echo "Selenium server log file available at /home/selenium/selenium.log" -cp -Rf . /tmp/code -cd /tmp/code/ - +echo "### Building app" /opt/Sencha/Cmd/sencha app build -c cd /tmp/code/t/ -rm -rf node_modules node_modules -npm install - -cd /tmp/code/t/ +echo "### Starting Karma test" ./node_modules/karma/bin/karma start config/karma.conf.js cd /tmp/code/ +echo "### Starting app server" /opt/Sencha/Cmd/sencha web start & sleep 5 + cd /tmp/code/t/ +echo "### Starting Webdriver.io test" ./node_modules/.bin/wdio config/wdio.conf.js +echo "### Moving JUnit XML files to /results" +mv /tmp/code/t/*.xml /results + echo "Finished test execution, test execution returned with exit code." echo "################################################################################"