X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fhs-test%2Fhttp_test.go;h=53e6ec22ac32513d1c43ec47d7f28e4fcbfe7112;hb=cc1475cdc2bddeac5237012dae1c19278ee5346c;hp=5e88fe00cc6895029c67d761dd9b812291c38b2a;hpb=7550dd268f80334cbb9127feefe35319b9c7e572;p=vpp.git diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index 5e88fe00cc6..53e6ec22ac3 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -3,12 +3,12 @@ package main import ( "fmt" "os" - "os/exec" + "strings" ) func (s *NsSuite) TestHttpTps() { iface := s.netInterfaces[clientInterface] - client_ip := iface.IP4AddressString() + client_ip := iface.ip4AddressString() port := "8080" finished := make(chan error, 1) @@ -17,7 +17,7 @@ func (s *NsSuite) TestHttpTps() { // configure vpp in the container container.vppInstance.vppctl("http tps uri tcp://0.0.0.0/8080") - go startWget(finished, client_ip, port, "test_file_10M", "client") + go s.startWget(finished, client_ip, port, "test_file_10M", "client") // wait for client err := <-finished s.assertNil(err) @@ -31,7 +31,7 @@ func (s *VethsSuite) TestHttpCli() { serverContainer.vppInstance.vppctl("http cli server") - uri := "http://" + serverVeth.IP4AddressString() + "/80" + uri := "http://" + serverVeth.ip4AddressString() + "/80" o := clientContainer.vppInstance.vppctl("http cli client" + " uri " + uri + " query /show/version") @@ -40,7 +40,39 @@ func (s *VethsSuite) TestHttpCli() { s.assertContains(o, "", " not found in the result!") } -func (s *NoTopoSuite) TestNginx() { +func (s *NoTopoSuite) TestNginxHttp3() { + s.SkipUnlessExtendedTestsBuilt() + + query := "index.html" + nginxCont := s.getContainerByName("nginx-http3") + s.assertNil(nginxCont.run()) + + vpp := s.getContainerByName("vpp").vppInstance + vpp.waitForApp("nginx-", 5) + serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() + + defer func() { os.Remove(query) }() + curlCont := s.getContainerByName("curl") + args := fmt.Sprintf("curl --noproxy '*' --http3-only -k https://%s:8443/%s", serverAddress, query) + curlCont.extraRunningArgs = args + o, err := curlCont.combinedOutput() + s.assertNil(err) + s.assertContains(o, "", " not found in the result!") +} + +func (s *NoTopoSuite) TestHttpStaticProm() { + finished := make(chan error, 1) + query := "stats.prom" + vpp := s.getContainerByName("vpp").vppInstance + serverAddress := s.netInterfaces[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, "") + err := <-finished + s.assertNil(err) +} + +func (s *NoTopoSuite) TestNginxAsServer() { query := "return_ok" finished := make(chan error, 1) @@ -48,51 +80,63 @@ func (s *NoTopoSuite) TestNginx() { s.assertNil(nginxCont.run()) vpp := s.getContainerByName("vpp").vppInstance - err := vpp.waitForApp("-app", 5) - s.assertNil(err) + vpp.waitForApp("nginx-", 5) - serverAddress := s.netInterfaces[tapNameVpp].IP4AddressString() + serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() defer func() { os.Remove(query) }() - go startWget(finished, serverAddress, "80", query, "") + go s.startWget(finished, serverAddress, "80", query, "") s.assertNil(<-finished) } +func parseString(s, pattern string) string { + temp := strings.Split(s, "\n") + for _, item := range temp { + if strings.Contains(item, pattern) { + return item + } + } + return "" +} + func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error { nRequests := 1000000 - nClients := 2000 - var args []string - var exeName string + nClients := 1000 - serverAddress := s.netInterfaces[tapNameVpp].IP4AddressString() + serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString() + + vpp := s.getContainerByName("vpp").vppInstance + + nginxCont := s.getContainerByName("nginx") + s.assertNil(nginxCont.run()) + vpp.waitForApp("nginx-", 5) if ab_or_wrk == "ab" { - args = []string{"-n", fmt.Sprintf("%d", nRequests), "-c", - fmt.Sprintf("%d", nClients)} + abCont := s.getContainerByName("ab") + args := fmt.Sprintf("-n %d -c %d", nRequests, nClients) if mode == "rps" { - args = append(args, "-k") + args += " -k" } else if mode != "cps" { return fmt.Errorf("invalid mode %s; expected cps/rps", mode) } - args = append(args, "http://"+serverAddress+":80/64B.json") - exeName = "ab" + // don't exit on socket receive errors + args += " -r" + args += " http://" + serverAddress + ":80/64B.json" + abCont.extraRunningArgs = args + o, err := abCont.combinedOutput() + rps := parseString(o, "Requests per second:") + s.log(rps, err) + s.assertNil(err) } else { - args = []string{"-c", fmt.Sprintf("%d", nClients), "-t", "2", "-d", "30", - "http://" + serverAddress + ":80"} - exeName = "wrk" + wrkCont := s.getContainerByName("wrk") + args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients, + serverAddress) + wrkCont.extraRunningArgs = args + o, err := wrkCont.combinedOutput() + rps := parseString(o, "requests") + s.log(rps, err) + s.assertNil(err) } - - vpp := s.getContainerByName("vpp").vppInstance - - nginxCont := s.getContainerByName("nginx") - s.assertNil(nginxCont.run()) - err := vpp.waitForApp("-app", 5) - s.assertNil(err) - - cmd := exec.Command(exeName, args...) - s.log(cmd) - o, _ := cmd.CombinedOutput() - s.log(string(o)) return nil }