Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 3 | import ( |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 4 | "fmt" |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 5 | "net/http" |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 6 | "os" |
Filip Tehlar | 5811356 | 2023-04-15 20:41:18 +0200 | [diff] [blame] | 7 | "strings" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 8 | "time" |
| 9 | |
| 10 | . "github.com/onsi/ginkgo/v2" |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 11 | ) |
| 12 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 13 | func init() { |
| 14 | registerNsTests(HttpTpsTest) |
Matus Fabian | 3d00893 | 2024-05-13 10:29:11 +0200 | [diff] [blame] | 15 | registerVethTests(HttpCliTest, HttpCliConnectErrorTest) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 16 | registerNoTopoTests(NginxHttp3Test, NginxAsServerTest, |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 17 | NginxPerfCpsTest, NginxPerfRpsTest, NginxPerfWrkTest, HeaderServerTest, |
| 18 | HttpStaticMovedTest, HttpStaticNotFoundTest, HttpCliMethodNotAllowedTest, |
| 19 | HttpCliBadRequestTest) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 20 | registerNoTopoSoloTests(HttpStaticPromTest) |
| 21 | } |
| 22 | |
| 23 | func HttpTpsTest(s *NsSuite) { |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 24 | iface := s.getInterfaceByName(clientInterface) |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 25 | client_ip := iface.ip4AddressString() |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 26 | port := "8080" |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 27 | finished := make(chan error, 1) |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 28 | clientNetns := s.getNetNamespaceByName("cln") |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 29 | |
| 30 | container := s.getContainerByName("vpp") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 31 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 32 | // configure vpp in the container |
| 33 | container.vppInstance.vppctl("http tps uri tcp://0.0.0.0/8080") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 34 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 35 | go func() { |
| 36 | defer GinkgoRecover() |
| 37 | s.startWget(finished, client_ip, port, "test_file_10M", clientNetns) |
| 38 | }() |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 39 | // wait for client |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 40 | err := <-finished |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 41 | s.assertNil(err, fmt.Sprint(err)) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 42 | } |
| 43 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 44 | func HttpCliTest(s *VethsSuite) { |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 45 | serverContainer := s.getContainerByName("server-vpp") |
| 46 | clientContainer := s.getContainerByName("client-vpp") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 47 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 48 | serverVeth := s.getInterfaceByName(serverInterfaceName) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 49 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 50 | serverContainer.vppInstance.vppctl("http cli server") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 51 | |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 52 | uri := "http://" + serverVeth.ip4AddressString() + "/80" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 53 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 54 | o := clientContainer.vppInstance.vppctl("http cli client" + |
Filip Tehlar | d894438 | 2023-11-27 13:28:36 +0100 | [diff] [blame] | 55 | " uri " + uri + " query /show/vlib/graph") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 56 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 57 | s.log(o) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 58 | s.assertContains(o, "<html>", "<html> not found in the result!") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 59 | } |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 60 | |
Matus Fabian | 3d00893 | 2024-05-13 10:29:11 +0200 | [diff] [blame] | 61 | func HttpCliConnectErrorTest(s *VethsSuite) { |
| 62 | clientContainer := s.getContainerByName("client-vpp") |
| 63 | |
| 64 | serverVeth := s.getInterfaceByName(serverInterfaceName) |
| 65 | |
| 66 | uri := "http://" + serverVeth.ip4AddressString() + "/80" |
| 67 | |
| 68 | o := clientContainer.vppInstance.vppctl("http cli client" + |
| 69 | " uri " + uri + " query /show/vlib/graph") |
| 70 | |
| 71 | s.log(o) |
| 72 | s.assertContains(o, "failed to connect") |
| 73 | } |
| 74 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 75 | func NginxHttp3Test(s *NoTopoSuite) { |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 76 | s.SkipUnlessExtendedTestsBuilt() |
| 77 | |
| 78 | query := "index.html" |
| 79 | nginxCont := s.getContainerByName("nginx-http3") |
| 80 | s.assertNil(nginxCont.run()) |
| 81 | |
| 82 | vpp := s.getContainerByName("vpp").vppInstance |
| 83 | vpp.waitForApp("nginx-", 5) |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 84 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 85 | |
| 86 | defer func() { os.Remove(query) }() |
| 87 | curlCont := s.getContainerByName("curl") |
Filip Tehlar | 87241fe | 2024-01-17 21:45:28 +0100 | [diff] [blame] | 88 | args := fmt.Sprintf("curl --noproxy '*' --local-port 55444 --http3-only -k https://%s:8443/%s", serverAddress, query) |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 89 | curlCont.extraRunningArgs = args |
| 90 | o, err := curlCont.combinedOutput() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 91 | s.assertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 92 | s.assertContains(o, "<http>", "<http> not found in the result!") |
| 93 | } |
| 94 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 95 | func HttpStaticPromTest(s *NoTopoSuite) { |
Filip Tehlar | cc1475c | 2023-11-29 12:59:05 +0100 | [diff] [blame] | 96 | finished := make(chan error, 1) |
| 97 | query := "stats.prom" |
| 98 | vpp := s.getContainerByName("vpp").vppInstance |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 99 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
Filip Tehlar | cc1475c | 2023-11-29 12:59:05 +0100 | [diff] [blame] | 100 | s.log(vpp.vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) |
| 101 | s.log(vpp.vppctl("prom enable")) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 102 | time.Sleep(time.Second * 5) |
| 103 | go func() { |
| 104 | defer GinkgoRecover() |
| 105 | s.startWget(finished, serverAddress, "80", query, "") |
| 106 | }() |
Filip Tehlar | cc1475c | 2023-11-29 12:59:05 +0100 | [diff] [blame] | 107 | err := <-finished |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 108 | s.assertNil(err) |
Filip Tehlar | cc1475c | 2023-11-29 12:59:05 +0100 | [diff] [blame] | 109 | } |
| 110 | |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 111 | func HttpStaticMovedTest(s *NoTopoSuite) { |
| 112 | vpp := s.getContainerByName("vpp").vppInstance |
| 113 | vpp.container.exec("mkdir -p /tmp/tmp.aaa") |
| 114 | vpp.container.createFile("/tmp/tmp.aaa/index.html", "<http><body><p>Hello</p></body></http>") |
| 115 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
| 116 | s.log(vpp.vppctl("http static server www-root /tmp uri tcp://" + serverAddress + "/80 debug")) |
| 117 | |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 118 | transport := http.DefaultTransport |
| 119 | transport.(*http.Transport).Proxy = nil |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 120 | client := &http.Client{ |
| 121 | CheckRedirect: func(req *http.Request, via []*http.Request) error { |
| 122 | return http.ErrUseLastResponse |
| 123 | }, |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 124 | Transport: transport, |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 125 | } |
| 126 | req, err := http.NewRequest("GET", "http://"+serverAddress+":80/tmp.aaa", nil) |
| 127 | s.assertNil(err, fmt.Sprint(err)) |
| 128 | resp, err := client.Do(req) |
| 129 | s.assertNil(err, fmt.Sprint(err)) |
| 130 | defer resp.Body.Close() |
| 131 | s.assertEqual(301, resp.StatusCode) |
| 132 | s.assertNotEqual("", resp.Header.Get("Location")) |
| 133 | } |
| 134 | |
| 135 | func HttpStaticNotFoundTest(s *NoTopoSuite) { |
| 136 | vpp := s.getContainerByName("vpp").vppInstance |
| 137 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
| 138 | s.log(vpp.vppctl("http static server www-root /tmp uri tcp://" + serverAddress + "/80 debug")) |
| 139 | |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 140 | transport := http.DefaultTransport |
| 141 | transport.(*http.Transport).Proxy = nil |
| 142 | client := &http.Client{Transport: transport} |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 143 | req, err := http.NewRequest("GET", "http://"+serverAddress+":80/notfound.html", nil) |
| 144 | s.assertNil(err, fmt.Sprint(err)) |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 145 | resp, err := client.Do(req) |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 146 | s.assertNil(err, fmt.Sprint(err)) |
| 147 | defer resp.Body.Close() |
| 148 | s.assertEqual(404, resp.StatusCode) |
| 149 | } |
| 150 | |
| 151 | func HttpCliMethodNotAllowedTest(s *NoTopoSuite) { |
Matus Fabian | 616201a | 2024-05-02 11:17:15 +0200 | [diff] [blame] | 152 | vpp := s.getContainerByName("vpp").vppInstance |
| 153 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
| 154 | vpp.vppctl("http cli server") |
| 155 | |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 156 | transport := http.DefaultTransport |
| 157 | transport.(*http.Transport).Proxy = nil |
| 158 | client := &http.Client{Transport: transport} |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 159 | req, err := http.NewRequest("POST", "http://"+serverAddress+":80/test", nil) |
Matus Fabian | 616201a | 2024-05-02 11:17:15 +0200 | [diff] [blame] | 160 | s.assertNil(err, fmt.Sprint(err)) |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 161 | resp, err := client.Do(req) |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 162 | s.assertNil(err, fmt.Sprint(err)) |
| 163 | defer resp.Body.Close() |
| 164 | s.assertEqual(405, resp.StatusCode) |
| 165 | // TODO: need to be fixed in http code |
| 166 | //s.assertNotEqual("", resp.Header.Get("Allow")) |
| 167 | } |
| 168 | |
| 169 | func HttpCliBadRequestTest(s *NoTopoSuite) { |
| 170 | vpp := s.getContainerByName("vpp").vppInstance |
| 171 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
| 172 | vpp.vppctl("http cli server") |
| 173 | |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 174 | transport := http.DefaultTransport |
| 175 | transport.(*http.Transport).Proxy = nil |
| 176 | client := &http.Client{Transport: transport} |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 177 | req, err := http.NewRequest("GET", "http://"+serverAddress+":80", nil) |
| 178 | s.assertNil(err, fmt.Sprint(err)) |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 179 | resp, err := client.Do(req) |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 180 | s.assertNil(err, fmt.Sprint(err)) |
| 181 | defer resp.Body.Close() |
| 182 | s.assertEqual(400, resp.StatusCode) |
| 183 | } |
| 184 | |
| 185 | func HeaderServerTest(s *NoTopoSuite) { |
| 186 | vpp := s.getContainerByName("vpp").vppInstance |
| 187 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
| 188 | vpp.vppctl("http cli server") |
| 189 | |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 190 | transport := http.DefaultTransport |
| 191 | transport.(*http.Transport).Proxy = nil |
| 192 | client := &http.Client{Transport: transport} |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 193 | req, err := http.NewRequest("GET", "http://"+serverAddress+":80/show/version", nil) |
| 194 | s.assertNil(err, fmt.Sprint(err)) |
Matus Fabian | 595d8cb | 2024-05-17 11:28:43 +0200 | [diff] [blame] | 195 | resp, err := client.Do(req) |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 196 | s.assertNil(err, fmt.Sprint(err)) |
| 197 | defer resp.Body.Close() |
| 198 | s.assertEqual("http_cli_server", resp.Header.Get("Server")) |
Matus Fabian | 616201a | 2024-05-02 11:17:15 +0200 | [diff] [blame] | 199 | } |
| 200 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 201 | func NginxAsServerTest(s *NoTopoSuite) { |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 202 | query := "return_ok" |
| 203 | finished := make(chan error, 1) |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 204 | |
| 205 | nginxCont := s.getContainerByName("nginx") |
| 206 | s.assertNil(nginxCont.run()) |
| 207 | |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 208 | vpp := s.getContainerByName("vpp").vppInstance |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 209 | vpp.waitForApp("nginx-", 5) |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 210 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 211 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 212 | |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 213 | defer func() { os.Remove(query) }() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 214 | go func() { |
| 215 | defer GinkgoRecover() |
| 216 | s.startWget(finished, serverAddress, "80", query, "") |
| 217 | }() |
Filip Tehlar | c204c87 | 2022-12-21 08:59:16 +0100 | [diff] [blame] | 218 | s.assertNil(<-finished) |
| 219 | } |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 220 | |
Filip Tehlar | 5811356 | 2023-04-15 20:41:18 +0200 | [diff] [blame] | 221 | func parseString(s, pattern string) string { |
| 222 | temp := strings.Split(s, "\n") |
| 223 | for _, item := range temp { |
| 224 | if strings.Contains(item, pattern) { |
| 225 | return item |
| 226 | } |
| 227 | } |
| 228 | return "" |
| 229 | } |
| 230 | |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 231 | func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error { |
| 232 | nRequests := 1000000 |
Filip Tehlar | dda1f68 | 2023-04-24 17:52:50 +0200 | [diff] [blame] | 233 | nClients := 1000 |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 234 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 235 | serverAddress := s.getInterfaceByName(tapInterfaceName).peer.ip4AddressString() |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 236 | |
Maros Ondrejicka | 7550dd2 | 2023-02-07 20:40:27 +0100 | [diff] [blame] | 237 | vpp := s.getContainerByName("vpp").vppInstance |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 238 | |
adrianvillin | fbf5f2b | 2024-02-13 03:26:25 -0500 | [diff] [blame] | 239 | nginxCont := s.getContainerByName(singleTopoContainerNginx) |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 240 | s.assertNil(nginxCont.run()) |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 241 | vpp.waitForApp("nginx-", 5) |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 242 | |
Filip Tehlar | b41b0af | 2023-03-20 12:39:20 +0100 | [diff] [blame] | 243 | if ab_or_wrk == "ab" { |
| 244 | abCont := s.getContainerByName("ab") |
| 245 | args := fmt.Sprintf("-n %d -c %d", nRequests, nClients) |
| 246 | if mode == "rps" { |
| 247 | args += " -k" |
| 248 | } else if mode != "cps" { |
| 249 | return fmt.Errorf("invalid mode %s; expected cps/rps", mode) |
| 250 | } |
Filip Tehlar | dda1f68 | 2023-04-24 17:52:50 +0200 | [diff] [blame] | 251 | // don't exit on socket receive errors |
| 252 | args += " -r" |
Filip Tehlar | b41b0af | 2023-03-20 12:39:20 +0100 | [diff] [blame] | 253 | args += " http://" + serverAddress + ":80/64B.json" |
| 254 | abCont.extraRunningArgs = args |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 255 | time.Sleep(time.Second * 10) |
Filip Tehlar | b41b0af | 2023-03-20 12:39:20 +0100 | [diff] [blame] | 256 | o, err := abCont.combinedOutput() |
Filip Tehlar | 5811356 | 2023-04-15 20:41:18 +0200 | [diff] [blame] | 257 | rps := parseString(o, "Requests per second:") |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 258 | s.log(rps) |
| 259 | s.log(err) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 260 | s.assertNil(err, "err: '%s', output: '%s'", err, o) |
Filip Tehlar | b41b0af | 2023-03-20 12:39:20 +0100 | [diff] [blame] | 261 | } else { |
| 262 | wrkCont := s.getContainerByName("wrk") |
| 263 | args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients, |
| 264 | serverAddress) |
| 265 | wrkCont.extraRunningArgs = args |
| 266 | o, err := wrkCont.combinedOutput() |
Filip Tehlar | 5811356 | 2023-04-15 20:41:18 +0200 | [diff] [blame] | 267 | rps := parseString(o, "requests") |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 268 | s.log(rps) |
| 269 | s.log(err) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 270 | s.assertNil(err, "err: '%s', output: '%s'", err, o) |
Filip Tehlar | b41b0af | 2023-03-20 12:39:20 +0100 | [diff] [blame] | 271 | } |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 272 | return nil |
| 273 | } |
| 274 | |
Adrian Villin | 0df582e | 2024-05-22 09:26:47 -0400 | [diff] [blame] | 275 | // unstable with multiple workers |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 276 | func NginxPerfCpsTest(s *NoTopoSuite) { |
Adrian Villin | 0df582e | 2024-05-22 09:26:47 -0400 | [diff] [blame] | 277 | s.SkipIfMultiWorker() |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 278 | s.assertNil(runNginxPerf(s, "cps", "ab")) |
| 279 | } |
| 280 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 281 | func NginxPerfRpsTest(s *NoTopoSuite) { |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 282 | s.assertNil(runNginxPerf(s, "rps", "ab")) |
| 283 | } |
| 284 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 285 | func NginxPerfWrkTest(s *NoTopoSuite) { |
Filip Tehlar | 8df3de4 | 2023-01-27 13:14:34 +0100 | [diff] [blame] | 286 | s.assertNil(runNginxPerf(s, "", "wrk")) |
| 287 | } |