Skip to content

Commit

Permalink
Feature functional tests for smoke vectors (#3515)
Browse files Browse the repository at this point in the history
* Add list of smoke test vectors

* Add option to specify the path to the source.json for the functional tests

* Change config.yml to launch smoke vector tests after each push to development

* Fix a bug in config.yml

* Change config.yml config

* Upgrade CircleCI yaml to 2.1

Get rid of yaml anchor notation
Make use of 2.1 commands
Make use of executor
Replace deprecated image circleci/node:10.20.1 with cimg/node:10.20.1

* Add PR workflow for testing

Commits on a PR branch will be unit tested and functional tests are run with one test vector for plausibility.
In parallel a virtual merge is perfomed (PR branch into development) and unit tests are run then a set of smoke vectors are used for the functional tests.

* Run functional tests only on non-forked branches

* Check if env vers are set before using them

Co-authored-by: Martin Lasak <martin.lasak@fokus.fraunhofer.de>
  • Loading branch information
dsilhavy and mlasak authored Feb 25, 2021
1 parent 6afaaaa commit f87c2ed
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 110 deletions.
257 changes: 156 additions & 101 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,161 @@
version: 2

_defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:10.20.1

_steps:
restore_cache: &restore_cache
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

install_dependencies: &install_dependencies
name: Install dependencies
command: npm install

save_cache: &save_cache
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
version: 2.1

executors:
dashjs-executor:
working_directory: ~/repo
docker:
- image: cimg/node:10.20.1

commands:
dependencies_setup:
steps:
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install dependencies
command: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

functional_precondition:
steps:
- run:
name: Check if preconditions are met for functional tests
command: |
if [ -z "$BROWSERSTACK_ACCESS_KEY" ]; then
echo "BrowserStack not configured, functional tests will not be executed."
circleci-agent step halt
fi
functional_test_setup:
steps:
- run:
name: Download the browserstack binary file to create a tunnel
command: wget "https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip"
- run:
name: Unzip the browserstack binary file
command: unzip BrowserStackLocal-linux-x64.zip
- run:
name: Run browserstack with provided access key
command: ./BrowserStackLocal $BROWSERSTACK_ACCESS_KEY
background: true

build_unit_test_steps:
steps:
- run:
name: Build and run unit tests
command: npm run build

jobs:
build:
<<: *defaults

steps:
- checkout
- restore_cache: *restore_cache
- run: *install_dependencies
- save_cache: *save_cache

# run build and tests
- run:
name: Build and Test
command: npm run build

# deploy
- deploy:
name: Deploy
command: |
if [ "${CIRCLE_BRANCH}" = "development" ]; then
sudo npm install -g grunt-cli
grunt deploy --git-commit=$CIRCLE_SHA1 --ftp-host=$DEPLOY_HOST --ftp-user=$DEPLOY_USER --ftp-pass=$DEPLOY_PASSWORD
else
echo "Not development branch, dry run only"
fi
functional-tests:
<<: *defaults

steps:
- checkout
- restore_cache: *restore_cache
- run: *install_dependencies
- save_cache: *save_cache
# run functional tests
- run:
# Download the browserstack binary file to create a tunnel
name: Download Browserstack
command: wget "https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip"

- run:
# Unzip the browserstack binary file
name: Install Browserstack
command: unzip BrowserStackLocal-linux-x64.zip

- run:
# Run browserstack with your access key
name: Run Browserstack
command: ./BrowserStackLocal $BROWSERSTACK_ACCESS_KEY
background: true

- run:
# Run functional tests for chrome browser for https
name: Run functional tests (chrome / https)
command:
node test/functional/runTests.js --selenium=remote --reporters=junit --app=remote --browsers=chrome --protocol=https

- run:
# Run functional tests for chrome browser for http
name: Run functional tests (chrome / http)
when: always # run tests even if some previous tests failed
command:
node test/functional/runTests.js --selenium=remote --reporters=junit --app=remote --browsers=chrome --protocol=http

- store_test_results:
path: test/functional/reports
build-and-unit-test:
executor: dashjs-executor
steps:
- checkout
- dependencies_setup
- build_unit_test_steps
- deploy:
name: Deploy
command: |
if [ "${CIRCLE_BRANCH}" = "development" ] && [ -n "$DEPLOY_HOST" ] && [ -n "$DEPLOY_USER" ] && [ -n "$DEPLOY_PASSWORD" ]; then
sudo npm install -g grunt-cli
grunt deploy --git-commit=$CIRCLE_SHA1 --ftp-host=$DEPLOY_HOST --ftp-user=$DEPLOY_USER --ftp-pass=$DEPLOY_PASSWORD
else
echo "Not on development branch or deploy not configured. Dry run only, nothing will be deployed."
fi
merge-build-and-unit-test:
executor: dashjs-executor
steps:
- checkout
- run:
name: Merge into development virtually
command: |
git config --global user.email "circleci@example.com"
git config --global user.name "CircleCI"
git checkout development
git merge --no-edit --no-ff $CIRCLE_BRANCH
- dependencies_setup
- build_unit_test_steps

functional-tests-smoke:
executor: dashjs-executor
steps:
- functional_precondition
- checkout
- run:
name: Virtual merge into development branch
command: |
if [ "${CIRCLE_BRANCH}" = "development" ]; then
echo "On development branch already, no merge needed"
else
git config --global user.email "circleci@example.com"
git config --global user.name "CircleCI"
git checkout development
git merge --no-edit --no-ff $CIRCLE_BRANCH
fi
- dependencies_setup
- build_unit_test_steps
- functional_test_setup
- run:
name: Run functional tests for one vector (chrome / https)
command:
node test/functional/runTests.js --selenium=remote --reporters=junit --app=remote --browsers=chrome --protocol=https --source=./test/functional/config/singleVector.json
- run:
name: Run functional tests for smoke vectors (chrome / https)
command:
node test/functional/runTests.js --selenium=remote --reporters=junit --app=remote --browsers=chrome --protocol=https --source=./test/functional/config/smokeVectors.json
- store_test_results:
path: test/functional/reports

functional-tests-all:
executor: dashjs-executor
steps:
- functional_precondition
- checkout
- dependencies_setup
- build_unit_test_steps
- functional_test_setup
- run:
name: Run functional tests (chrome / https)
command:
node test/functional/runTests.js --selenium=remote --reporters=junit --app=remote --browsers=chrome --protocol=https
- run:
name: Run functional tests (chrome / http)
when: always # run tests even if some previous tests failed
command:
node test/functional/runTests.js --selenium=remote --reporters=junit --app=remote --browsers=chrome --protocol=http
- store_test_results:
path: test/functional/reports

workflows:
version: 2
commit-workflow:
jobs:
- build
scheduled-workflow:
triggers:
- schedule:
cron: "0 0 * * 0"
filters:
branches:
only:
- development
jobs:
- functional-tests
version: 2
commit-workflow:
jobs:
- build-and-unit-test # run unit tests on feature branch
- merge-build-and-unit-test: # run unit tests on virtually merged feature branch
filters:
branches:
ignore:
- development # skiping redundant job if already on development
- functional-tests-smoke:
filters:
branches:
ignore: # as creds are available only for non-forked branches
- /pull\/[0-9]+/

scheduled-workflow:
triggers:
- schedule:
cron: "0 0 * * 0"
filters:
branches:
only:
- development
jobs:
- functional-tests-all

14 changes: 14 additions & 0 deletions test/functional/config/singleVector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"items": [
{
"name": "Video on Demand (VoD)",
"submenu": [
{
"url": "https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd",
"name": "Segment Template, number based",
"description": "Segment Template, number based"
}
]
}
]
}
64 changes: 64 additions & 0 deletions test/functional/config/smokeVectors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"items": [
{
"name": "Video on Demand (VoD)",
"submenu": [
{
"url": "https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd",
"name": "Segment Template, number based",
"description": "Segment Template, number based"
},
{
"url": "https://dash.akamaized.net/dash264/TestCases/1a/sony/SNE_DASH_SD_CASE1A_REVISED.mpd",
"name": "Segment Base",
"description": "Segment Base"
},
{
"url": "https://dash.akamaized.net/dash264/TestCases/2c/qualcomm/1/MultiResMPEG2.mpd",
"name": "Segment Timeline, time based",
"description": "Segment Timeline, time based"
},
{
"url": "//wowzaec2demo.streamlock.net/vod/_definst_/ElephantsDream/smil:ElephantsDream.smil/manifest_mvlist.mpd",
"name": "Clear Segment List",
"description": "Clear Segment List"
},
{
"url": "https://dash.akamaized.net/dash264/TestCases/4b/qualcomm/2/TearsOfSteel_onDem5secSegSubTitles.mpd",
"name": "Fragmented text, TTML",
"description": "Fragmented text, TTML"
},
{
"url": "https://media.axprod.net/TestVectors/v7-Clear/Manifest_1080p.mpd",
"name": "Multi Audio",
"description": "Multi Audio"
},
{
"url": "https://dash.akamaized.net/dash264/TestCases/5a/nomor/1.mpd",
"name": "Multiperiod with presentationTimeOffset",
"description": "Multiperiod with presentationTimeOffset"
}
]
},
{
"name": "Live content",
"submenu": [
{
"url": "https://livesim.dashif.org/livesim/testpic_2s/Manifest.mpd",
"name": "Segment Template without manifest updates",
"description": "Segment Template without manifest updates"
},
{
"url": "https://livesim.dashif.org/livesim/segtimeline_1/testpic_2s/Manifest.mpd",
"name": "Segment Timeline",
"description": "Segment Timeline"
},
{
"url": "https://livesim.dashif.org/livesim/periods_60/continuous_1/testpic_2s/Manifest.mpd",
"name": "Multiperiod Segment Template",
"description": "Multiperiod Segment Template"
}
]
}
]
}
Loading

0 comments on commit f87c2ed

Please sign in to comment.