9 func (s *NsSuite) TestHttpTps() {
10 iface := s.netInterfaces[clientInterface]
11 client_ip := iface.ip4AddressString()
13 finished := make(chan error, 1)
16 container := s.getContainerByName("vpp")
18 // configure vpp in the container
19 container.vppInstance.vppctl("http tps uri tcp://0.0.0.0/8080")
21 go s.startWget(finished, client_ip, port, "test_file_10M", clientNetns)
27 func (s *VethsSuite) TestHttpCli() {
28 serverContainer := s.getContainerByName("server-vpp")
29 clientContainer := s.getContainerByName("client-vpp")
31 serverVeth := s.netInterfaces[serverInterfaceName]
33 serverContainer.vppInstance.vppctl("http cli server")
35 uri := "http://" + serverVeth.ip4AddressString() + "/80"
37 o := clientContainer.vppInstance.vppctl("http cli client" +
38 " uri " + uri + " query /show/version")
41 s.assertContains(o, "<html>", "<html> not found in the result!")
44 func (s *NoTopoSuite) TestNginxHttp3() {
45 s.SkipUnlessExtendedTestsBuilt()
48 nginxCont := s.getContainerByName("nginx-http3")
49 s.assertNil(nginxCont.run())
51 vpp := s.getContainerByName("vpp").vppInstance
52 vpp.waitForApp("nginx-", 5)
53 serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString()
55 defer func() { os.Remove(query) }()
56 curlCont := s.getContainerByName("curl")
57 args := fmt.Sprintf("curl --noproxy '*' --local-port 55444 --http3-only -k https://%s:8443/%s", serverAddress, query)
58 curlCont.extraRunningArgs = args
59 o, err := curlCont.combinedOutput()
61 s.assertContains(o, "<http>", "<http> not found in the result!")
64 func (s *NoTopoSuite) TestHttpStaticProm() {
65 finished := make(chan error, 1)
67 vpp := s.getContainerByName("vpp").vppInstance
68 serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString()
69 s.log(vpp.vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers"))
70 s.log(vpp.vppctl("prom enable"))
71 go s.startWget(finished, serverAddress, "80", query, "")
76 func (s *NoTopoSuite) TestNginxAsServer() {
78 finished := make(chan error, 1)
80 nginxCont := s.getContainerByName("nginx")
81 s.assertNil(nginxCont.run())
83 vpp := s.getContainerByName("vpp").vppInstance
84 vpp.waitForApp("nginx-", 5)
86 serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString()
88 defer func() { os.Remove(query) }()
89 go s.startWget(finished, serverAddress, "80", query, "")
90 s.assertNil(<-finished)
93 func parseString(s, pattern string) string {
94 temp := strings.Split(s, "\n")
95 for _, item := range temp {
96 if strings.Contains(item, pattern) {
103 func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
107 serverAddress := s.netInterfaces[tapInterfaceName].peer.ip4AddressString()
109 vpp := s.getContainerByName("vpp").vppInstance
111 nginxCont := s.getContainerByName(singleTopoContainerNginx)
112 s.assertNil(nginxCont.run())
113 vpp.waitForApp("nginx-", 5)
115 if ab_or_wrk == "ab" {
116 abCont := s.getContainerByName("ab")
117 args := fmt.Sprintf("-n %d -c %d", nRequests, nClients)
120 } else if mode != "cps" {
121 return fmt.Errorf("invalid mode %s; expected cps/rps", mode)
123 // don't exit on socket receive errors
125 args += " http://" + serverAddress + ":80/64B.json"
126 abCont.extraRunningArgs = args
127 o, err := abCont.combinedOutput()
128 rps := parseString(o, "Requests per second:")
130 s.assertNil(err, "err: '%s', output: '%s'", err, o)
132 wrkCont := s.getContainerByName("wrk")
133 args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients,
135 wrkCont.extraRunningArgs = args
136 o, err := wrkCont.combinedOutput()
137 rps := parseString(o, "requests")
139 s.assertNil(err, "err: '%s', output: '%s'", err, o)
144 func (s *NoTopoSuite) TestNginxPerfCps() {
145 s.assertNil(runNginxPerf(s, "cps", "ab"))
148 func (s *NoTopoSuite) TestNginxPerfRps() {
149 s.assertNil(runNginxPerf(s, "rps", "ab"))
152 func (s *NoTopoSuite) TestNginxPerfWrk() {
153 s.assertNil(runNginxPerf(s, "", "wrk"))