blob: 6aee2eab2da9d1460ce9de850695341a744b3458 [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
17SHELL = bash -e -o pipefail
Andy Bavierba9866b2019-10-11 07:11:53 -070018ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
Kailash92764922019-07-25 08:21:39 -070019
Zack Williamsec53a1b2019-09-16 15:50:52 -070020# Variables
Gilles Depatie6c727ff2019-10-21 16:23:13 -040021LINT_ARGS ?= --verbose --configure LineTooLong:120 --configure TooManyTestSteps:15 \
22 --configure TooFewTestSteps:1 --configure TooFewKeywordSteps:1
Zack Williamsec53a1b2019-09-16 15:50:52 -070023VERSION ?= $(shell cat ./VERSION)
Gilles Depatie45fbe042019-11-11 17:10:06 -050024ROBOT_SANITY_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml
David Bainbridgef81cd642019-11-20 00:14:47 +000025ROBOT_FAIL_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml
Gilles Depatie45fbe042019-11-11 17:10:06 -050026ROBOT_SANITY_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-2x2.yaml
27ROBOT_SCALE_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-16.yaml
28ROBOT_SCALE_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x2.yaml
David Bainbridgef81cd642019-11-20 00:14:47 +000029ROBOT_DEBUG_LOG_OPT ?=
Kailash92764922019-07-25 08:21:39 -070030
hwchiu11289122019-11-27 16:20:15 +000031ROBOT_SYSTEM_SETUP_MISC_ARGS ?= -i scaledown -l systemup_log.html -r systemup_report.html -o systemup_output.xml
32ROBOT_SYSTEM_TEARDOWN_MISC_ARGS ?= -i scaleup -l systemdown_log.html -r systemdown_report.html -o sysstemdown_output.xml
33ROBOT_SYSTEM_FILE ?= K8S_SystemTest.robot
34
hwchiu0601ec72019-10-08 00:04:43 +000035.PHONY: gendocs
36
37## Variables for gendocs
38TEST_SOURCE := $(wildcard tests/*/*.robot)
39TEST_BASENAME := $(basename $(TEST_SOURCE))
40TEST_DIRS := $(dir $(TEST_SOURCE))
41
42LIB_SOURCE := $(wildcard libraries/*.robot)
43LIB_BASENAME := $(basename $(LIB_SOURCE))
44LIB_DIRS := $(dir $(LIB_SOURCE))
45
Andy Bavierba9866b2019-10-11 07:11:53 -070046ROBOT_MISC_ARGS ?=
hwchiu0601ec72019-10-08 00:04:43 +000047
Gilles Depatie45fbe042019-11-11 17:10:06 -050048# for backwards compatibility
49sanity-kind: sanity-single-kind
50
David Bainbridgef81cd642019-11-20 00:14:47 +000051sanity-single-kind: ROBOT_MISC_ARGS += -i sanity $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -050052sanity-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
53sanity-single-kind: bbsim-kind
54
David Bainbridgef81cd642019-11-20 00:14:47 +000055rwcore-restart-single-kind: ROBOT_MISC_ARGS += -X -i bbsimANDrwcore-restart $(ROBOT_DEBUG_LOG_OPT)
56rwcore-restart-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_FAIL_SINGLE_PON_FILE)
57rwcore-restart-single-kind: ROBOT_FILE := Voltha_PODTests.robot
58rwcore-restart-single-kind: voltha-test
59
60sanity-multi-kind: ROBOT_MISC_ARGS += -i sanity $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -050061sanity-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
62sanity-multi-kind: bbsim-kind
Andy Bavierba9866b2019-10-11 07:11:53 -070063
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -070064bbsim-kind: ROBOT_MISC_ARGS += -X
Gilles Depatie45fbe042019-11-11 17:10:06 -050065bbsim-kind: ROBOT_FILE := Voltha_PODTests.robot
66bbsim-kind: voltha-test
67
David Bainbridgef81cd642019-11-20 00:14:47 +000068scale-single-kind: ROBOT_MISC_ARGS += -i active $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -050069scale-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_SINGLE_PON_FILE)
70scale-single-kind: bbsim-scale-kind
71
David Bainbridgef81cd642019-11-20 00:14:47 +000072scale-multi-kind: ROBOT_MISC_ARGS += -i active $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -050073scale-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_PON_FILE)
74scale-multi-kind: bbsim-scale-kind
75
David Bainbridgef81cd642019-11-20 00:14:47 +000076bbsim-scale-kind: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT)
Gilles Depatie45fbe042019-11-11 17:10:06 -050077bbsim-scale-kind: ROBOT_FILE := Voltha_ScaleFunctionalTests.robot
78bbsim-scale-kind: voltha-test
Zack Williamsec53a1b2019-09-16 15:50:52 -070079
hwchiu11289122019-11-27 16:20:15 +000080system-scale-test: ROBOT_FILE := Voltha_PODTests.robot
81system-scale-test: ROBOT_MISC_ARGS += -X -i sanity
82system-scale-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
83system-scale-test: k8s-system-test
84
Andy Bavier70eab042019-12-14 14:16:26 -070085voltha-test: ROBOT_MISC_ARGS += -e notready
86k8s-system-test: ROBOT_MISC_ARGS += -e notready
87
Zack Williamsec53a1b2019-09-16 15:50:52 -070088# virtualenv for the robot tools
89vst_venv:
90 virtualenv $@ ;\
91 source ./$@/bin/activate ;\
92 pip install -r requirements.txt
93
94test: lint
95
96lint: vst_venv
97 source ./vst_venv/bin/activate ;\
98 set -u ;\
99 find . -name *.robot -exec rflint $(LINT_ARGS) {} +
100
101# tidy will be more useful once this issue with removing leading comments is
102# resolved: https://github.com/robotframework/robotframework/issues/3263
103tidy:
104 source ./vst_venv/bin/activate ;\
105 set -u ;\
106 find . -name *.robot -exec python -m robot.tidy --inplace {} \;
107
Gilles Depatie45fbe042019-11-11 17:10:06 -0500108voltha-test: vst_venv
Zack Williamsec53a1b2019-09-16 15:50:52 -0700109 source ./vst_venv/bin/activate ;\
110 set -u ;\
Andy Bavierba9866b2019-10-11 07:11:53 -0700111 cd tests/functional ;\
Gilles Depatie45fbe042019-11-11 17:10:06 -0500112 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
hwchiu0601ec72019-10-08 00:04:43 +0000113
hwchiu11289122019-11-27 16:20:15 +0000114#bbsim-only
115k8s-system-test: vst_venv
116 source ./vst_venv/bin/activate ;\
117 set -u ;\
118 cd tests/functional ;\
119 robot $(ROBOT_SYSTEM_SETUP_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE) && \
120 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE) && \
121 robot $(ROBOT_SYSTEM_TEARDOWN_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE)
122
Zack Williamsec53a1b2019-09-16 15:50:52 -0700123gendocs: vst_venv
124 source ./vst_venv/bin/activate ;\
125 set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +0000126 mkdir -p $@ ;\
127 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
128 for dir in ${LIB_BASENAME}; do\
129 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
130 done ;\
131 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
132 for dir in ${TEST_BASENAME}; do\
133 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
134 done
Zack Williamsec53a1b2019-09-16 15:50:52 -0700135
136# explore use of --docformat REST - integration w/Sphinx?
137clean:
138 find . -name output.xml -print
139
140clean-all: clean
141 rm -rf vst_venv gendocs