// Add custom setup code here
- s.ConfigureNetworkTopology("myTopology")
- s.LoadContainerTopology("2peerVeth")
+ s.ConfigureNetworkTopology("myNetworkTopology")
+ s.LoadContainerTopology("myContainerTopology")
}
#. In suite file, implement ``SetupTest`` method which gets executed before each test. Starting containers and
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(time.Minute*5))
+ }, SpecTimeout(TestTimeout))
})
#. Next step is to add test cases to the suite. For that, see section `Adding a test case`_ above
func TestHst(t *testing.T) {
if *IsVppDebug {
// 30 minute timeout so that the framework won't timeout while debugging
- SuiteTimeout = time.Minute * 30
+ TestTimeout = time.Minute * 30
} else {
- SuiteTimeout = time.Minute * 5
+ TestTimeout = time.Minute * 5
}
output, err := os.ReadFile("/sys/devices/system/node/online")
}
core_pattern, err := sysctl.Read("kernel.core_pattern")
- core_pattern = strings.ReplaceAll(core_pattern, "%", "%%")
if err == nil {
if len(core_pattern) > 0 && core_pattern[0] != '|' {
index := strings.LastIndex(core_pattern, "/")
var ParallelTotal = flag.Lookup("ginkgo.parallel.total")
var DryRun = flag.Bool("dryrun", false, "set up containers but don't run tests")
var NumaAwareCpuAlloc bool
-var SuiteTimeout time.Duration
+var TestTimeout time.Duration
type HstSuite struct {
Containers map[string]*Container
ExpectWithOffset(2, resp).To(HaveHTTPBody(expectedBody), msgAndArgs...)
}
+func (s *HstSuite) AssertChannelClosed(timeout time.Duration, channel chan error) {
+ EventuallyWithOffset(2, channel).WithTimeout(timeout).Should(BeClosed())
+}
+
func (s *HstSuite) CreateLogger() {
suiteName := s.GetCurrentSuiteName()
var err error
// Logs to files by default, logs to stdout when VERBOSE=true with GinkgoWriter
// to keep console tidy
func (s *HstSuite) Log(log any, arg ...any) {
- logs := strings.Split(fmt.Sprintf(fmt.Sprint(log), arg...), "\n")
+ var logStr string
+ if len(arg) == 0 {
+ logStr = fmt.Sprint(log)
+ } else {
+ logStr = fmt.Sprintf(fmt.Sprint(log), arg...)
+ }
+ logs := strings.Split(logStr, "\n")
+
for _, line := range logs {
s.Logger.Println(line)
}
if *IsVerbose {
- GinkgoWriter.Println(fmt.Sprintf(fmt.Sprint(log), arg...))
+ GinkgoWriter.Println(logStr)
}
}
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
- }, SpecTimeout(SuiteTimeout))
+ }, SpecTimeout(TestTimeout))
}
}
})
import (
"fmt"
+ "time"
. "fd.io/hs-test/infra"
. "github.com/onsi/ginkgo/v2"
" -u -l 1460 -b 10g -p " + s.GetPortFromPpid()
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
}()
-
+ s.AssertChannelClosed(time.Minute*3, clnCh)
s.Log(<-clnRes)
- err = <-clnCh
- s.AssertNil(err, "err: '%s'", err)
}
import (
"fmt"
+ "time"
. "fd.io/hs-test/infra"
. "github.com/onsi/ginkgo/v2"
clnCh := make(chan error)
clnRes := make(chan string, 1)
+ defer func() {
+ stopServerCh <- struct{}{}
+ }()
+
go func() {
defer GinkgoRecover()
cmd := "iperf3 -4 -s -p " + s.GetPortFromPpid()
cmd := "iperf3 -c " + serverVethAddress + " -u -l 1460 -b 10g -p " + s.GetPortFromPpid()
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
}()
- s.Log(<-clnRes)
-
- // wait for client's result
- err = <-clnCh
- s.AssertNil(err, fmt.Sprint(err))
- // stop server
- stopServerCh <- struct{}{}
+ s.AssertChannelClosed(time.Minute*3, clnCh)
+ s.Log(<-clnRes)
}
func RedisBenchmarkTest(s *LdpSuite) {
clnCh := make(chan error)
clnRes := make(chan string, 1)
+ defer func() {
+ doneSrv <- struct{}{}
+ }()
+
go func() {
defer GinkgoRecover()
cmd := "redis-server --daemonize yes --protected-mode no --bind " + serverVethAddress
cmd = "redis-benchmark --threads " + fmt.Sprint(*NConfiguredCpus) + "-h " + serverVethAddress
}
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
+
}()
+ // 4.5 minutes
+ s.AssertChannelClosed(time.Second*270, clnCh)
s.Log(<-clnRes)
- // wait for client's result
- err = <-clnCh
- s.AssertNil(err, fmt.Sprint(err))
- // stop server
- doneSrv <- struct{}{}
}
if [ -n "${WORKSPACE}" ]
then
echo -n "Copying docker logs..."
- dirs=$(jq -r '.[0] | .SpecReports[] | select(.State == "failed") | .LeafNodeText | split("/")[1]' ${HS_ROOT}/summary/report.json)
+ dirs=$(jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | .LeafNodeText | split("/")[1]' ${HS_ROOT}/summary/report.json)
for dirName in $dirs; do
logDir=/tmp/hs-test/$dirName
if [ -d "$logDir" ]; then