Skip to content

Commit a6ff4bf

Browse files
Merge pull request #5295 from topcoder-platform/develop_automation
Smoke Test Automation
2 parents 5f65a62 + 5094131 commit a6ff4bf

File tree

93 files changed

+13324
-10339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+13324
-10339
lines changed

.circleci/config.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2
1+
version: 2.1
22

33
defaults: &defaults
44
docker:
@@ -63,7 +63,7 @@ jobs:
6363
source awsenvconf
6464
source buildenvvar
6565
./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp
66-
66+
6767
# Build & Deploy against testing backend
6868
"build-test":
6969
<<: *defaults
@@ -231,28 +231,35 @@ workflows:
231231
branches:
232232
only:
233233
- develop
234+
- develop_automation
235+
post-steps:
236+
- run:
237+
name: Run automation
238+
command: |
239+
source awsenvconf
240+
source buildenvvar
241+
./automated-smoke-test/smoketest.sh automation-config-dev.json dev
234242
# This is alternate dev env for parallel testing
235243
- "build-test":
236244
context : org-global
237245
filters:
238246
branches:
239247
only:
240-
- gig-apply-fix
248+
- free
241249
# This is alternate dev env for parallel testing
242250
- "build-qa":
243251
context : org-global
244252
filters:
245253
branches:
246254
only:
247-
- hide-my-communities
255+
- free
248256
# This is beta env for production soft releases
249257
- "build-prod-beta":
250258
context : org-global
251259
filters:
252260
branches:
253261
only:
254-
- integration-v5-challenge-api
255-
- hot-fix
262+
- free
256263
# This is stage env for production QA releases
257264
- "build-prod-staging":
258265
context : org-global
@@ -279,4 +286,3 @@ workflows:
279286
branches:
280287
ignore:
281288
- develop
282-

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ jspm_packages
5151
set-env*.sh
5252
set-test-env.sh
5353
.idea
54-
*.iml
54+
*.iml
55+
56+
# e2e test case
57+
automated-smoke-test/temp
58+
automated-smoke-test/test-results
59+
automated-smoke-test/config/config.json

automated-smoke-test/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 . /automated-smoke-test
28+
WORKDIR /automated-smoke-test
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"]

automated-smoke-test/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Topcoder Testing Project - E2E Tests
2+
3+
#### Software Required
4+
5+
Nodejs v8.11.4+
6+
Chrome Browser
7+
8+
#### Installation:
9+
10+
- Installs
11+
`npm install`
12+
13+
- To run tests
14+
`cd automated-smoke-test`
15+
`npm run test`
16+
- To run Test locally
17+
`cd automated-smoke-test`
18+
`npm run local-test`
19+
20+
Note : if you want to run the script for different env, make sure you there is config.json file created. For example , to run the dev env
21+
`cd automated-smoke-test`
22+
`cp config/automation-config-dev.json config/config.json`
23+
`npm run test`
24+
25+
26+
- Test results are generated in test-results/ folder
27+
28+
```
29+
HTML report - TestResult.html
30+
Junit report - junitresults-TopcoderLoginPageTests.xml and junitresults-TopcoderRegistrationPageTests.xml
31+
```
32+
33+
- To view junit reports into html, install xunit-viewer
34+
`npm i -g xunit-viewer`
35+
36+
- HTML report from Junit reports can be generated using this command
37+
`xunit-viewer --results=test-results/ --output=/home/Documents/`
38+
39+
As of now, the tests are running in headless mode. To view the actual chrom browser running the tests, you can remove `--headless` option from `chromeOptions.args` in `config.ts`
40+
41+
#### Implementation Details:
42+
43+
- TBD
44+
45+
#### Configuration details:
46+
47+
- config.json holds the data level configuration, like user credentials etc
48+
- conf.ts holds the application configuration, like jasmine reporters to be configured, specs to be run etc.
49+

automated-smoke-test/conf.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import reporters = require('jasmine-reporters');
2+
import HtmlReporter = require('protractor-beautiful-reporter');
3+
import { BrowserHelper } from 'topcoder-testing-lib';
4+
5+
declare global {
6+
namespace NodeJS {
7+
interface IGlobal {
8+
document: Document;
9+
window: Window;
10+
navigator: Navigator;
11+
forgotPasswordMailListener: any;
12+
registrationMailListener: any;
13+
}
14+
}
15+
}
16+
17+
exports.config = {
18+
directConnect: true,
19+
20+
// Capabilities to be passed to the webdriver instance.
21+
capabilities: {
22+
browserName: 'chrome',
23+
chromeOptions: {
24+
args: [
25+
"--headless",
26+
'--disable-gpu',
27+
'--no-sandbox',
28+
'--window-size=1325x744',
29+
],
30+
},
31+
},
32+
33+
// Framework to use. Jasmine is recommended.
34+
framework: 'jasmine2',
35+
36+
specs: [
37+
// '../temp/test-suites/tc-login.spec.js'
38+
// '../temp/test-suites/tc-tools.spec.js',
39+
// '../temp/test-suites/tc-account.spec.js',
40+
// '../temp/test-suites/tc-profile.spec.js',
41+
// '../temp/test-suites/tc-header.spec.js',
42+
// '../temp/test-suites/tc-footer.spec.js',
43+
// '../temp/test-suites/tc-preferences.spec.js',
44+
'../temp/test-suites/tc-challenge-listing.spec.js',
45+
// '../temp/test-suites/tc-challenge-detail.spec.js',
46+
// '../temp/test-suites/tc-my-dashboard.spec.js',
47+
// '../temp/test-suites/tc-member-profile.spec.js',
48+
],
49+
50+
// Options to be passed to Jasmine.
51+
jasmineNodeOpts: {
52+
defaultTimeoutInterval: 1200000, // 20 minutes
53+
isVerbose: true,
54+
showColors: true,
55+
},
56+
57+
onPrepare: () => {
58+
BrowserHelper.maximize();
59+
BrowserHelper.implicitlyWait(5000);
60+
const junitReporter = new reporters.JUnitXmlReporter({
61+
consolidateAll: false,
62+
savePath: 'test-results',
63+
});
64+
jasmine.getEnv().addReporter(junitReporter);
65+
jasmine.getEnv().addReporter(
66+
new HtmlReporter({
67+
baseDirectory: 'test-results',
68+
docName: 'TestResult.html', // Change html report file name
69+
docTitle: 'Test Automation Execution Report', // Add title for the html report
70+
gatherBrowserLogs: true, // Store Browser logs
71+
jsonsSubfolder: 'jsons', // JSONs Subfolder
72+
preserveDirectory: false, // Preserve base directory
73+
screenshotsSubfolder: 'screenshots',
74+
takeScreenShotsForSkippedSpecs: true, // Screenshots for skipped test cases
75+
takeScreenShotsOnlyForFailedSpecs: false, // Screenshots only for failed test cases
76+
}).getJasmine2Reporter()
77+
);
78+
},
79+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Timeout": {
3+
"FieldVisibility": 15000,
4+
"ElementVisibility": 15000,
5+
"ElementInvisibility": 15000,
6+
"ElementPresence": 15000,
7+
"ElementClickable": 15000,
8+
"PageLoad": 300000
9+
},
10+
11+
"LoggerErrors": {
12+
"ElementVisibilty": "Element did not display within timeout",
13+
"ElementInvisibilty": "Element did not become invisible within timeout",
14+
"ElementPresence": "Element was not present within timeout",
15+
"ElementClickable": "Element was not clickable within timeout",
16+
"PageLoad": "Page did not load within timeout"
17+
}
18+
}

0 commit comments

Comments
 (0)