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 |
| 25 | ROBOT_SANITY_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-2x2.yaml |
| 26 | ROBOT_SCALE_SINGLE_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-16.yaml |
| 27 | ROBOT_SCALE_MULT_PON_FILE ?= $(ROOT_DIR)/tests/data/bbsim-kind-8x2.yaml |
Kailash | 9276492 | 2019-07-25 08:21:39 -0700 | [diff] [blame] | 28 | |
hwchiu | 1128912 | 2019-11-27 16:20:15 +0000 | [diff] [blame^] | 29 | ROBOT_SYSTEM_SETUP_MISC_ARGS ?= -i scaledown -l systemup_log.html -r systemup_report.html -o systemup_output.xml |
| 30 | ROBOT_SYSTEM_TEARDOWN_MISC_ARGS ?= -i scaleup -l systemdown_log.html -r systemdown_report.html -o sysstemdown_output.xml |
| 31 | ROBOT_SYSTEM_FILE ?= K8S_SystemTest.robot |
| 32 | |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 33 | .PHONY: gendocs |
| 34 | |
| 35 | ## Variables for gendocs |
| 36 | TEST_SOURCE := $(wildcard tests/*/*.robot) |
| 37 | TEST_BASENAME := $(basename $(TEST_SOURCE)) |
| 38 | TEST_DIRS := $(dir $(TEST_SOURCE)) |
| 39 | |
| 40 | LIB_SOURCE := $(wildcard libraries/*.robot) |
| 41 | LIB_BASENAME := $(basename $(LIB_SOURCE)) |
| 42 | LIB_DIRS := $(dir $(LIB_SOURCE)) |
| 43 | |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 44 | ROBOT_MISC_ARGS ?= |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 45 | |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 46 | # for backwards compatibility |
| 47 | sanity-kind: sanity-single-kind |
| 48 | |
| 49 | sanity-single-kind: ROBOT_MISC_ARGS += -i sanity |
| 50 | sanity-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE) |
| 51 | sanity-single-kind: bbsim-kind |
| 52 | |
| 53 | sanity-multi-kind: ROBOT_MISC_ARGS += -i sanity |
| 54 | sanity-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_MULT_PON_FILE) |
| 55 | sanity-multi-kind: bbsim-kind |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 56 | |
Suchitra Vemuri | 8a9c378 | 2019-10-23 12:43:01 -0700 | [diff] [blame] | 57 | bbsim-kind: ROBOT_MISC_ARGS += -X |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 58 | bbsim-kind: ROBOT_FILE := Voltha_PODTests.robot |
| 59 | bbsim-kind: voltha-test |
| 60 | |
| 61 | scale-single-kind: ROBOT_MISC_ARGS += -i active |
| 62 | scale-single-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_SINGLE_PON_FILE) |
| 63 | scale-single-kind: bbsim-scale-kind |
| 64 | |
| 65 | scale-multi-kind: ROBOT_MISC_ARGS += -i active |
| 66 | scale-multi-kind: ROBOT_CONFIG_FILE := $(ROBOT_SCALE_MULT_PON_FILE) |
| 67 | scale-multi-kind: bbsim-scale-kind |
| 68 | |
| 69 | bbsim-scale-kind: ROBOT_MISC_ARGS += -X |
| 70 | bbsim-scale-kind: ROBOT_FILE := Voltha_ScaleFunctionalTests.robot |
| 71 | bbsim-scale-kind: voltha-test |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 72 | |
hwchiu | 1128912 | 2019-11-27 16:20:15 +0000 | [diff] [blame^] | 73 | system-scale-test: ROBOT_FILE := Voltha_PODTests.robot |
| 74 | system-scale-test: ROBOT_MISC_ARGS += -X -i sanity |
| 75 | system-scale-test: ROBOT_CONFIG_FILE := $(ROBOT_SANITY_SINGLE_PON_FILE) |
| 76 | system-scale-test: k8s-system-test |
| 77 | |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 78 | # virtualenv for the robot tools |
| 79 | vst_venv: |
| 80 | virtualenv $@ ;\ |
| 81 | source ./$@/bin/activate ;\ |
| 82 | pip install -r requirements.txt |
| 83 | |
| 84 | test: lint |
| 85 | |
| 86 | lint: 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 |
| 93 | tidy: |
| 94 | source ./vst_venv/bin/activate ;\ |
| 95 | set -u ;\ |
| 96 | find . -name *.robot -exec python -m robot.tidy --inplace {} \; |
| 97 | |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 98 | voltha-test: vst_venv |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 99 | source ./vst_venv/bin/activate ;\ |
| 100 | set -u ;\ |
Andy Bavier | ba9866b | 2019-10-11 07:11:53 -0700 | [diff] [blame] | 101 | cd tests/functional ;\ |
Gilles Depatie | 45fbe04 | 2019-11-11 17:10:06 -0500 | [diff] [blame] | 102 | robot -V $(ROBOT_CONFIG_FILE) $(ROBOT_MISC_ARGS) $(ROBOT_FILE) |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 103 | |
hwchiu | 1128912 | 2019-11-27 16:20:15 +0000 | [diff] [blame^] | 104 | #bbsim-only |
| 105 | k8s-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 Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 113 | gendocs: vst_venv |
| 114 | source ./vst_venv/bin/activate ;\ |
| 115 | set -u ;\ |
hwchiu | 0601ec7 | 2019-10-08 00:04:43 +0000 | [diff] [blame] | 116 | 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 Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 125 | |
| 126 | # explore use of --docformat REST - integration w/Sphinx? |
| 127 | clean: |
| 128 | find . -name output.xml -print |
| 129 | |
| 130 | clean-all: clean |
| 131 | rm -rf vst_venv gendocs |