summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/http_test.go
diff options
context:
space:
mode:
authorAdrian Villin <avillin@cisco.com>2024-03-14 11:42:55 -0400
committerAdrian Villin <avillin@cisco.com>2024-04-19 14:52:05 +0000
commitcee15aa940a0229e21049c18df66c7dc80ad9096 (patch)
tree7cca4828c44fa2e059e728f2171f158bf3621447 /extras/hs-test/http_test.go
parent3a05db6264a4b2edf1fc7e6c35ee3b688baa463a (diff)
hs-test: transition to ginkgo test framework
Type: test Change-Id: Ia38bf5549d20b22876f6082085b69a52a03d0142 Signed-off-by: Adrian Villin <avillin@cisco.com> Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras/hs-test/http_test.go')
-rw-r--r--extras/hs-test/http_test.go56
1 files changed, 40 insertions, 16 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index 943c8a591d4..4277d432e72 100644
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -4,9 +4,20 @@ import (
"fmt"
"os"
"strings"
+ "time"
+
+ . "github.com/onsi/ginkgo/v2"
)
-func (s *NsSuite) TestHttpTps() {
+func init() {
+ registerNsTests(HttpTpsTest)
+ registerVethTests(HttpCliTest)
+ registerNoTopoTests(NginxHttp3Test, NginxAsServerTest,
+ NginxPerfCpsTest, NginxPerfRpsTest, NginxPerfWrkTest)
+ registerNoTopoSoloTests(HttpStaticPromTest)
+}
+
+func HttpTpsTest(s *NsSuite) {
iface := s.getInterfaceByName(clientInterface)
client_ip := iface.ip4AddressString()
port := "8080"
@@ -18,13 +29,16 @@ func (s *NsSuite) TestHttpTps() {
// configure vpp in the container
container.vppInstance.vppctl("http tps uri tcp://0.0.0.0/8080")
- go s.startWget(finished, client_ip, port, "test_file_10M", clientNetns)
+ go func() {
+ defer GinkgoRecover()
+ s.startWget(finished, client_ip, port, "test_file_10M", clientNetns)
+ }()
// wait for client
err := <-finished
- s.assertNil(err, err)
+ s.assertNil(err, fmt.Sprint(err))
}
-func (s *VethsSuite) TestHttpCli() {
+func HttpCliTest(s *VethsSuite) {
serverContainer := s.getContainerByName("server-vpp")
clientContainer := s.getContainerByName("client-vpp")
@@ -41,7 +55,7 @@ func (s *VethsSuite) TestHttpCli() {
s.assertContains(o, "<html>", "<html> not found in the result!")
}
-func (s *NoTopoSuite) TestNginxHttp3() {
+func NginxHttp3Test(s *NoTopoSuite) {
s.SkipUnlessExtendedTestsBuilt()
query := "index.html"
@@ -57,23 +71,27 @@ func (s *NoTopoSuite) TestNginxHttp3() {
args := fmt.Sprintf("curl --noproxy '*' --local-port 55444 --http3-only -k https://%s:8443/%s", serverAddress, query)
curlCont.extraRunningArgs = args
o, err := curlCont.combinedOutput()
- s.assertNil(err, err)
+ s.assertNil(err, fmt.Sprint(err))
s.assertContains(o, "<http>", "<http> not found in the result!")
}
-func (s *NoTopoSuite) TestHttpStaticProm() {
+func HttpStaticPromTest(s *NoTopoSuite) {
finished := make(chan error, 1)
query := "stats.prom"
vpp := s.getContainerByName("vpp").vppInstance
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
s.log(vpp.vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers"))
s.log(vpp.vppctl("prom enable"))
- go s.startWget(finished, serverAddress, "80", query, "")
+ time.Sleep(time.Second * 5)
+ go func() {
+ defer GinkgoRecover()
+ s.startWget(finished, serverAddress, "80", query, "")
+ }()
err := <-finished
- s.assertNil(err, err)
+ s.assertNil(err)
}
-func (s *NoTopoSuite) TestNginxAsServer() {
+func NginxAsServerTest(s *NoTopoSuite) {
query := "return_ok"
finished := make(chan error, 1)
@@ -86,7 +104,10 @@ func (s *NoTopoSuite) TestNginxAsServer() {
serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString()
defer func() { os.Remove(query) }()
- go s.startWget(finished, serverAddress, "80", query, "")
+ go func() {
+ defer GinkgoRecover()
+ s.startWget(finished, serverAddress, "80", query, "")
+ }()
s.assertNil(<-finished)
}
@@ -124,9 +145,11 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
args += " -r"
args += " http://" + serverAddress + ":80/64B.json"
abCont.extraRunningArgs = args
+ time.Sleep(time.Second * 10)
o, err := abCont.combinedOutput()
rps := parseString(o, "Requests per second:")
- s.log(rps, err)
+ s.log(rps)
+ s.log(err)
s.assertNil(err, "err: '%s', output: '%s'", err, o)
} else {
wrkCont := s.getContainerByName("wrk")
@@ -135,20 +158,21 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
wrkCont.extraRunningArgs = args
o, err := wrkCont.combinedOutput()
rps := parseString(o, "requests")
- s.log(rps, err)
+ s.log(rps)
+ s.log(err)
s.assertNil(err, "err: '%s', output: '%s'", err, o)
}
return nil
}
-func (s *NoTopoSuite) TestNginxPerfCps() {
+func NginxPerfCpsTest(s *NoTopoSuite) {
s.assertNil(runNginxPerf(s, "cps", "ab"))
}
-func (s *NoTopoSuite) TestNginxPerfRps() {
+func NginxPerfRpsTest(s *NoTopoSuite) {
s.assertNil(runNginxPerf(s, "rps", "ab"))
}
-func (s *NoTopoSuite) TestNginxPerfWrk() {
+func NginxPerfWrkTest(s *NoTopoSuite) {
s.assertNil(runNginxPerf(s, "", "wrk"))
}