From 40cba405c5c06a3dc086a55143cb3ffd1094597e Mon Sep 17 00:00:00 2001 From: Maros Ondrejicka Date: Thu, 23 Feb 2023 13:19:15 +0100 Subject: hs-test: refactor netconfig This joins separate representations of veth and tap interfaces into a single struct. It removes the need for type interface and embedding which simplifies the code. Type: test Signed-off-by: Maros Ondrejicka Change-Id: I1b2c368bfe90a5bdfaaa9a5129c27d7d96f8fe3b --- extras/hs-test/suite_no_topo_test.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'extras/hs-test/suite_no_topo_test.go') diff --git a/extras/hs-test/suite_no_topo_test.go b/extras/hs-test/suite_no_topo_test.go index 01958b0a804..12b939e435f 100644 --- a/extras/hs-test/suite_no_topo_test.go +++ b/extras/hs-test/suite_no_topo_test.go @@ -4,8 +4,7 @@ const ( singleTopoContainerVpp = "vpp" singleTopoContainerNginx = "nginx" - tapNameVpp = "vppTap" - tapNameHost = "hostTap" + tapInterfaceName = "hst_tap_host" ) type NoTopoSuite struct { @@ -13,19 +12,9 @@ type NoTopoSuite struct { } func (s *NoTopoSuite) SetupSuite() { - s.loadContainerTopology("single") - - s.addresser = NewAddresser(&s.HstSuite) - - var vppTapDevConfig = NetDevConfig{"name": tapNameVpp} - vppTap, _ := NewTap(vppTapDevConfig, s.addresser) + s.loadNetworkTopology("tap") - var hostTapDevConfig = NetDevConfig{"name": tapNameHost} - hostTap, _ := NewTap(hostTapDevConfig, s.addresser) - - s.netInterfaces = make(map[string]NetInterface) - s.netInterfaces[vppTap.Name()] = &vppTap - s.netInterfaces[hostTap.Name()] = &hostTap + s.loadContainerTopology("single") } func (s *NoTopoSuite) SetupTest() { @@ -43,8 +32,7 @@ func (s *NoTopoSuite) SetupTest() { vpp, _ := container.newVppInstance(startupConfig) vpp.start() - vppTapAddress := s.netInterfaces[tapNameVpp].AddressWithPrefix() - hostTapAddress := s.netInterfaces[tapNameHost].IP4AddressWithPrefix() + tapInterface := s.netInterfaces[tapInterfaceName] - vpp.createTap("tap0", hostTapAddress, vppTapAddress) + vpp.createTap(1, tapInterface) } -- cgit 1.2.3-korg