blob: 0026def2f394899df384a17cf93de5f5232e7a6d [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
hwchiu85695932019-12-18 08:05:25 +000085failure-test: ROBOT_MISC_ARGS += -X -i FailureTest $(ROBOT_DEBUG_LOG_OPT)
86failure-test: ROBOT_FILE := $(ROBOT_SYSTEM_FILE)
87failure-test: ROBOT_CONFIG_FILE := $(ROBOT_FAIL_SINGLE_PON_FILE)
88failure-test: voltha-test
89
Andy Bavier70eab042019-12-14 14:16:26 -070090voltha-test: ROBOT_MISC_ARGS += -e notready
91k8s-system-test: ROBOT_MISC_ARGS += -e notready
92
Zack Williamsec53a1b2019-09-16 15:50:52 -070093# virtualenv for the robot tools
94vst_venv:
95 virtualenv $@ ;\
96 source ./$@/bin/activate ;\
97 pip install -r requirements.txt
98
99test: lint
100
101lint: vst_venv
102 source ./vst_venv/bin/activate ;\
103 set -u ;\
104 find . -name *.robot -exec rflint $(LINT_ARGS) {} +
105
106# tidy will be more useful once this issue with removing leading comments is
107# resolved: https://github.com/robotframework/robotframework/issues/3263
108tidy:
109 source ./vst_venv/bin/activate ;\
110 set -u ;\
111 find . -name *.robot -exec python -m robot.tidy --inplace {} \;
112
Gilles Depatie45fbe042019-11-11 17:10:06 -0500113voltha-test: vst_venv
Zack Williamsec53a1b2019-09-16 15:50:52 -0700114 source ./vst_venv/bin/activate ;\
115 set -u ;\
Andy Bavierba9866b2019-10-11 07:11:53 -0700116 cd tests/functional ;\
Gilles Depatie45fbe042019-11-11 17:10:06 -0500117 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE)
hwchiu0601ec72019-10-08 00:04:43 +0000118
hwchiu11289122019-11-27 16:20:15 +0000119#bbsim-only
120k8s-system-test: vst_venv
121 source ./vst_venv/bin/activate ;\
122 set -u ;\
123 cd tests/functional ;\
124 robot $(ROBOT_SYSTEM_SETUP_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE) && \
125 robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE) && \
126 robot $(ROBOT_SYSTEM_TEARDOWN_MISC_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_SYSTEM_FILE)
127
Zack Williamsec53a1b2019-09-16 15:50:52 -0700128gendocs: vst_venv
129 source ./vst_venv/bin/activate ;\
130 set -u ;\
hwchiu0601ec72019-10-08 00:04:43 +0000131 mkdir -p $@ ;\
132 for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
133 for dir in ${LIB_BASENAME}; do\
134 python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
135 done ;\
136 for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
137 for dir in ${TEST_BASENAME}; do\
138 python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
139 done
Zack Williamsec53a1b2019-09-16 15:50:52 -0700140
141# explore use of --docformat REST - integration w/Sphinx?
142clean:
143 find . -name output.xml -print
144
145clean-all: clean
146 rm -rf vst_venv gendocs