blob: 159288e616909fe963d4f6b00fb9b1f66b8eb3c3 [file] [log] [blame]
Kailash92764922019-07-25 08:21:39 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Zack Williamsec53a1b2019-09-16 15:50:52 -070015# use bash for pushd/popd, and to fail quickly. virtualenv's activate
16# has undefined variables, so no -u
Zack Williamsa8fe75a2020-01-10 14:25:27 -070017SHELL := bash -e -o pipefail
Kailash92764922019-07-25 08:21:39 -070018
Zack Williamsa8fe75a2020-01-10 14:25:27 -070019ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
Kailash92764922019-07-25 08:21:39 -070020
Zack Williamsa8fe75a2020-01-10 14:25:27 -070021# Configuration and lists of files for linting/testing
22VERSION ?= $(shell cat ./VERSION)
23LINT_ARGS ?= --verbose --configure LineTooLong:120 -e LineTooLong \
Suraj Gour33651272020-05-04 10:10:16 +053024 --configure TooManyTestSteps:50 -e TooManyTestSteps \
Scott Baker27d04db2020-02-06 18:03:21 -080025 --configure TooManyTestCases:50 -e TooManyTestCases \
Zack Williamsa8fe75a2020-01-10 14:25:27 -070026 --configure TooFewTestSteps:1 \
27 --configure TooFewKeywordSteps:1 \
Suchitra Vemuri5ba33442020-05-25 22:43:40 -070028 --configure FileTooLong:1000 -e FileTooLong \
Zack Williamsa8fe75a2020-01-10 14:25:27 -070029 -e TrailingWhitespace
30
31PYTHON_FILES := $(wildcard libraries/*.py)
32ROBOT_FILES := $(shell find . -name *.robot -print)
33YAML_FILES := $(shell find ./tests -type f \( -name *.yaml -o -name *.yml \) -print)
34JSON_FILES := $(shell find ./tests -name *.json -print)
35
36# Robot config
37ROBOT_SANITY_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml
Hardik Windlassa3d04b92020-02-17 15:06:05 +000038ROBOT_SANITY_DT_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-dt.yaml
TorstenThiemebccd3ae2020-02-20 12:56:44 +000039ROBOT_SANITY_MULTIPLE_OLT_FILE ?= $(ROOT_DIR)/tests/data/multiple-bbsim-kind.yaml
Zack Williamsa8fe75a2020-01-10 14:25:27 -070040ROBOT_FAIL_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml
41ROBOT_SANITY_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-2x2.yaml
42ROBOT_SCALE_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-16.yaml
43ROBOT_SCALE_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x2.yaml
TorstenThiemeffb33922020-06-18 08:41:17 +000044ROBOT_SCALE_MULT_ONU_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x8.yaml
Zack Williamsa8fe75a2020-01-10 14:25:27 -070045ROBOT_DEBUG_LOG_OPT ?=
46ROBOT_MISC_ARGS ?=
Hardik Windlass43118692020-07-01 22:16:47 +053047# TODO: TT workflow not yet supported on BBSim
48ROBOT_SANITY_TT_SINGLE_PON_FILE ?=
Zack Williamsa8fe75a2020-01-10 14:25:27 -070049
Gilles Depatie45fbe042019-11-11 17:10:06 -050050# for backwards compatibility
51sanity-kind: sanity-single-kind
52
Matteo Scandolo142e6272020-04-29 17:36:59 -070053# for scale pipeline
54voltha-scale: ROBOT_MISC_ARGS += -i activation $(ROBOT_DEBUG_LOG_OPT)
55voltha-scale: voltha-scale-test
56
Hardik Windlassa3d04b92020-02-17 15:06:05 +000057# target to invoke DT Workflow Sanity
58sanity-kind-dt: ROBOT_MISC_ARGS += -i sanityDt $(ROBOT_DEBUG_LOG_OPT)
59sanity-kind-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_SINGLE_PON_FILE)
60sanity-kind-dt: ROBOT_FILE := Voltha_DT_PODTests.robot
61sanity-kind-dt: voltha-dt-test
62
Hardik Windlassd6aa0822020-06-29 20:18:12 +053063functional-single-kind: ROBOT_MISC_ARGS += -i sanityORfunctional -e PowerSwitch $(ROBOT_DEBUG_LOG_OPT)
Andy Bavier33e6dd32020-01-16 13:35:20 -070064functional-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
65functional-single-kind: bbsim-kind
66
Hardik Windlass35706ba2020-02-20 08:16:42 +000067# target to invoke DT Workflow Functional scenarios
Hardik Windlassd6aa0822020-06-29 20:18:12 +053068functional-single-kind-dt: ROBOT_MISC_ARGS += -i sanityDtORfunctionalDt -e PowerSwitch $(ROBOT_DEBUG_LOG_OPT)
Hardik Windlass35706ba2020-02-20 08:16:42 +000069functional-single-kind-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_SINGLE_PON_FILE)
70functional-single-kind-dt: ROBOT_FILE := Voltha_DT_PODTests.robot
71functional-single-kind-dt: voltha-dt-test
72
Suchitra Vemuri2f1e07d2020-06-26 19:18:01 -070073# target to invoke TT Workflow Sanity
Hardik Windlass43118692020-07-01 22:16:47 +053074sanity-kind-tt: ROBOT_MISC_ARGS += -i sanityTT $(ROBOT_DEBUG_LOG_OPT)
75sanity-kind-tt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TT_SINGLE_PON_FILE)
76sanity-kind-tt: ROBOT_FILE := Voltha_TT_PODTests.robot
77sanity-kind-tt: voltha-tt-test
Suchitra Vemuri2f1e07d2020-06-26 19:18:01 -070078
79# target to invoke TT Workflow Functional scenarios
Hardik Windlass43118692020-07-01 22:16:47 +053080functional-single-kind-tt: ROBOT_MISC_ARGS += -i sanityTTORfunctional -e PowerSwitch $(ROBOT_DEBUG_LOG_OPT)
Suchitra Vemuri2f1e07d2020-06-26 19:18:01 -070081functional-single-kind-tt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_TT_SINGLE_PON_FILE)
82functional-single-kind-tt: ROBOT_FILE := Voltha_TT_PODTests.robot
83functional-single-kind-tt: voltha-tt-test
84
TorstenThiemebccd3ae2020-02-20 12:56:44 +000085# target to invoke multiple OLTs Functional scenarios
86functional-multi-olt: ROBOT_MISC_ARGS += -i sanityMultiOLT $(ROBOT_DEBUG_LOG_OPT)
87functional-multi-olt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULTIPLE_OLT_FILE)
88functional-multi-olt: ROBOT_FILE := Voltha_multipleOLTTests.robot
89functional-multi-olt: voltha-test
90
TorstenThieme1619db22020-04-03 12:01:15 +000091# target to invoke openonu go adapter
Holger Hildebrandt83d48682020-07-22 09:08:10 +000092openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:5 -v testmode:SingleStateTime -v timeout:180s
TorstenThiemeffb33922020-06-18 08:41:17 +000093openonu-go-adapter-test: ROBOT_MISC_ARGS += -i onutest $(ROBOT_DEBUG_LOG_OPT)
TorstenThieme1619db22020-04-03 12:01:15 +000094openonu-go-adapter-test: ROBOT_MISC_ARGS += -X
95openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
96openonu-go-adapter-test: ROBOT_FILE := Voltha_ONUStateTests.robot
97openonu-go-adapter-test: openonu-go-adapter-statetest
98
TorstenThiemeffb33922020-06-18 08:41:17 +000099# target to invoke multiple openonu go adapter
Holger Hildebrandt83d48682020-07-22 09:08:10 +0000100multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -v state2test:5 -v testmode:SingleStateTime -v timeout:180s
TorstenThiemeffb33922020-06-18 08:41:17 +0000101multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -i onutest $(ROBOT_DEBUG_LOG_OPT)
102multi-openonu-go-adapter-test: ROBOT_MISC_ARGS += -X
103multi-openonu-go-adapter-test: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_ONU_FILE)
104multi-openonu-go-adapter-test: ROBOT_FILE := Voltha_ONUStateTests.robot
105multi-openonu-go-adapter-test: openonu-go-adapter-statetest
106
David Bainbridgef81cd642019-11-20 00:14:47 +0000107sanity-single-kind: ROBOT_MISC_ARGS += -i sanity $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -0500108sanity-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
109sanity-single-kind: bbsim-kind
110
David Bainbridge32c45632020-04-13 08:47:09 -0700111rwcore-restart-single-kind: ROBOT_MISC_ARGS += -X -i functionalANDrwcore-restart $(ROBOT_DEBUG_LOG_OPT)
David Bainbridgef81cd642019-11-20 00:14:47 +0000112rwcore-restart-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_FAIL_SINGLE_PON_FILE)
ubuntu6b6e7d42020-03-02 12:35:42 -0800113rwcore-restart-single-kind: ROBOT_FILE := Voltha_FailureScenarios.robot
David Bainbridgef81cd642019-11-20 00:14:47 +0000114rwcore-restart-single-kind: voltha-test
115
David Bainbridge3d6d5d32019-12-17 19:05:35 +0000116single-kind: ROBOT_MISC_ARGS += -X -i $(TEST_TAGS) $(ROBOT_DEBUG_LOG_OPT)
117single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
118single-kind: ROBOT_FILE := Voltha_PODTests.robot
119single-kind: voltha-test
120
David Bainbridgef81cd642019-11-20 00:14:47 +0000121sanity-multi-kind: ROBOT_MISC_ARGS += -i sanity $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -0500122sanity-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
123sanity-multi-kind: bbsim-kind
Andy Bavierba9866b2019-10-11 07:11:53 -0700124
Andy Bavier8da0e132020-04-13 10:25:16 -0700125functional-multi-kind: ROBOT_MISC_ARGS += -i sanityORfunctional $(ROBOT_DEBUG_LOG_OPT)
126functional-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
127functional-multi-kind: bbsim-kind
128
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700129bbsim-kind: ROBOT_MISC_ARGS += -X
Gilles Depatie45fbe042019-11-11 17:10:06 -0500130bbsim-kind: ROBOT_FILE := Voltha_PODTests.robot
131bbsim-kind: voltha-test
132
David Bainbridgef81cd642019-11-20 00:14:47 +0000133scale-single-kind: ROBOT_MISC_ARGS += -i active $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -0500134scale-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_SINGLE_PON_FILE)
135scale-single-kind: bbsim-scale-kind
136
David Bainbridgef81cd642019-11-20 00:14:47 +0000137scale-multi-kind: ROBOT_MISC_ARGS += -i active $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -0500138scale-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_PON_FILE)
139scale-multi-kind: bbsim-scale-kind
140
David Bainbridgef81cd642019-11-20 00:14:47 +0000141bbsim-scale-kind: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -0500142bbsim-scale-kind: ROBOT_FILE := Voltha_ScaleFunctionalTests.robot
143bbsim-scale-kind: voltha-test
Zack Williamsec53a1b2019-09-16 15:50:52 -0700144
hwchiuab524f02020-02-03 23:24:19 +0000145#Only supported in full mode
146system-scale-test: ROBOT_FILE := K8S_SystemTest.robot
hwchiu56eb85c2020-02-05 01:05:53 +0000147system-scale-test: ROBOT_MISC_ARGS += -X -i functional $(ROBOT_DEBUG_LOG_OPT)
hwchiuab524f02020-02-03 23:24:19 +0000148system-scale-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
149system-scale-test: voltha-test
hwchiu11289122019-11-27 16:20:15 +0000150
hwchiu85695932019-12-18 08:05:25 +0000151failure-test: ROBOT_MISC_ARGS += -X -i FailureTest $(ROBOT_DEBUG_LOG_OPT)
hwchiu3d9a0982020-02-06 00:19:19 +0000152failure-test: ROBOT_FILE := K8S_SystemTest.robot
hwchiu85695932019-12-18 08:05:25 +0000153failure-test: ROBOT_CONFIG_FILE := $(ROBOT_FAIL_SINGLE_PON_FILE)
154failure-test: voltha-test
155
Scott Baker60e570d2020-02-02 22:10:13 -0800156bbsim-alarms-kind: ROBOT_MISC_ARGS += -X -i active
157bbsim-alarms-kind: ROBOT_FILE := Voltha_AlarmTests.robot
Andy Baviere118e052020-03-06 12:49:24 -0700158bbsim-alarms-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
Scott Baker60e570d2020-02-02 22:10:13 -0800159bbsim-alarms-kind: voltctl-docker-image-build voltctl-docker-image-install-kind voltha-test
160
Andy Bavierc1904dc2020-03-20 11:39:15 -0700161bbsim-errorscenarios: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT)
162bbsim-errorscenarios: ROBOT_FILE := Voltha_ErrorScenarios.robot
163bbsim-errorscenarios: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
164bbsim-errorscenarios: voltha-test
165
Hardik Windlasscbcca312020-04-20 21:46:11 +0530166bbsim-errorscenarios-dt: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT)
167bbsim-errorscenarios-dt: ROBOT_FILE := Voltha_ErrorScenarios.robot
168bbsim-errorscenarios-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_SINGLE_PON_FILE)
169bbsim-errorscenarios-dt: voltha-test
170
Hardik Windlasse05e4712020-04-29 10:40:42 +0530171bbsim-failurescenarios: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT) -e PowerSwitch -e PhysicalOLTReboot
Andy Bavier8da0e132020-04-13 10:25:16 -0700172bbsim-failurescenarios: ROBOT_FILE := Voltha_FailureScenarios.robot
173bbsim-failurescenarios: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
174bbsim-failurescenarios: voltha-test
175
Hardik Windlass9df139e2020-04-24 14:54:54 +0530176bbsim-failurescenarios-dt: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT) -e PowerSwitchOnuRebootDt -e PhysicalOltRebootDt
177bbsim-failurescenarios-dt: ROBOT_FILE := Voltha_DT_FailureScenarios.robot
178bbsim-failurescenarios-dt: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_DT_SINGLE_PON_FILE)
179bbsim-failurescenarios-dt: voltha-dt-test
180
Andy Bavier70eab042019-12-14 14:16:26 -0700181voltha-test: ROBOT_MISC_ARGS += -e notready
hwchiu11289122019-11-27 16:20:15 +0000182
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700183voltha-test: vst_venv
184 source ./$</bin/activate ; set -u ;\
185 cd tests/functional ;\
186 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
187
Hardik Windlass79b40ff2020-06-11 22:55:47 +0530188voltha-dt-test: ROBOT_MISC_ARGS += -e notready
189
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000190voltha-dt-test: vst_venv
191 source ./$</bin/activate ; set -u ;\
192 cd tests/dt-workflow ;\
193 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
194
Hardik Windlass43118692020-07-01 22:16:47 +0530195voltha-tt-test: ROBOT_MISC_ARGS += -e notready
196
197voltha-tt-test: vst_venv
198 source ./$</bin/activate ; set -u ;\
199 cd tests/tt-workflow ;\
200 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
201
Matteo Scandolo142e6272020-04-29 17:36:59 -0700202voltha-scale-test: vst_venv
203 source ./$</bin/activate ; set -u ;\
204 cd tests/scale ;\
205 robot $(ROBOT_MISC_ARGS) Voltha_Scale_Tests.robot
206
TorstenThieme1619db22020-04-03 12:01:15 +0000207openonu-go-adapter-statetest: vst_venv
208 source ./$</bin/activate ; set -u ;\
209 cd tests/openonu-go-adapter ;\
210 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
211
212
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700213# self-test, lint, and setup targets
214
215# virtualenv for the robot tools
Andy Bavier952b95b2020-03-06 09:53:42 -0700216# VOL-2724 Invoke pip via python3 to avoid pathname too long on QA jobs
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700217vst_venv:
218 virtualenv -p python3 $@ ;\
219 source ./$@/bin/activate ;\
Andy Baviere118e052020-03-06 12:49:24 -0700220 python -m pip install -r requirements.txt
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700221
222test: lint
223
224lint: lint-robot lint-python lint-yaml lint-json
225
226lint-robot: vst_venv
227 source ./$</bin/activate ; set -u ;\
228 rflint $(LINT_ARGS) $(ROBOT_FILES)
229
230# check deps for format and python3 cleanliness
231lint-python: vst_venv
232 source ./$</bin/activate ; set -u ;\
233 pylint --py3k $(PYTHON_FILES) ;\
234 flake8 --max-line-length=99 --count $(PYTHON_FILES)
235
236lint-yaml: vst_venv
237 source ./$</bin/activate ; set -u ;\
238 yamllint -s $(YAML_FILES)
239
240lint-json: vst_venv
241 source ./$</bin/activate ; set -u ;\
242 for jsonfile in $(JSON_FILES); do \
243 echo "Validating json file: $$jsonfile" ;\
244 python -m json.tool $$jsonfile > /dev/null ;\
245 done
246
247# tidy target will be more useful once issue with removing leading comments
248# is resolved: https://github.com/robotframework/robotframework/issues/3263
249tidy-robot: vst_venv
250 source ./$</bin/activate ; set -u ;\
251 python -m robot.tidy --inplace $(ROBOT_FILES);
252
Andy Bavier4a8450e2020-02-04 08:58:37 -0700253# Install the 'kail' tool if needed: https://github.com/boz/kail
254KAIL_PATH ?= /usr/local/bin
255$(KAIL_PATH)/kail:
256 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b /tmp
257 mv /tmp/kail $(KAIL_PATH)
258
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700259## Variables for gendocs
260TEST_SOURCE := $(wildcard tests/*/*.robot)
261TEST_BASENAME := $(basename $(TEST_SOURCE))
262TEST_DIRS := $(dir $(TEST_SOURCE))
263
264LIB_SOURCE := $(wildcard libraries/*.robot)
265LIB_BASENAME := $(basename $(LIB_SOURCE))
266LIB_DIRS := $(dir $(LIB_SOURCE))
267
268.PHONY: gendocs lint test
269# In future explore use of --docformat REST - integration w/Sphinx?
Zack Williamsec53a1b2019-09-16 15:50:52 -0700270gendocs: vst_venv
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700271 source ./$</bin/activate ; set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +0000272 mkdir -p $@ ;\
273 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
274 for dir in ${LIB_BASENAME}; do\
275 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
276 done ;\
277 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
278 for dir in ${TEST_BASENAME}; do\
279 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
280 done
Zack Williamsec53a1b2019-09-16 15:50:52 -0700281
Zack Williamsec53a1b2019-09-16 15:50:52 -0700282clean:
283 find . -name output.xml -print
284
285clean-all: clean
286 rm -rf vst_venv gendocs
Scott Baker60e570d2020-02-02 22:10:13 -0800287
288voltctl-docker-image-build:
289 cd docker && docker build -t opencord/voltctl:local -f Dockerfile.voltctl .
290
291voltctl-docker-image-install-kind:
292 @if [ "`kind get clusters | grep voltha`" = '' ]; then echo "no voltha cluster found" && exit 1; fi
293 kind load docker-image --name `kind get clusters | grep voltha` opencord/voltctl:local