blob: 4343b64daa28fd7a815c10647a6e254e1ddd3365 [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
25ROBOT_SANITY_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-2x2.yaml
26ROBOT_SCALE_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-16.yaml
27ROBOT_SCALE_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x2.yaml
Kailash92764922019-07-25 08:21:39 -070028
hwchiu11289122019-11-27 16:20:15 +000029ROBOT_SYSTEM_SETUP_MISC_ARGS ?= -i scaledown -l systemup_log.html -r systemup_report.html -o systemup_output.xml
30ROBOT_SYSTEM_TEARDOWN_MISC_ARGS ?= -i scaleup -l systemdown_log.html -r systemdown_report.html -o sysstemdown_output.xml
31ROBOT_SYSTEM_FILE ?= K8S_SystemTest.robot
32
hwchiu0601ec72019-10-08 00:04:43 +000033.PHONY: gendocs
34
35## Variables for gendocs
36TEST_SOURCE := $(wildcard tests/*/*.robot)
37TEST_BASENAME := $(basename $(TEST_SOURCE))
38TEST_DIRS := $(dir $(TEST_SOURCE))
39
40LIB_SOURCE := $(wildcard libraries/*.robot)
41LIB_BASENAME := $(basename $(LIB_SOURCE))
42LIB_DIRS := $(dir $(LIB_SOURCE))
43
Andy Bavierba9866b2019-10-11 07:11:53 -070044ROBOT_MISC_ARGS ?=
hwchiu0601ec72019-10-08 00:04:43 +000045
Gilles Depatie45fbe042019-11-11 17:10:06 -050046# for backwards compatibility
47sanity-kind: sanity-single-kind
48
49sanity-single-kind: ROBOT_MISC_ARGS += -i sanity
50sanity-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
51sanity-single-kind: bbsim-kind
52
53sanity-multi-kind: ROBOT_MISC_ARGS += -i sanity
54sanity-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE)
55sanity-multi-kind: bbsim-kind
Andy Bavierba9866b2019-10-11 07:11:53 -070056
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -070057bbsim-kind: ROBOT_MISC_ARGS += -X
Gilles Depatie45fbe042019-11-11 17:10:06 -050058bbsim-kind: ROBOT_FILE := Voltha_PODTests.robot
59bbsim-kind: voltha-test
60
61scale-single-kind: ROBOT_MISC_ARGS += -i active
62scale-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_SINGLE_PON_FILE)
63scale-single-kind: bbsim-scale-kind
64
65scale-multi-kind: ROBOT_MISC_ARGS += -i active
66scale-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_PON_FILE)
67scale-multi-kind: bbsim-scale-kind
68
69bbsim-scale-kind: ROBOT_MISC_ARGS += -X
70bbsim-scale-kind: ROBOT_FILE := Voltha_ScaleFunctionalTests.robot
71bbsim-scale-kind: voltha-test
Zack Williamsec53a1b2019-09-16 15:50:52 -070072
hwchiu11289122019-11-27 16:20:15 +000073system-scale-test: ROBOT_FILE := Voltha_PODTests.robot
74system-scale-test: ROBOT_MISC_ARGS += -X -i sanity
75system-scale-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE)
76system-scale-test: k8s-system-test
77
Zack Williamsec53a1b2019-09-16 15:50:52 -070078# virtualenv for the robot tools
79vst_venv:
80 virtualenv $@ ;\
81 source ./$@/bin/activate ;\
82 pip install -r requirements.txt
83
84test: lint
85
86lint: vst_venv
87 source ./vst_venv/bin/activate ;\
88 set -u ;\
89 find . -name *.robot -exec rflint $(LINT_ARGS) {} +
90
91# tidy will be more useful once this issue with removing leading comments is
92# resolved: https://github.com/robotframework/robotframework/issues/3263
93tidy:
94 source ./vst_venv/bin/activate ;\
95 set -u ;\
96 find . -name *.robot -exec python -m robot.tidy --inplace {} \;
97
Gilles Depatie45fbe042019-11-11 17:10:06 -050098voltha-test: vst_venv
Zack Williamsec53a1b2019-09-16 15:50:52 -070099 source ./vst_venv/bin/activate ;\
100 set -u ;\
Andy Bavierba9866b2019-10-11 07:11:53 -0700101 cd tests/functional ;\
Gilles Depatie45fbe042019-11-11 17:10:06 -0500102 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
hwchiu0601ec72019-10-08 00:04:43 +0000103
hwchiu11289122019-11-27 16:20:15 +0000104#bbsim-only
105k8s-system-test: vst_venv
106 source ./vst_venv/bin/activate ;\
107 set -u ;\
108 cd tests/functional ;\
109 robot $(ROBOT_SYSTEM_SETUP_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE) && \
110 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE) && \
111 robot $(ROBOT_SYSTEM_TEARDOWN_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE)
112
Zack Williamsec53a1b2019-09-16 15:50:52 -0700113gendocs: vst_venv
114 source ./vst_venv/bin/activate ;\
115 set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +0000116 mkdir -p $@ ;\
117 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
118 for dir in ${LIB_BASENAME}; do\
119 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
120 done ;\
121 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
122 for dir in ${TEST_BASENAME}; do\
123 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
124 done
Zack Williamsec53a1b2019-09-16 15:50:52 -0700125
126# explore use of --docformat REST - integration w/Sphinx?
127clean:
128 find . -name output.xml -print
129
130clean-all: clean
131 rm -rf vst_venv gendocs