Skip to content

Commit 6e35afe

Browse files
committed
run test automation by CircleCI
1 parent 94aa4d2 commit 6e35afe

File tree

4 files changed

+139
-6
lines changed

4 files changed

+139
-6
lines changed

.circleci/config.yml

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
run_basedeployment:
4+
default: true
5+
type: boolean
6+
run_smoketesting:
7+
default: false
8+
type: boolean
9+
210
defaults: &defaults
311
docker:
412
- image: circleci/python:2.7-stretch-browsers
13+
14+
test_defaults: &test_defaults
15+
docker:
16+
- image: docker:17.11.0-ce-git
17+
518
install_dependency: &install_dependency
619
name: Installation of build and deployment dependencies.
720
command: |
821
sudo apt install jq
922
sudo pip install awscli --upgrade
1023
sudo pip install docker-compose
24+
25+
install_test_dependency: &install_test_dependency
26+
name: Installation of build and deployment dependencies.
27+
command: |
28+
apk update
29+
apk add --no-cache bash openssl curl
30+
apk upgrade
31+
apk add --no-cache jq py-pip sudo
32+
sudo pip install awscli --upgrade
33+
1134
install_deploysuite: &install_deploysuite
1235
name: Installation of install_deploysuite.
1336
command: |
1437
git clone --branch v1.4 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
1538
cp ./../buildscript/master_deploy.sh .
1639
cp ./../buildscript/buildenv.sh .
1740
cp ./../buildscript/awsconfiguration.sh .
41+
1842
restore_cache_settings_for_build: &restore_cache_settings_for_build
1943
key: docker-node-modules-28-10-2020-{{ checksum "package-lock.json" }}
2044

@@ -35,7 +59,7 @@ builddeploy_steps: &builddeploy_steps
3559
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
3660
echo awsenvconf >.dockerignore
3761
echo buildenvvar >>.dockerignore
38-
- run:
62+
- run:
3963
name: "building image"
4064
command: |
4165
source buildenvvar
@@ -48,7 +72,35 @@ builddeploy_steps: &builddeploy_steps
4872
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
4973
source buildenvvar
5074
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
75+
curl --request POST \
76+
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
77+
--header "Circle-Token: ${CIRCLE_TOKEN}" \
78+
--header 'content-type: application/json' \
79+
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true, "run_basedeployment": false}}'
5180
81+
# Automated Smoke Testing
82+
smoke_testing: &smoke_testing
83+
# Initialization.
84+
- checkout
85+
- setup_remote_docker
86+
- run: *install_test_dependency
87+
- run: *install_deploysuite
88+
# Restoration of node_modules from cache.
89+
- restore_cache: *restore_cache_settings_for_build
90+
- run:
91+
name: "configuring environment"
92+
command: |
93+
./awsconfiguration.sh $DEPLOY_ENV
94+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-deployvar
95+
- run:
96+
name: "Run automation"
97+
no_output_timeout: 20m
98+
command: |
99+
source awsenvconf
100+
source buildenvvar
101+
./test-automation/smoketest.sh
102+
- store_artifacts:
103+
path: ./test-automation/test-results
52104

53105
jobs:
54106
# Build & Deploy against development backend
@@ -59,29 +111,44 @@ jobs:
59111
LOGICAL_ENV: "dev"
60112
NODE_ENV: "development"
61113
BABEL_ENV: "development"
62-
APPNAME: "challenge-engine-ui"
114+
APPNAME: "challenge-engine-ui"
63115
steps: *builddeploy_steps
64116

65117
"build-prod":
66118
<<: *defaults
67119
environment:
68120
DEPLOY_ENV: "PROD"
69-
LOGICAL_ENV: "prod"
121+
LOGICAL_ENV: "prod"
70122
NODE_ENV: "production"
71123
BABEL_ENV: "production"
72-
APPNAME: "challenge-engine-ui"
124+
APPNAME: "challenge-engine-ui"
73125
steps: *builddeploy_steps
74126

127+
"smoke-testing-dev":
128+
<<: *test_defaults
129+
environment:
130+
DEPLOY_ENV: "DEV"
131+
LOGICAL_ENV: "dev"
132+
steps: *smoke_testing
133+
134+
"smoke-testing-prod":
135+
<<: *test_defaults
136+
environment:
137+
DEPLOY_ENV: "PROD"
138+
LOGICAL_ENV: "prod"
139+
steps: *smoke_testing
140+
75141
workflows:
76142
version: 2
77143
build:
144+
when: << pipeline.parameters.run_basedeployment >>
78145
jobs:
79146
# Development builds are executed on "develop" branch only.
80147
- "build-dev":
81148
context : org-global
82149
filters:
83150
branches:
84-
only: ['develop', 'feature/bug-bash-july']
151+
only: ['develop', 'feature/bug-bash-july', 'feature/test-automation']
85152

86153
# Production builds are exectuted only on tagged commits to the
87154
# master branch.
@@ -90,3 +157,21 @@ workflows:
90157
filters:
91158
branches:
92159
only: master
160+
161+
Smoke Testing:
162+
when: << pipeline.parameters.run_smoketesting >>
163+
jobs:
164+
- Hold [Smoke-Testing]:
165+
type: approval
166+
- smoke-testing-dev:
167+
context : org-global
168+
requires:
169+
- Hold [Smoke-Testing]
170+
filters:
171+
<<: *filters-dev
172+
- smoke-testing-prod:
173+
context : org-global
174+
requires:
175+
- Hold [Smoke-Testing]
176+
filters:
177+
<<: *filters-prod

test-automation/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM node:10.17.0-stretch
2+
RUN apt update
3+
RUN apt install sudo
4+
RUN sudo apt-get update; sudo apt-get install -y openjdk-8-jre openjdk-8-jre-headless openjdk-8-jdk openjdk-8-jdk-headless;
5+
RUN curl --silent --show-error --location --fail --retry 3 --output /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
6+
&& (sudo dpkg -i /tmp/google-chrome-stable_current_amd64.deb || sudo apt-get -fy install) \
7+
&& rm -rf /tmp/google-chrome-stable_current_amd64.deb \
8+
&& sudo sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' \
9+
"/opt/google/chrome/google-chrome" \
10+
&& google-chrome --version
11+
RUN export CHROMEDRIVER_RELEASE=$(curl --location --fail --retry 3 http://chromedriver.storage.googleapis.com/LATEST_RELEASE) \
12+
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/chromedriver_linux64.zip "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" \
13+
&& cd /tmp \
14+
&& unzip chromedriver_linux64.zip \
15+
&& rm -rf chromedriver_linux64.zip \
16+
&& sudo mv chromedriver /usr/local/bin/chromedriver \
17+
&& sudo chmod +x /usr/local/bin/chromedriver \
18+
&& chromedriver --version
19+
RUN sudo apt-get install -y libgconf-2-4
20+
RUN sudo apt-get install -y xvfb
21+
RUN sudo apt-get install -y jq
22+
ENV DISPLAY :99
23+
RUN printf '#!/bin/sh\nXvfb :99 -screen 0 1280x1024x24 &\nexec "$@"\n' > /tmp/entrypoint \
24+
&& chmod +x /tmp/entrypoint \
25+
&& sudo mv /tmp/entrypoint /docker-entrypoint.sh
26+
27+
COPY . /test-automation
28+
WORKDIR /test-automation
29+
RUN npm install
30+
RUN ./node_modules/.bin/webdriver-manager update --versions.chrome=="$(google-chrome -version)"
31+
ENTRYPOINT ["/docker-entrypoint.sh"]
32+
CMD ["/bin/sh"]

test-automation/smoketest.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
cd test-automation
4+
5+
docker build -t wm-smoke:latest .
6+
docker run --name wm-smoke --shm-size=2g wm-smoke:latest ./testrun.sh -d -p 4444:4444
7+
docker cp wm-smoke:./test-automation/test-results .

test-automation/testrun.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
./node_modules/.bin/webdriver-manager start --detach
3+
npm run test
4+
5+
if [ $? -eq 0 ]; then
6+
echo "Test case successfully completed"
7+
else
8+
echo "Test case Failed"
9+
fi

0 commit comments

Comments
 (0)