diff options
author | Maros Ondrejicka <mondreji@cisco.com> | 2023-02-23 13:19:15 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-02-27 17:26:41 +0000 |
commit | 40cba405c5c06a3dc086a55143cb3ffd1094597e (patch) | |
tree | 0263e3834a316d73863b1a6cc2da9beac916ac45 /extras/hs-test/hst_suite.go | |
parent | 9cb3e15c9f5b0eed296c3517c6475bd17a33441e (diff) |
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 <mondreji@cisco.com>
Change-Id: I1b2c368bfe90a5bdfaaa9a5129c27d7d96f8fe3b
Diffstat (limited to 'extras/hs-test/hst_suite.go')
-rw-r--r-- | extras/hs-test/hst_suite.go | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go index 01be2efbf3d..ff7024582dc 100644 --- a/extras/hs-test/hst_suite.go +++ b/extras/hs-test/hst_suite.go @@ -25,7 +25,7 @@ type HstSuite struct { containers map[string]*Container volumes []string netConfigs []NetConfig - netInterfaces map[string]NetInterface + netInterfaces map[string]*NetInterface addresser *Addresser testIds map[string]string } @@ -188,7 +188,7 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) { } s.addresser = NewAddresser(s) - s.netInterfaces = make(map[string]NetInterface) + s.netInterfaces = make(map[string]*NetInterface) for _, elem := range yamlTopo.Devices { switch elem["type"].(string) { case NetNs: @@ -199,20 +199,11 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) { s.T().Fatalf("network config error: %v", err) } } - case Veth: + case Veth, Tap: { - if veth, err := NewVeth(elem, s.addresser); err == nil { - s.netConfigs = append(s.netConfigs, &veth) - s.netInterfaces[veth.Name()] = &veth - } else { - s.T().Fatalf("network config error: %v", err) - } - } - case Tap: - { - if tap, err := NewTap(elem, s.addresser); err == nil { - s.netConfigs = append(s.netConfigs, &tap) - s.netInterfaces[tap.Name()] = &tap + if netIf, err := NewNetworkInterface(elem, s.addresser); err == nil { + s.netConfigs = append(s.netConfigs, netIf) + s.netInterfaces[netIf.Name()] = netIf } else { s.T().Fatalf("network config error: %v", err) } @@ -262,11 +253,6 @@ func (s *HstSuite) getTestId() string { return s.testIds[testName] } -type NetworkAddresses struct { - network int - numberOfAddresses int -} - type AddressCounter = int type Addresser struct { |