summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/http_test.go
diff options
context:
space:
mode:
authorMaros Ondrejicka <maros.ondrejicka@pantheon.tech>2022-12-06 15:38:05 +0100
committerFlorin Coras <florin.coras@gmail.com>2022-12-07 16:05:20 +0000
commit98a91e82608e6e30d4516b52556cdaaa9837ee24 (patch)
tree2030a669ba4a70a2767cd8ca8fcce3f0e5c647d9 /extras/hs-test/http_test.go
parentfe1fb3c31aa5f42c213eaa0c51f9d5a2cef07711 (diff)
hs-test: use assert-like approach in test cases
Type: test Signed-off-by: Maros Ondrejicka <maros.ondrejicka@pantheon.tech> Change-Id: I1653001461d4dfc52f1fb3a9e0cf458a506b8324
Diffstat (limited to 'extras/hs-test/http_test.go')
-rwxr-xr-xextras/hs-test/http_test.go59
1 files changed, 13 insertions, 46 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index 99b509fdcff..d2fb5a3c85a 100755
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -1,8 +1,6 @@
package main
import (
- "strings"
-
"github.com/edwarnicke/exechelper"
)
@@ -15,26 +13,17 @@ func (s *NsSuite) TestHttpTps() {
t.Log("starting vpp..")
- err := dockerRun(dockerInstance, "")
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ s.assertNil(dockerRun(dockerInstance, ""), "failed to start docker")
defer func() { exechelper.Run("docker stop " + dockerInstance) }()
// start & configure vpp in the container
- _, err = hstExec("ConfigureHttpTps", dockerInstance)
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ _, err := hstExec("ConfigureHttpTps", dockerInstance)
+ s.assertNil(err)
go startWget(finished, server_ip, port, "client")
// wait for client
err = <-finished
- if err != nil {
- t.Errorf("%v", err)
- }
+ s.assertNil(err)
}
func (s *VethsSuite) TestHttpCli() {
@@ -42,49 +31,27 @@ func (s *VethsSuite) TestHttpCli() {
srvInstance := "http-cli-srv"
clnInstance := "http-cli-cln"
- err := dockerRun(srvInstance, "")
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ s.assertNil(dockerRun(srvInstance, ""), "failed to start docker (srv)")
defer func() { exechelper.Run("docker stop " + srvInstance) }()
- err = dockerRun(clnInstance, "")
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ s.assertNil(dockerRun(clnInstance, ""), "failed to start docker (cln)")
defer func() { exechelper.Run("docker stop " + clnInstance) }()
- _, err = hstExec("Configure2Veths srv", srvInstance)
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ _, err := hstExec("Configure2Veths srv", srvInstance)
+ s.assertNil(err)
_, err = hstExec("Configure2Veths cln", clnInstance)
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ s.assertNil(err)
t.Log("configured IPs...")
_, err = hstExec("RunHttpCliSrv", srvInstance)
- if err != nil {
- t.Errorf("%v", err)
- return
- }
+ s.assertNil(err)
t.Log("configured http server")
o, err := hstExec("RunHttpCliCln /show/version", clnInstance)
- if err != nil {
- t.Errorf("%v", err)
- return
- }
-
- if strings.Index(o, "<html>") < 0 {
- t.Error("<html> not found in the result!")
- }
+ s.assertNil(err)
+
+ s.assertContains(o, "<html>", "<html> not found in the result!")
}