hs-test: fixed timed out tests passing in the CI
[vpp.git] / extras / hs-test / Makefile
1 export HS_ROOT=$(CURDIR)
2
3 ifeq ($(VERBOSE),)
4 VERBOSE=false
5 endif
6
7 ifeq ($(PERSIST),)
8 PERSIST=false
9 endif
10
11 ifeq ($(UNCONFIGURE),)
12 UNCONFIGURE=false
13 endif
14
15 ifeq ($(TEST),)
16 TEST=all
17 endif
18
19 ifeq ($(DEBUG),)
20 DEBUG=false
21 endif
22
23 ifeq ($(CPUS),)
24 CPUS=1
25 endif
26
27 ifeq ($(PARALLEL),)
28 PARALLEL=1
29 endif
30
31 ifeq ($(REPEAT),)
32 REPEAT=0
33 endif
34
35 ifeq ($(VPPSRC),)
36 VPPSRC=$(shell pwd)/../..
37 endif
38
39 ifeq ($(UBUNTU_CODENAME),)
40 UBUNTU_CODENAME=$(shell grep '^UBUNTU_CODENAME=' /etc/os-release | cut -f2- -d=)
41 endif
42
43 ifeq ($(ARCH),)
44 ARCH=$(shell dpkg --print-architecture)
45 endif
46
47 list_tests = @go run github.com/onsi/ginkgo/v2/ginkgo --dry-run -v --no-color --seed=2 | head -n -1 | grep 'Test' | \
48                 sed 's/^/* /; s/\(Suite\) /\1\//g'
49
50 .PHONY: help
51 help:
52         @echo "Make targets:"
53         @echo " test                 - run tests"
54         @echo " test-debug           - run tests (vpp debug image)"
55         @echo " build                - build test infra"
56         @echo " build-debug          - build test infra (vpp debug image)"
57         @echo " build-go             - just build golang files"
58         @echo " fixstyle             - format .go source files"
59         @echo " list-tests           - list all tests"
60         @echo
61         @echo "make build arguments:"
62         @echo " UBUNTU_VERSION           - ubuntu version for docker image"
63         @echo " HST_EXTENDED_TESTS       - build extended tests"
64         @echo
65         @echo "make test arguments:"
66         @echo " PERSIST=[true|false]     - whether clean up topology and dockers after test"
67         @echo " VERBOSE=[true|false]     - verbose output"
68         @echo " UNCONFIGURE=[true|false] - unconfigure selected test"
69         @echo " DEBUG=[true|false]       - attach VPP to GDB"
70         @echo " TEST=[test-name]         - specific test to run"
71         @echo " CPUS=[n-cpus]            - number of cpus to run with vpp"
72         @echo " VPPSRC=[path-to-vpp-src] - path to vpp source files (for gdb)"
73         @echo " PARALLEL=[n-cpus]        - number of test processes to spawn to run in parallel"
74         @echo " REPEAT=[n]               - repeat tests up to N times or until a failure occurs"
75         @echo
76         @echo "List of all tests:"
77         $(call list_tests)
78
79 .PHONY: list-tests
80 list-tests:
81         $(call list_tests)
82
83 .PHONY: build-vpp-release
84 build-vpp-release:
85         @make -C ../.. build-release
86
87 .PHONY: build-vpp-debug
88 build-vpp-debug:
89         @make -C ../.. build
90
91 .build.ok: build
92         @touch .build.ok
93
94 .build_debug.ok: build-debug
95         @touch .build.ok
96
97 .PHONY: test
98 test: .deps.ok .build.ok
99         # '-' ignores the exit status, it is set in compress.sh
100         # necessary so gmake won't skip executing the bash script
101         -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
102                 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
103                 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
104         @bash ./script/compress.sh
105
106 .PHONY: test-debug
107 test-debug: .deps.ok .build_debug.ok
108         # '-' ignores the exit status, it is set in compress.sh
109         # necessary so gmake won't skip executing the bash script
110         -bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
111                 --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
112                 --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT)
113         @bash ./script/compress.sh
114
115 .PHONY: build-go
116 build-go:
117         go build ./tools/http_server
118
119 .PHONY: build
120 build: .deps.ok build-vpp-release build-go
121         @rm -f .build.ok
122         bash ./script/build_hst.sh release
123         @touch .build.ok
124
125 .PHONY: build-debug
126 build-debug: .deps.ok build-vpp-debug build-go
127         @rm -f .build.ok
128         bash ./script/build_hst.sh debug
129         @touch .build.ok
130
131 .deps.ok:
132         @sudo make install-deps
133
134 .PHONY: install-deps
135 install-deps:
136         @rm -f .deps.ok
137         @apt-get update \
138                 && apt-get install -y apt-transport-https ca-certificates curl software-properties-common \
139                 apache2-utils wrk bridge-utils
140         @if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ] ; then \
141                 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \
142                 echo "deb [arch=$(ARCH) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(UBUNTU_CODENAME) stable" \
143                         | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ; \
144                 apt-get update; \
145         fi
146         @touch .deps.ok
147
148 .PHONY: fixstyle
149 fixstyle:
150         @gofmt -w .
151         @go mod tidy