diff options
author | Maros Ondrejicka <mondreji@cisco.com> | 2023-02-27 16:52:57 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-02-28 16:36:41 +0000 |
commit | af004ddad1231682d0a64ce9671e2619c2910c7a (patch) | |
tree | c0631b738b8f024f5ad12ceddbbce54651ceacca /extras/hs-test | |
parent | 32881935bb82b009528ba5a930b4399bad26abfd (diff) |
hs-test: add option to unconfigure topology
Adding `UNCONFIGURE=true` argument when running `make test` will skip
test run and unconfigure existing topology for that test.
Type: test
Signed-off-by: Maros Ondrejicka <mondreji@cisco.com>
Change-Id: I197747a56ca68807f0b2c3f25b6f61c3dcc41ace
Diffstat (limited to 'extras/hs-test')
-rw-r--r-- | extras/hs-test/Makefile | 7 | ||||
-rw-r--r-- | extras/hs-test/hst_suite.go | 14 | ||||
-rw-r--r-- | extras/hs-test/suite_no_topo_test.go | 1 | ||||
-rw-r--r-- | extras/hs-test/suite_ns_test.go | 1 | ||||
-rw-r--r-- | extras/hs-test/suite_veth_test.go | 2 | ||||
-rwxr-xr-x | extras/hs-test/test | 20 |
6 files changed, 42 insertions, 3 deletions
diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index 7460026ed52..a392c14871a 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -7,6 +7,10 @@ ifeq ($(PERSIST),) PERSIST=false endif +ifeq ($(UNCONFIGURE),) +UNCONFIGURE=false +endif + ifeq ($(TEST),) TEST=all endif @@ -45,7 +49,8 @@ build-vpp-debug: .PHONY: test test: .deps.ok .build.vpp - @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) --test=$(TEST) + @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + --unconfigure=$(UNCONFIGURE) --test=$(TEST) build-go: go build ./tools/http_server diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go index ff7024582dc..8e52cc4e851 100644 --- a/extras/hs-test/hst_suite.go +++ b/extras/hs-test/hst_suite.go @@ -19,6 +19,7 @@ const ( var IsPersistent = flag.Bool("persist", false, "persists topology config") var IsVerbose = flag.Bool("verbose", false, "verbose test output") +var IsUnconfiguring = flag.Bool("unconfigure", false, "remove topology") type HstSuite struct { suite.Suite @@ -42,7 +43,14 @@ func (s *HstSuite) TearDownTest() { s.RemoveVolumes() } +func (s *HstSuite) skipIfUnconfiguring() { + if *IsUnconfiguring { + s.skip("skipping to unconfigure") + } +} + func (s *HstSuite) SetupTest() { + s.skipIfUnconfiguring() s.SetupVolumes() s.SetupContainers() } @@ -111,7 +119,7 @@ func (s *HstSuite) assertNotEmpty(object interface{}, msgAndArgs ...interface{}) func (s *HstSuite) log(args ...any) { if *IsVerbose { - s.T().Helper() + s.T().Helper() s.T().Log(args...) } } @@ -223,6 +231,10 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) { func (s *HstSuite) configureNetworkTopology(topologyName string) { s.loadNetworkTopology(topologyName) + if *IsUnconfiguring { + return + } + for _, nc := range s.netConfigs { if err := nc.Configure(); err != nil { s.T().Fatalf("network config error: %v", err) diff --git a/extras/hs-test/suite_no_topo_test.go b/extras/hs-test/suite_no_topo_test.go index 12b939e435f..bca1dbf1828 100644 --- a/extras/hs-test/suite_no_topo_test.go +++ b/extras/hs-test/suite_no_topo_test.go @@ -18,6 +18,7 @@ func (s *NoTopoSuite) SetupSuite() { } func (s *NoTopoSuite) SetupTest() { + s.skipIfUnconfiguring() s.SetupVolumes() s.SetupContainers() diff --git a/extras/hs-test/suite_ns_test.go b/extras/hs-test/suite_ns_test.go index 5bc45c7f80c..c4a3f426648 100644 --- a/extras/hs-test/suite_ns_test.go +++ b/extras/hs-test/suite_ns_test.go @@ -17,6 +17,7 @@ func (s *NsSuite) SetupSuite() { } func (s *NsSuite) SetupTest() { + s.skipIfUnconfiguring() s.SetupVolumes() s.SetupContainers() diff --git a/extras/hs-test/suite_veth_test.go b/extras/hs-test/suite_veth_test.go index ff79dfae799..96af40771a2 100644 --- a/extras/hs-test/suite_veth_test.go +++ b/extras/hs-test/suite_veth_test.go @@ -23,6 +23,8 @@ func (s *VethsSuite) SetupSuite() { } func (s *VethsSuite) SetupTest() { + s.skipIfUnconfiguring() + s.SetupVolumes() s.SetupContainers() diff --git a/extras/hs-test/test b/extras/hs-test/test index e14f3eecaa6..f02c1596681 100755 --- a/extras/hs-test/test +++ b/extras/hs-test/test @@ -5,6 +5,7 @@ source vars args= single_test=0 persist_set=0 +unconfigure_set=0 for i in "$@" do @@ -22,6 +23,13 @@ case "${i}" in args="$args -verbose" fi ;; + --unconfigure=*) + unconfigure="${i#*=}" + if [ $unconfigure = "true" ]; then + args="$args -unconfigure" + unconfigure_set=1 + fi + ;; --test=*) tc_name="${i#*=}" if [ $tc_name != "all" ]; then @@ -32,7 +40,17 @@ esac done if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then - echo "persist flag is not supperted while running all tests!" + echo "persist flag is not supported while running all tests!" + exit 1 +fi + +if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then + echo "a single test has to be specified when unconfigure is set" + exit 1 +fi + +if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then + echo "setting persist flag and unconfigure flag is not allowed" exit 1 fi |