summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/framework_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'extras/hs-test/framework_test.go')
-rwxr-xr-xextras/hs-test/framework_test.go47
1 files changed, 34 insertions, 13 deletions
diff --git a/extras/hs-test/framework_test.go b/extras/hs-test/framework_test.go
index a3d46ad0ab9..33bc1f35011 100755
--- a/extras/hs-test/framework_test.go
+++ b/extras/hs-test/framework_test.go
@@ -1,9 +1,9 @@
package main
import (
- "fmt"
"testing"
"io/ioutil"
+ "os"
"github.com/edwarnicke/exechelper"
"github.com/stretchr/testify/assert"
@@ -11,6 +11,20 @@ import (
"gopkg.in/yaml.v3"
)
+func IsPersistent() bool {
+ if os.Getenv("HST_PERSIST") == "1" {
+ return true
+ }
+ return false
+}
+
+func IsVerbose() bool {
+ if os.Getenv("HST_VERBOSE") == "1" {
+ return true
+ }
+ return false
+}
+
type HstSuite struct {
suite.Suite
teardownSuite func()
@@ -23,6 +37,9 @@ func (s *HstSuite) TearDownSuite() {
}
func (s *HstSuite) TearDownTest() {
+ if IsPersistent() {
+ return
+ }
s.ResetContainers()
s.RemoveVolumes()
}
@@ -30,7 +47,7 @@ func (s *HstSuite) TearDownTest() {
func (s *HstSuite) SetupTest() {
for _, volume := range s.volumes {
cmd := "docker volume create --name=" + volume
- fmt.Println(cmd)
+ s.log(cmd)
exechelper.Run(cmd)
}
for _, container := range s.containers {
@@ -80,20 +97,21 @@ func (s *HstSuite) assertNotContains(testString, contains interface{}, msgAndArg
}
}
-func (s *HstSuite) ResetContainers() {
- for _, container := range s.containers {
- container.stop()
+func (s *HstSuite) log(args ...any) {
+ if IsVerbose() {
+ s.T().Log(args...)
}
}
-func (s *HstSuite) NewVolume(name string) error {
- err := exechelper.Run(fmt.Sprintf("docker volume create --name=%s", name))
- if err != nil {
- return err
- }
+func (s *HstSuite) skip(args ...any) {
+ s.log(args...)
+ s.T().SkipNow()
+}
- s.volumes = append(s.volumes, name)
- return nil
+func (s *HstSuite) ResetContainers() {
+ for _, container := range s.containers {
+ container.stop()
+ }
}
func (s *HstSuite) RemoveVolumes() {
@@ -128,6 +146,7 @@ func (s *HstSuite) loadContainerTopology(topologyName string) {
if err != nil {
s.T().Fatalf("config error: %v", err)
}
+ s.log(newContainer.getRunCommand())
s.containers[newContainer.name] = newContainer
}
}
@@ -143,8 +162,10 @@ func setupSuite(s *suite.Suite, topologyName string) func() {
t.Fatalf("failed to configure %s: %v", topologyName, err)
}
- t.Logf("topo %s loaded", topologyName)
return func() {
+ if IsPersistent() {
+ return
+ }
topology.Unconfigure()
}
}