Skip to content

Commit 221114b

Browse files
committed
test: integrate browser testing for differential loading
1 parent 2676c2d commit 221114b

File tree

8 files changed

+348
-72
lines changed

8 files changed

+348
-72
lines changed

.circleci/config.yml

Lines changed: 98 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,29 @@ jobs:
212212
PATH=~/.npm-global/bin:$PATH npm install --global npm
213213
- run: PATH=~/.npm-global/bin:$PATH node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX}
214214

215+
test-browsers:
216+
executor:
217+
name: test-executor
218+
environment:
219+
E2E_BROWSERS: true
220+
steps:
221+
- attach_workspace: *attach_options
222+
- run:
223+
name: Initialize Environment
224+
command: ./.circleci/env.sh
225+
- run:
226+
name: Initialize Saucelabs
227+
command: setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
228+
- run:
229+
name: Start Saucelabs Tunnel
230+
command: ./scripts/saucelabs/start-tunnel.sh
231+
background: true
232+
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
233+
# too early without Saucelabs not being ready.
234+
- run: ./scripts/saucelabs/wait-for-tunnel.sh
235+
- run: PATH=~/.npm-global/bin:$PATH node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts
236+
- run: ./scripts/saucelabs/stop-tunnel.sh
237+
215238
build:
216239
executor: action-executor
217240
steps:
@@ -289,77 +312,80 @@ workflows:
289312
default_workflow:
290313
jobs:
291314
- install
292-
- lint:
315+
# - lint:
316+
# requires:
317+
# - install
318+
# - validate:
319+
# requires:
320+
# - install
321+
# - build:
322+
# requires:
323+
# - install
324+
# filters:
325+
# branches:
326+
# ignore:
327+
# - /docs-preview/
328+
# - build-bazel:
329+
# requires:
330+
# - build
331+
# - test:
332+
# requires:
333+
# - build
334+
# - test-win:
335+
# requires:
336+
# - test
337+
# - test-large:
338+
# requires:
339+
# - build
340+
# - test-large:
341+
# name: test-large-ivy
342+
# ivy: true
343+
# glob: "packages/angular_devkit/build_angular/test/browser/*_spec_large.ts"
344+
# requires:
345+
# - build
346+
# - e2e-cli:
347+
# post-steps:
348+
# - store_artifacts:
349+
# path: /tmp/dist
350+
# destination: cli/new-production
351+
# requires:
352+
# - build
353+
# - e2e-cli:
354+
# name: e2e-cli-ivy
355+
# ivy: true
356+
# requires:
357+
# - build
358+
# - e2e-cli:
359+
# name: e2e-cli-ng-snapshots
360+
# snapshots: true
361+
# <<: *ignore_pull_requests
362+
# requires:
363+
# - e2e-cli
364+
# - e2e-cli-node-10:
365+
# <<: *ignore_pull_requests
366+
# requires:
367+
# - e2e-cli
368+
# - e2e-cli-win:
369+
# <<: *ignore_pull_requests
370+
# requires:
371+
# - e2e-cli
372+
- test-browsers:
293373
requires:
294374
- install
295-
- validate:
296-
requires:
297-
- install
298-
- build:
299-
requires:
300-
- install
301-
filters:
302-
branches:
303-
ignore:
304-
- /docs-preview/
305-
- build-bazel:
306-
requires:
307-
- build
308-
- test:
309-
requires:
310-
- build
311-
- test-win:
312-
requires:
313-
- test
314-
- test-large:
315-
requires:
316-
- build
317-
- test-large:
318-
name: test-large-ivy
319-
ivy: true
320-
glob: "packages/angular_devkit/build_angular/test/browser/*_spec_large.ts"
321-
requires:
322-
- build
323-
- e2e-cli:
324-
post-steps:
325-
- store_artifacts:
326-
path: /tmp/dist
327-
destination: cli/new-production
328-
requires:
329-
- build
330-
- e2e-cli:
331-
name: e2e-cli-ivy
332-
ivy: true
333-
requires:
334-
- build
335-
- e2e-cli:
336-
name: e2e-cli-ng-snapshots
337-
snapshots: true
338-
<<: *ignore_pull_requests
339-
requires:
340-
- e2e-cli
341-
- e2e-cli-node-10:
342-
<<: *ignore_pull_requests
343-
requires:
344-
- e2e-cli
345-
- e2e-cli-win:
346-
<<: *ignore_pull_requests
347-
requires:
348-
- e2e-cli
349-
- snapshot_publish:
350-
<<: *ignore_pull_requests
351-
requires:
352-
- test
353-
- build
354-
- e2e-cli
355-
- publish:
356-
requires:
357-
- test
358-
- build
359-
- e2e-cli
360-
- snapshot_publish
361-
filters:
362-
tags:
363-
only: /^v\d+/
364-
branches:
365-
ignore: /.*/
375+
# - snapshot_publish:
376+
# <<: *ignore_pull_requests
377+
# requires:
378+
# - test
379+
# - build
380+
# - e2e-cli
381+
# - publish:
382+
# requires:
383+
# - test
384+
# - build
385+
# - e2e-cli
386+
# - snapshot_publish
387+
# filters:
388+
# tags:
389+
# only: /^v\d+/
390+
# branches:
391+
# ignore: /.*/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"pidtree": "^0.3.0",
129129
"pidusage": "^2.0.17",
130130
"rxjs": "~6.4.0",
131+
"sauce-connect": "https://saucelabs.com/downloads/sc-4.5.4-linux.tar.gz",
131132
"semver": "6.2.0",
132133
"source-map": "^0.5.6",
133134
"source-map-support": "^0.5.0",

scripts/saucelabs/start-tunnel.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -x -u -e -o pipefail
4+
5+
readonly currentDir=$(cd $(dirname $0); pwd)
6+
7+
# Command arguments that will be passed to sauce-connect. By default we disable SSL bumping for
8+
# all requests. This is because SSL bumping is not needed for our test setup and in order
9+
# to perform the SSL bumping, Saucelabs intercepts all HTTP requests in the tunnel VM and modifies
10+
# them. This can cause flakiness as it makes all requests dependent on the SSL bumping middleware.
11+
# See: https://wiki.saucelabs.com/display/DOCS/Troubleshooting+Sauce+Connect#TroubleshootingSauceConnect-DisablingSSLBumping
12+
sauceArgs="--no-ssl-bump-domains all"
13+
14+
if [[ ! -z "${SAUCE_LOG_FILE:-}" ]]; then
15+
mkdir -p $(dirname ${SAUCE_LOG_FILE})
16+
sauceArgs="${sauceArgs} --logfile ${SAUCE_LOG_FILE}"
17+
fi
18+
19+
if [[ ! -z "${SAUCE_READY_FILE:-}" ]]; then
20+
mkdir -p $(dirname ${SAUCE_READY_FILE})
21+
sauceArgs="${sauceArgs} --readyfile ${SAUCE_READY_FILE}"
22+
fi
23+
24+
if [[ ! -z "${SAUCE_PID_FILE:-}" ]]; then
25+
mkdir -p $(dirname ${SAUCE_PID_FILE})
26+
sauceArgs="${sauceArgs} --pidfile ${SAUCE_PID_FILE}"
27+
fi
28+
29+
if [[ ! -z "${SAUCE_TUNNEL_IDENTIFIER:-}" ]]; then
30+
sauceArgs="${sauceArgs} --tunnel-identifier ${SAUCE_TUNNEL_IDENTIFIER}"
31+
fi
32+
33+
echo "Starting Sauce Connect. Passed arguments: ${sauceArgs}"
34+
35+
${currentDir}/../../node_modules/sauce-connect/bin/sc -u ${SAUCE_USERNAME} -k ${SAUCE_ACCESS_KEY} ${sauceArgs}

scripts/saucelabs/stop-tunnel.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Disable printing of any executed command because this would cause a lot
4+
# of spam due to the loop.
5+
set +x -u -e -o pipefail
6+
7+
if [[ ! -f ${SAUCE_PID_FILE} ]]; then
8+
echo "Could not find Saucelabs tunnel PID file. Cannot stop tunnel.."
9+
exit 1
10+
fi
11+
12+
echo "Shutting down Sauce Connect tunnel"
13+
14+
# The process id for the sauce-connect instance is stored inside of the pidfile.
15+
tunnelProcessId=$(cat ${SAUCE_PID_FILE})
16+
17+
# Kill the process by using the PID that has been read from the pidfile. Note that
18+
# we cannot use killall because CircleCI base container images don't have it installed.
19+
kill ${tunnelProcessId}
20+
21+
while (ps -p ${tunnelProcessId} &> /dev/null); do
22+
printf "."
23+
sleep .5
24+
done
25+
26+
echo ""
27+
echo "Sauce Connect tunnel has been shut down"

scripts/saucelabs/wait-for-tunnel.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# Disable printing of any executed command because this would cause a lot
4+
# of spam due to the loop.
5+
set +x -u -e -o pipefail
6+
7+
# Waits for Saucelabs Connect to be ready before executing any tests.
8+
counter=0
9+
10+
while [[ ! -f ${SAUCE_READY_FILE} ]]; do
11+
counter=$((counter + 1))
12+
13+
# Counter needs to be multiplied by two because the while loop only sleeps a half second.
14+
# This has been made in favor of better progress logging (printing dots every half second)
15+
if [ $counter -gt $[${SAUCE_READY_FILE_TIMEOUT} * 2] ]; then
16+
echo "Timed out after ${SAUCE_READY_FILE_TIMEOUT} seconds waiting for tunnel ready file."
17+
echo "Printing logfile output:"
18+
echo ""
19+
cat ${SAUCE_LOG_FILE}
20+
exit 5
21+
fi
22+
23+
printf "."
24+
sleep 0.5
25+
done
26+
27+
echo ""
28+
echo "Connected to Saucelabs"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// @ts-check
2+
// Protractor configuration file, see link for more information
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
4+
5+
const { SpecReporter } = require('jasmine-spec-reporter');
6+
7+
const tunnelIdentifier = process.env['SAUCE_TUNNEL_IDENTIFIER'];
8+
9+
/**
10+
* @type { import("protractor").Config }
11+
*/
12+
exports.config = {
13+
sauceUser: process.env['SAUCE_USERNAME'],
14+
sauceKey: process.env['SAUCE_ACCESS_KEY'],
15+
16+
allScriptsTimeout: 11000,
17+
specs: ['./src/**/*.e2e-spec.ts'],
18+
19+
multiCapabilities: [
20+
{
21+
browserName: 'chrome',
22+
version: '41',
23+
'tunnel-identifier': tunnelIdentifier,
24+
},
25+
{
26+
browserName: 'chrome',
27+
version: '74',
28+
'tunnel-identifier': tunnelIdentifier,
29+
},
30+
{
31+
browserName: 'safari',
32+
platform: 'OS X 10.11',
33+
version: '9.0',
34+
'tunnel-identifier': tunnelIdentifier,
35+
},
36+
// TODO: Investigate. Failure:
37+
// Failed: Error while running testForAngular: undefined is not an object (evaluating 'd.prototype[b].apply')
38+
// {
39+
// browserName: 'safari',
40+
// platform: 'OS X 10.12',
41+
// version: '10.1',
42+
// 'tunnel-identifier': tunnelIdentifier,
43+
// },
44+
{
45+
browserName: 'safari',
46+
platform: 'macOS 10.14',
47+
version: '12.0',
48+
'tunnel-identifier': tunnelIdentifier,
49+
},
50+
{
51+
browserName: 'firefox',
52+
version: '48.0',
53+
'tunnel-identifier': tunnelIdentifier,
54+
},
55+
{
56+
browserName: 'firefox',
57+
version: '60.0',
58+
'tunnel-identifier': tunnelIdentifier,
59+
},
60+
{
61+
browserName: 'firefox',
62+
version: '67.0',
63+
'tunnel-identifier': tunnelIdentifier,
64+
},
65+
{
66+
browserName: 'internet explorer',
67+
platform: 'Windows 2012',
68+
version: '10',
69+
'tunnel-identifier': tunnelIdentifier,
70+
},
71+
{
72+
browserName: 'internet explorer',
73+
platform: 'Windows 8.1',
74+
version: '11',
75+
'tunnel-identifier': tunnelIdentifier,
76+
},
77+
// TODO: Investigate. Both Edge versions fail due to whitespace issue:
78+
// Expected 'Welcome to test-project! ' to equal 'Welcome to test-project!'.
79+
// {
80+
// browserName: "MicrosoftEdge",
81+
// platform: 'Windows 10',
82+
// version: "14.14393",
83+
// 'tunnel-identifier': tunnelIdentifier,
84+
// },
85+
// {
86+
// browserName: "MicrosoftEdge",
87+
// platform: 'Windows 10',
88+
// version: "16.16299",
89+
// 'tunnel-identifier': tunnelIdentifier,
90+
// },
91+
],
92+
93+
baseUrl: 'http://localhost:2000/',
94+
framework: 'jasmine',
95+
jasmineNodeOpts: {
96+
showColors: true,
97+
defaultTimeoutInterval: 30000,
98+
print: function() {},
99+
},
100+
101+
onPrepare() {
102+
// Fix for Safari 12 -- https://github.com/angular/protractor/issues/4964
103+
browser.resetUrl = 'about:blank';
104+
105+
require('ts-node').register({
106+
project: require('path').join(__dirname, './tsconfig.json'),
107+
});
108+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
109+
},
110+
};

0 commit comments

Comments
 (0)