Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 1 | # 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 Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 15 | # use bash for pushd/popd, and to fail quickly. virtualenv's activate |
| 16 | # has undefined variables, so no -u |
| 17 | SHELL = bash -e -o pipefail |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 18 | ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 19 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 20 | # Variables |
Gilles Depatie | 6c727ff | 2019-10-21 16:23:13 -0400 | [diff] [blame] | 21 | LINT_ARGS ?= --verbose --configure LineTooLong:120 --configure TooManyTestSteps:15 \ |
| 22 | --configure TooFewTestSteps:1 --configure TooFewKeywordSteps:1 |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 23 | VERSION ?= $(shell cat ./VERSION) |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 24 | ROBOT_SANITY_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 25 | ROBOT_FAIL_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind.yaml |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 26 | ROBOT_SANITY_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-2x2.yaml |
| 27 | ROBOT_SCALE_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-16.yaml |
| 28 | ROBOT_SCALE_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x2.yaml |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 29 | ROBOT_DEBUG_LOG_OPT ?= |
Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 30 | |
hwchiu | 1128912 | 2019-11-27 16:20:15 +0000 | [diff] [blame] | 31 | ROBOT_SYSTEM_SETUP_MISC_ARGS ?= -i scaledown -l systemup_log.html -r systemup_report.html -o systemup_output.xml |
| 32 | ROBOT_SYSTEM_TEARDOWN_MISC_ARGS ?= -i scaleup -l systemdown_log.html -r systemdown_report.html -o sysstemdown_output.xml |
| 33 | ROBOT_SYSTEM_FILE ?= K8S_SystemTest.robot |
| 34 | |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 35 | .PHONY: gendocs |
| 36 | |
| 37 | ## Variables for gendocs |
| 38 | TEST_SOURCE := $(wildcard tests/*/*.robot) |
| 39 | TEST_BASENAME := $(basename $(TEST_SOURCE)) |
| 40 | TEST_DIRS := $(dir $(TEST_SOURCE)) |
| 41 | |
| 42 | LIB_SOURCE := $(wildcard libraries/*.robot) |
| 43 | LIB_BASENAME := $(basename $(LIB_SOURCE)) |
| 44 | LIB_DIRS := $(dir $(LIB_SOURCE)) |
| 45 | |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 46 | ROBOT_MISC_ARGS ?= |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 47 | |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 48 | # for backwards compatibility |
| 49 | sanity-kind: sanity-single-kind |
| 50 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 51 | sanity-single-kind: ROBOT_MISC_ARGS += -i sanity $(ROBOT_DEBUG_LOG_OPT) |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 52 | sanity-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE) |
| 53 | sanity-single-kind: bbsim-kind |
| 54 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 55 | rwcore-restart-single-kind: ROBOT_MISC_ARGS += -X -i bbsimANDrwcore-restart $(ROBOT_DEBUG_LOG_OPT) |
| 56 | rwcore-restart-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_FAIL_SINGLE_PON_FILE) |
| 57 | rwcore-restart-single-kind: ROBOT_FILE := Voltha_PODTests.robot |
| 58 | rwcore-restart-single-kind: voltha-test |
| 59 | |
| 60 | sanity-multi-kind: ROBOT_MISC_ARGS += -i sanity $(ROBOT_DEBUG_LOG_OPT) |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 61 | sanity-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE) |
| 62 | sanity-multi-kind: bbsim-kind |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 63 | |
Suchitra Vemuri | 8a9c378 | 2019-10-23 12:43:01 -0700 | [diff] [blame] | 64 | bbsim-kind: ROBOT_MISC_ARGS += -X |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 65 | bbsim-kind: ROBOT_FILE := Voltha_PODTests.robot |
| 66 | bbsim-kind: voltha-test |
| 67 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 68 | scale-single-kind: ROBOT_MISC_ARGS += -i active $(ROBOT_DEBUG_LOG_OPT) |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 69 | scale-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_SINGLE_PON_FILE) |
| 70 | scale-single-kind: bbsim-scale-kind |
| 71 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 72 | scale-multi-kind: ROBOT_MISC_ARGS += -i active $(ROBOT_DEBUG_LOG_OPT) |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 73 | scale-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_PON_FILE) |
| 74 | scale-multi-kind: bbsim-scale-kind |
| 75 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 76 | bbsim-scale-kind: ROBOT_MISC_ARGS += -X $(ROBOT_DEBUG_LOG_OPT) |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 77 | bbsim-scale-kind: ROBOT_FILE := Voltha_ScaleFunctionalTests.robot |
| 78 | bbsim-scale-kind: voltha-test |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 79 | |
hwchiu | 1128912 | 2019-11-27 16:20:15 +0000 | [diff] [blame] | 80 | system-scale-test: ROBOT_FILE := Voltha_PODTests.robot |
| 81 | system-scale-test: ROBOT_MISC_ARGS += -X -i sanity |
| 82 | system-scale-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE) |
| 83 | system-scale-test: k8s-system-test |
| 84 | |
Andy Bavier | 70eab04 | 2019-12-14 14:16:26 -0700 | [diff] [blame^] | 85 | voltha-test: ROBOT_MISC_ARGS += -e notready |
| 86 | k8s-system-test: ROBOT_MISC_ARGS += -e notready |
| 87 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 88 | # virtualenv for the robot tools |
| 89 | vst_venv: |
| 90 | virtualenv $@ ;\ |
| 91 | source ./$@/bin/activate ;\ |
| 92 | pip install -r requirements.txt |
| 93 | |
| 94 | test: lint |
| 95 | |
| 96 | lint: 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 |
| 103 | tidy: |
| 104 | source ./vst_venv/bin/activate ;\ |
| 105 | set -u ;\ |
| 106 | find . -name *.robot -exec python -m robot.tidy --inplace {} \; |
| 107 | |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 108 | voltha-test: vst_venv |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 109 | source ./vst_venv/bin/activate ;\ |
| 110 | set -u ;\ |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 111 | cd tests/functional ;\ |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 112 | robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE) |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 113 | |
hwchiu | 1128912 | 2019-11-27 16:20:15 +0000 | [diff] [blame] | 114 | #bbsim-only |
| 115 | k8s-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 Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 123 | gendocs: vst_venv |
| 124 | source ./vst_venv/bin/activate ;\ |
| 125 | set -u ;\ |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 126 | 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 Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 135 | |
| 136 | # explore use of --docformat REST - integration w/Sphinx? |
| 137 | clean: |
| 138 | find . -name output.xml -print |
| 139 | |
| 140 | clean-all: clean |
| 141 | rm -rf vst_venv gendocs |