Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 2 | ifeq ($(VERBOSE),) |
| 3 | VERBOSE=false |
| 4 | endif |
Maros Ondrejicka | 2ddb2fd | 2023-02-15 17:44:46 +0100 | [diff] [blame] | 5 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 6 | ifeq ($(PERSIST),) |
| 7 | PERSIST=false |
| 8 | endif |
| 9 | |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 10 | ifeq ($(UNCONFIGURE),) |
| 11 | UNCONFIGURE=false |
| 12 | endif |
| 13 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 14 | ifeq ($(TEST),) |
| 15 | TEST=all |
| 16 | endif |
| 17 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 18 | ifeq ($(DEBUG),) |
| 19 | DEBUG=false |
| 20 | endif |
| 21 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 22 | ifeq ($(CPUS),) |
| 23 | CPUS=1 |
| 24 | endif |
| 25 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 26 | ifeq ($(PARALLEL),) |
| 27 | PARALLEL=1 |
| 28 | endif |
| 29 | |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 30 | ifeq ($(REPEAT),) |
| 31 | REPEAT=0 |
| 32 | endif |
| 33 | |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 34 | ifeq ($(VPPSRC),) |
| 35 | VPPSRC=$(shell pwd)/../.. |
| 36 | endif |
| 37 | |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 38 | ifeq ($(UBUNTU_CODENAME),) |
| 39 | UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=) |
| 40 | endif |
| 41 | |
| 42 | ifeq ($(ARCH),) |
| 43 | ARCH=$(shell dpkg --print-architecture) |
| 44 | endif |
| 45 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 46 | list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \ |
| 47 | sed 's/^/* /; s/\(Suite\) /\1\//g' |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 48 | |
| 49 | .PHONY: help |
| 50 | help: |
| 51 | @echo "Make targets:" |
| 52 | @echo " test - run tests" |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 53 | @echo " test-debug - run tests (vpp debug image)" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 54 | @echo " build - build test infra" |
| 55 | @echo " build-debug - build test infra (vpp debug image)" |
| 56 | @echo " build-go - just build golang files" |
| 57 | @echo " fixstyle - format .go source files" |
| 58 | @echo " list-tests - list all tests" |
| 59 | @echo |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 60 | @echo "make build arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 61 | @echo " UBUNTU_VERSION - ubuntu version for docker image" |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 62 | @echo " HST_EXTENDED_TESTS - build extended tests" |
| 63 | @echo |
| 64 | @echo "make test arguments:" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 65 | @echo " PERSIST=[true|false] - whether clean up topology and dockers after test" |
| 66 | @echo " VERBOSE=[true|false] - verbose output" |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 67 | @echo " UNCONFIGURE=[true|false] - unconfigure selected test" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 68 | @echo " DEBUG=[true|false] - attach VPP to GDB" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 69 | @echo " TEST=[test-name] - specific test to run" |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 70 | @echo " CPUS=[n-cpus] - number of cpus to run with vpp" |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 71 | @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)" |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 72 | @echo " PARALLEL=[n-cpus] - number of test processes to spawn to run in parallel" |
| 73 | @echo " REPEAT=[n] - repeat tests up to N times or until a failure occurs" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 74 | @echo |
| 75 | @echo "List of all tests:" |
| 76 | $(call list_tests) |
| 77 | |
| 78 | .PHONY: list-tests |
| 79 | list-tests: |
| 80 | $(call list_tests) |
| 81 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 82 | .PHONY: build-vpp-release |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 83 | build-vpp-release: |
| 84 | @make -C ../.. build-release |
| 85 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 86 | .PHONY: build-vpp-debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 87 | build-vpp-debug: |
| 88 | @make -C ../.. build |
| 89 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 90 | .build.ok: build |
| 91 | @touch .build.ok |
| 92 | |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 93 | .build_debug.ok: build-debug |
| 94 | @touch .build.ok |
| 95 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 96 | .PHONY: test |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 97 | test: .deps.ok .build.ok |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 98 | -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 99 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 100 | --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 101 | $(call jq-summary) |
| 102 | @bash ./script/compress.sh |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 103 | |
Matus Fabian | 2d1bc4c | 2024-05-09 10:46:58 +0200 | [diff] [blame] | 104 | .PHONY: test-debug |
| 105 | test-debug: .deps.ok .build_debug.ok |
| 106 | @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ |
| 107 | --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ |
| 108 | --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) |
| 109 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 110 | .PHONY: build-go |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 111 | build-go: |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 112 | go build ./tools/http_server |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 113 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 114 | .PHONY: build |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 115 | build: .deps.ok build-vpp-release build-go |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 116 | @rm -f .build.ok |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 117 | bash ./script/build_hst.sh release |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 118 | @touch .build.ok |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 119 | |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 120 | .PHONY: build-debug |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 121 | build-debug: .deps.ok build-vpp-debug build-go |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 122 | @rm -f .build.ok |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 123 | bash ./script/build_hst.sh debug |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 124 | @touch .build.ok |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 125 | |
Dave Wallace | d0df24d | 2023-04-26 18:03:03 -0400 | [diff] [blame] | 126 | .deps.ok: |
| 127 | @sudo make install-deps |
| 128 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 129 | .PHONY: install-deps |
| 130 | install-deps: |
Dave Wallace | 05120fb | 2023-03-07 22:09:20 -0500 | [diff] [blame] | 131 | @rm -f .deps.ok |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 132 | @apt-get update \ |
| 133 | && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \ |
Dave Wallace | 83b12bf | 2024-04-25 16:21:37 -0400 | [diff] [blame] | 134 | apache2-utils wrk bridge-utils |
Dave Wallace | f72bb6f | 2023-03-08 13:53:32 -0500 | [diff] [blame] | 135 | @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \ |
| 136 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \ |
| 137 | echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \ |
| 138 | | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \ |
| 139 | apt-get update; \ |
| 140 | fi |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 141 | @touch .deps.ok |
| 142 | |
| 143 | .PHONY: fixstyle |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 144 | fixstyle: |
| 145 | @gofmt -w . |
Maros Ondrejicka | 7d7ab10 | 2023-02-14 12:56:49 +0100 | [diff] [blame] | 146 | @go mod tidy |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 147 | |
| 148 | # splitting this into multiple lines breaks the command |
| 149 | jq-summary = @jq -r '.[0] | .SpecReports[] | select(.State == "failed") | select(.Failure != null) | "TestName: \(.LeafNodeText)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \ |
| 150 | && echo "Summary generated -> failed-summary.log" |