diff options
author | Maros Ondrejicka <maros.ondrejicka@pantheon.tech> | 2023-01-26 10:07:29 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-02-09 17:02:43 +0000 |
commit | ffa3f60290499bdacc37a97c49f2e794b5e1f18c (patch) | |
tree | c23820e0d91d2a1a0eef2596b0de60c06f1ea303 /extras/hs-test/framework_test.go | |
parent | 7a6532bb9f3b9c429f92d11a6ccbf55638906d0a (diff) |
hs-test: configure VPP from test context
Instead of configuring VPP instances running inside of a container,
now the configuration is going to be done from within the test context
by using binary API and shared volume that exposes api socket.
This converts just some of the test cases, rest is to follow.
Type: test
Signed-off-by: Maros Ondrejicka <maros.ondrejicka@pantheon.tech>
Change-Id: I87e4ab15de488f0eebb01ff514596265fc2a787f
Diffstat (limited to 'extras/hs-test/framework_test.go')
-rw-r--r-- | extras/hs-test/framework_test.go | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/extras/hs-test/framework_test.go b/extras/hs-test/framework_test.go index 76d8e58724f..6de8f167f70 100644 --- a/extras/hs-test/framework_test.go +++ b/extras/hs-test/framework_test.go @@ -1,152 +1,11 @@ package main import ( - "io/ioutil" - "os" "testing" - "github.com/edwarnicke/exechelper" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "gopkg.in/yaml.v3" ) -func IsPersistent() bool { - return os.Getenv("HST_PERSIST") == "1" -} - -func IsVerbose() bool { - return os.Getenv("HST_VERBOSE") == "1" -} - -type HstSuite struct { - suite.Suite - teardownSuite func() - containers map[string]*Container - volumes []string -} - -func (s *HstSuite) TearDownSuite() { - s.teardownSuite() -} - -func (s *HstSuite) TearDownTest() { - if IsPersistent() { - return - } - s.ResetContainers() - s.RemoveVolumes() -} - -func (s *HstSuite) SetupTest() { - for _, volume := range s.volumes { - cmd := "docker volume create --name=" + volume - s.log(cmd) - exechelper.Run(cmd) - } - for _, container := range s.containers { - if container.isOptional == false { - container.run() - } - } -} - -func (s *HstSuite) hstFail() { - s.T().FailNow() -} - -func (s *HstSuite) assertNil(object interface{}, msgAndArgs ...interface{}) { - if !assert.Nil(s.T(), object, msgAndArgs...) { - s.hstFail() - } -} - -func (s *HstSuite) assertNotNil(object interface{}, msgAndArgs ...interface{}) { - if !assert.NotNil(s.T(), object, msgAndArgs...) { - s.hstFail() - } -} - -func (s *HstSuite) assertEqual(expected, actual interface{}, msgAndArgs ...interface{}) { - if !assert.Equal(s.T(), expected, actual, msgAndArgs...) { - s.hstFail() - } -} - -func (s *HstSuite) assertNotEqual(expected, actual interface{}, msgAndArgs ...interface{}) { - if !assert.NotEqual(s.T(), expected, actual, msgAndArgs...) { - s.hstFail() - } -} - -func (s *HstSuite) assertContains(testString, contains interface{}, msgAndArgs ...interface{}) { - if !assert.Contains(s.T(), testString, contains, msgAndArgs...) { - s.hstFail() - } -} - -func (s *HstSuite) assertNotContains(testString, contains interface{}, msgAndArgs ...interface{}) { - if !assert.NotContains(s.T(), testString, contains, msgAndArgs...) { - s.hstFail() - } -} - -func (s *HstSuite) log(args ...any) { - if IsVerbose() { - s.T().Log(args...) - } -} - -func (s *HstSuite) skip(args ...any) { - s.log(args...) - s.T().SkipNow() -} - -func (s *HstSuite) ResetContainers() { - for _, container := range s.containers { - container.stop() - } -} - -func (s *HstSuite) RemoveVolumes() { - for _, volumeName := range s.volumes { - cmd := "docker volume rm " + volumeName - exechelper.Run(cmd) - } -} - -func (s *HstSuite) getContainerByName(name string) *Container { - return s.containers[name] -} - -func (s *HstSuite) loadContainerTopology(topologyName string) { - data, err := ioutil.ReadFile(ContainerTopologyDir + topologyName + ".yaml") - if err != nil { - s.T().Fatalf("read error: %v", err) - } - var yamlTopo YamlTopology - err = yaml.Unmarshal(data, &yamlTopo) - if err != nil { - s.T().Fatalf("unmarshal error: %v", err) - } - - for _, elem := range yamlTopo.Volumes { - volumeMap := elem["volume"].(VolumeConfig) - hostDir := volumeMap["host-dir"].(string) - s.volumes = append(s.volumes, hostDir) - } - - s.containers = make(map[string]*Container) - for _, elem := range yamlTopo.Containers { - newContainer, err := NewContainer(elem) - if err != nil { - s.T().Fatalf("config error: %v", err) - } - s.log(newContainer.getRunCommand()) - s.containers[newContainer.name] = newContainer - } -} - func setupSuite(s *suite.Suite, topologyName string) func() { t := s.T() topology, err := LoadTopology(NetworkTopologyDir, topologyName) |