aboutsummaryrefslogtreecommitdiffstats
path: root/extras/hs-test/hst_suite.go
diff options
context:
space:
mode:
Diffstat (limited to 'extras/hs-test/hst_suite.go')
-rw-r--r--extras/hs-test/hst_suite.go62
1 files changed, 31 insertions, 31 deletions
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go
index 4e4b7d20b61..78d953b794d 100644
--- a/extras/hs-test/hst_suite.go
+++ b/extras/hs-test/hst_suite.go
@@ -17,10 +17,10 @@ const (
defaultNetworkNumber int = 1
)
-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")
-var IsVppDebug = flag.Bool("debug", false, "attach gdb to vpp")
+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")
+var isVppDebug = flag.Bool("debug", false, "attach gdb to vpp")
type HstSuite struct {
suite.Suite
@@ -37,26 +37,26 @@ func (s *HstSuite) TearDownSuite() {
}
func (s *HstSuite) TearDownTest() {
- if *IsPersistent {
+ if *isPersistent {
return
}
- s.ResetContainers()
- s.RemoveVolumes()
+ s.resetContainers()
+ s.removeVolumes()
}
func (s *HstSuite) skipIfUnconfiguring() {
- if *IsUnconfiguring {
+ if *isUnconfiguring {
s.skip("skipping to unconfigure")
}
}
func (s *HstSuite) SetupTest() {
s.skipIfUnconfiguring()
- s.SetupVolumes()
- s.SetupContainers()
+ s.setupVolumes()
+ s.setupContainers()
}
-func (s *HstSuite) SetupVolumes() {
+func (s *HstSuite) setupVolumes() {
for _, volume := range s.volumes {
cmd := "docker volume create --name=" + volume
s.log(cmd)
@@ -64,7 +64,7 @@ func (s *HstSuite) SetupVolumes() {
}
}
-func (s *HstSuite) SetupContainers() {
+func (s *HstSuite) setupContainers() {
for _, container := range s.containers {
if container.isOptional == false {
container.run()
@@ -119,7 +119,7 @@ func (s *HstSuite) assertNotEmpty(object interface{}, msgAndArgs ...interface{})
}
func (s *HstSuite) log(args ...any) {
- if *IsVerbose {
+ if *isVerbose {
s.T().Helper()
s.T().Log(args...)
}
@@ -130,13 +130,13 @@ func (s *HstSuite) skip(args ...any) {
s.T().SkipNow()
}
-func (s *HstSuite) ResetContainers() {
+func (s *HstSuite) resetContainers() {
for _, container := range s.containers {
container.stop()
}
}
-func (s *HstSuite) RemoveVolumes() {
+func (s *HstSuite) removeVolumes() {
for _, volumeName := range s.volumes {
cmd := "docker volume rm " + volumeName
exechelper.Run(cmd)
@@ -158,7 +158,7 @@ func (s *HstSuite) getTransientContainerByName(name string) *Container {
}
func (s *HstSuite) loadContainerTopology(topologyName string) {
- data, err := ioutil.ReadFile(ContainerTopologyDir + topologyName + ".yaml")
+ data, err := ioutil.ReadFile(containerTopologyDir + topologyName + ".yaml")
if err != nil {
s.T().Fatalf("read error: %v", err)
}
@@ -176,7 +176,7 @@ func (s *HstSuite) loadContainerTopology(topologyName string) {
s.containers = make(map[string]*Container)
for _, elem := range yamlTopo.Containers {
- newContainer, err := NewContainer(elem)
+ newContainer, err := newContainer(elem)
newContainer.suite = s
if err != nil {
s.T().Fatalf("container config error: %v", err)
@@ -186,7 +186,7 @@ func (s *HstSuite) loadContainerTopology(topologyName string) {
}
func (s *HstSuite) loadNetworkTopology(topologyName string) {
- data, err := ioutil.ReadFile(NetworkTopologyDir + topologyName + ".yaml")
+ data, err := ioutil.ReadFile(networkTopologyDir + topologyName + ".yaml")
if err != nil {
s.T().Fatalf("read error: %v", err)
}
@@ -196,13 +196,13 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) {
s.T().Fatalf("unmarshal error: %v", err)
}
- s.addresser = NewAddresser(s)
+ s.addresser = newAddresser(s)
s.netInterfaces = make(map[string]*NetInterface)
for _, elem := range yamlTopo.Devices {
switch elem["type"].(string) {
case NetNs:
{
- if namespace, err := NewNetNamespace(elem); err == nil {
+ if namespace, err := newNetNamespace(elem); err == nil {
s.netConfigs = append(s.netConfigs, &namespace)
} else {
s.T().Fatalf("network config error: %v", err)
@@ -210,7 +210,7 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) {
}
case Veth, Tap:
{
- if netIf, err := NewNetworkInterface(elem, s.addresser); err == nil {
+ if netIf, err := newNetworkInterface(elem, s.addresser); err == nil {
s.netConfigs = append(s.netConfigs, netIf)
s.netInterfaces[netIf.Name()] = netIf
} else {
@@ -219,7 +219,7 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) {
}
case Bridge:
{
- if bridge, err := NewBridge(elem); err == nil {
+ if bridge, err := newBridge(elem); err == nil {
s.netConfigs = append(s.netConfigs, &bridge)
} else {
s.T().Fatalf("network config error: %v", err)
@@ -232,23 +232,23 @@ func (s *HstSuite) loadNetworkTopology(topologyName string) {
func (s *HstSuite) configureNetworkTopology(topologyName string) {
s.loadNetworkTopology(topologyName)
- if *IsUnconfiguring {
+ if *isUnconfiguring {
return
}
for _, nc := range s.netConfigs {
- if err := nc.Configure(); err != nil {
+ if err := nc.configure(); err != nil {
s.T().Fatalf("network config error: %v", err)
}
}
}
func (s *HstSuite) unconfigureNetworkTopology() {
- if *IsPersistent {
+ if *isPersistent {
return
}
for _, nc := range s.netConfigs {
- nc.Unconfigure()
+ nc.unconfigure()
}
}
@@ -273,18 +273,18 @@ type Addresser struct {
suite *HstSuite
}
-func (a *Addresser) AddNetwork(networkNumber int) {
+func (a *Addresser) addNetwork(networkNumber int) {
a.networks[networkNumber] = 1
}
-func (a *Addresser) NewIp4Address(inputNetworkNumber ...int) (string, error) {
+func (a *Addresser) newIp4Address(inputNetworkNumber ...int) (string, error) {
var networkNumber int = 0
if len(inputNetworkNumber) > 0 {
networkNumber = inputNetworkNumber[0]
}
if _, ok := a.networks[networkNumber]; !ok {
- a.AddNetwork(networkNumber)
+ a.addNetwork(networkNumber)
}
numberOfAddresses := a.networks[networkNumber]
@@ -299,10 +299,10 @@ func (a *Addresser) NewIp4Address(inputNetworkNumber ...int) (string, error) {
return address, nil
}
-func NewAddresser(suite *HstSuite) *Addresser {
+func newAddresser(suite *HstSuite) *Addresser {
var addresser = new(Addresser)
addresser.suite = suite
addresser.networks = make(map[int]AddressCounter)
- addresser.AddNetwork(0)
+ addresser.addNetwork(0)
return addresser
}