blob: 48d9dd5b515c40b489bfb767e224ac3ade63b752 [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
Zack Williamsec53a1b2019-09-16 15:50:52 -070085# virtualenv for the robot tools
86vst_venv:
87 virtualenv $@ ;\
88 source ./$@/bin/activate ;\
89 pip install -r requirements.txt
90
91test: lint
92
93lint: vst_venv
94 source ./vst_venv/bin/activate ;\
95 set -u ;\
96 find . -name *.robot -exec rflint $(LINT_ARGS) {} +
97
98# tidy will be more useful once this issue with removing leading comments is
99# resolved: https://github.com/robotframework/robotframework/issues/3263
100tidy:
101 source ./vst_venv/bin/activate ;\
102 set -u ;\
103 find . -name *.robot -exec python -m robot.tidy --inplace {} \;
104
Gilles Depatie45fbe042019-11-11 17:10:06 -0500105voltha-test: vst_venv
Zack Williamsec53a1b2019-09-16 15:50:52 -0700106 source ./vst_venv/bin/activate ;\
107 set -u ;\
Andy Bavierba9866b2019-10-11 07:11:53 -0700108 cd tests/functional ;\
Gilles Depatie45fbe042019-11-11 17:10:06 -0500109 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
hwchiu0601ec72019-10-08 00:04:43 +0000110
hwchiu11289122019-11-27 16:20:15 +0000111#bbsim-only
112k8s-system-test: vst_venv
113 source ./vst_venv/bin/activate ;\
114 set -u ;\
115 cd tests/functional ;\
116 robot $(ROBOT_SYSTEM_SETUP_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE) && \
117 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE) && \
118 robot $(ROBOT_SYSTEM_TEARDOWN_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE)
119
Zack Williamsec53a1b2019-09-16 15:50:52 -0700120gendocs: vst_venv
121 source ./vst_venv/bin/activate ;\
122 set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +0000123 mkdir -p $@ ;\
124 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
125 for dir in ${LIB_BASENAME}; do\
126 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
127 done ;\
128 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
129 for dir in ${TEST_BASENAME}; do\
130 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
131 done
Zack Williamsec53a1b2019-09-16 15:50:52 -0700132
133# explore use of --docformat REST - integration w/Sphinx?
134clean:
135 find . -name output.xml -print
136
137clean-all: clean
138 rm -rf vst_venv gendocs