hs-test: http tests improvement
- added http specific asserts - added helper functions to NoTopoSuite Type: test Change-Id: I0a7e77ed3ffd938aa3eaa37ed5432fbaab0dab64 Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -313,7 +313,7 @@ func (c *Container) Run() {
|
||||
|
||||
func (c *Container) addVolume(hostDir string, containerDir string, isDefaultWorkDir bool) {
|
||||
var volume Volume
|
||||
volume.HostDir = strings.Replace(hostDir, "volumes", c.Suite.GetTestId() + "/" + "volumes", 1)
|
||||
volume.HostDir = strings.Replace(hostDir, "volumes", c.Suite.GetTestId()+"/"+"volumes", 1)
|
||||
volume.ContainerDir = containerDir
|
||||
volume.IsDefaultWorkDir = isDefaultWorkDir
|
||||
c.Volumes[hostDir] = volume
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -258,7 +259,35 @@ func (s *HstSuite) AssertNotEmpty(object interface{}, msgAndArgs ...interface{})
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertMatchError(actual, expected error, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, actual).To(MatchError(expected))
|
||||
ExpectWithOffset(2, actual).To(MatchError(expected), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertGreaterThan(actual, expected interface{}, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, actual).Should(BeNumerically(">=", expected), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertTimeEqualWithinThreshold(actual, expected time.Time, threshold time.Duration, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, actual).Should(BeTemporally("~", expected, threshold), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertHttpStatus(resp *http.Response, expectedStatus int, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, resp).To(HaveHTTPStatus(expectedStatus), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertHttpHeaderWithValue(resp *http.Response, key string, value interface{}, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, resp).To(HaveHTTPHeaderWithValue(key, value), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertHttpHeaderNotPresent(resp *http.Response, key string, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, resp.Header.Get(key)).To(BeEmpty(), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertHttpContentLength(resp *http.Response, expectedContentLen int64, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, resp).To(HaveHTTPHeaderWithValue("Content-Length", strconv.FormatInt(expectedContentLen, 10)), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) AssertHttpBody(resp *http.Response, expectedBody string, msgAndArgs ...interface{}) {
|
||||
ExpectWithOffset(2, resp).To(HaveHTTPBody(expectedBody), msgAndArgs...)
|
||||
}
|
||||
|
||||
func (s *HstSuite) CreateLogger() {
|
||||
|
@ -60,6 +60,18 @@ func (s *NoTopoSuite) SetupTest() {
|
||||
s.AssertNil(vpp.createTap(tapInterface), "failed to create tap interface")
|
||||
}
|
||||
|
||||
func (s *NoTopoSuite) VppAddr() string {
|
||||
return s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString()
|
||||
}
|
||||
|
||||
func (s *NoTopoSuite) VppIfName() string {
|
||||
return s.GetInterfaceByName(TapInterfaceName).Peer.Name()
|
||||
}
|
||||
|
||||
func (s *NoTopoSuite) HostAddr() string {
|
||||
return s.GetInterfaceByName(TapInterfaceName).Ip4AddressString()
|
||||
}
|
||||
|
||||
var _ = Describe("NoTopoSuite", Ordered, ContinueOnFailure, func() {
|
||||
var s NoTopoSuite
|
||||
BeforeAll(func() {
|
||||
|
@ -22,7 +22,7 @@ func NginxHttp3Test(s *NoTopoSuite) {
|
||||
|
||||
vpp := s.GetContainerByName("vpp").VppInstance
|
||||
vpp.WaitForApp("nginx-", 5)
|
||||
serverAddress := s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString()
|
||||
serverAddress := s.VppAddr()
|
||||
|
||||
defer func() { os.Remove(query) }()
|
||||
curlCont := s.GetContainerByName("curl")
|
||||
@ -44,7 +44,7 @@ func NginxAsServerTest(s *NoTopoSuite) {
|
||||
vpp := s.GetContainerByName("vpp").VppInstance
|
||||
vpp.WaitForApp("nginx-", 5)
|
||||
|
||||
serverAddress := s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString()
|
||||
serverAddress := s.VppAddr()
|
||||
|
||||
defer func() { os.Remove(query) }()
|
||||
go func() {
|
||||
@ -68,7 +68,7 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
|
||||
nRequests := 1000000
|
||||
nClients := 1000
|
||||
|
||||
serverAddress := s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString()
|
||||
serverAddress := s.VppAddr()
|
||||
|
||||
vpp := s.GetContainerByName("vpp").VppInstance
|
||||
|
||||
|
Reference in New Issue
Block a user