Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 5 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 6 | . "fd.io/hs-test/infra" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 7 | . "github.com/onsi/ginkgo/v2" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 8 | ) |
| 9 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 10 | func init() { |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 11 | RegisterLdpTests(LDPreloadIperfVppTest, LDPreloadIperfVppInterruptModeTest, RedisBenchmarkTest) |
Adrian Villin | 1fde999 | 2024-06-24 08:14:05 -0400 | [diff] [blame] | 12 | } |
| 13 | |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 14 | func LDPreloadIperfVppInterruptModeTest(s *LdpSuite) { |
Adrian Villin | 1fde999 | 2024-06-24 08:14:05 -0400 | [diff] [blame] | 15 | LDPreloadIperfVppTest(s) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 16 | } |
| 17 | |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 18 | func LDPreloadIperfVppTest(s *LdpSuite) { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 19 | clientContainer := s.GetContainerByName("client-vpp") |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 20 | serverContainer := s.GetContainerByName("server-vpp") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 21 | |
| 22 | stopServerCh := make(chan struct{}, 1) |
| 23 | srvCh := make(chan error, 1) |
| 24 | clnCh := make(chan error) |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 25 | clnRes := make(chan string, 1) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 26 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 27 | go func() { |
| 28 | defer GinkgoRecover() |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 29 | cmd := "iperf3 -4 -s -p " + s.GetPortFromPpid() |
| 30 | s.StartServerApp(serverContainer, "iperf3", cmd, srvCh, stopServerCh) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 31 | }() |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 32 | |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 33 | err := <-srvCh |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 34 | s.AssertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 35 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 36 | serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 37 | go func() { |
| 38 | defer GinkgoRecover() |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 39 | cmd := "iperf3 -c " + serverVethAddress + " -u -l 1460 -b 10g -p " + s.GetPortFromPpid() |
| 40 | s.StartClientApp(clientContainer, cmd, clnCh, clnRes) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 41 | }() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 42 | s.Log(<-clnRes) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 43 | |
| 44 | // wait for client's result |
| 45 | err = <-clnCh |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 46 | s.AssertNil(err, fmt.Sprint(err)) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 47 | |
| 48 | // stop server |
| 49 | stopServerCh <- struct{}{} |
| 50 | } |
Adrian Villin | d01a63a | 2024-08-15 12:53:53 +0200 | [diff] [blame] | 51 | |
| 52 | func RedisBenchmarkTest(s *LdpSuite) { |
| 53 | s.SkipIfMultiWorker() |
| 54 | |
| 55 | serverContainer := s.GetContainerByName("server-vpp") |
| 56 | clientContainer := s.GetContainerByName("client-vpp") |
| 57 | |
| 58 | serverVethAddress := s.GetInterfaceByName(ServerInterfaceName).Ip4AddressString() |
| 59 | runningSrv := make(chan error) |
| 60 | doneSrv := make(chan struct{}) |
| 61 | clnCh := make(chan error) |
| 62 | clnRes := make(chan string, 1) |
| 63 | |
| 64 | go func() { |
| 65 | defer GinkgoRecover() |
| 66 | cmd := "redis-server --daemonize yes --protected-mode no --bind " + serverVethAddress |
| 67 | s.StartServerApp(serverContainer, "redis-server", cmd, runningSrv, doneSrv) |
| 68 | }() |
| 69 | |
| 70 | err := <-runningSrv |
| 71 | s.AssertNil(err) |
| 72 | |
| 73 | go func() { |
| 74 | defer GinkgoRecover() |
| 75 | var cmd string |
| 76 | if *NConfiguredCpus == 1 { |
| 77 | cmd = "redis-benchmark --threads 1 -h " + serverVethAddress |
| 78 | } else { |
| 79 | cmd = "redis-benchmark --threads " + fmt.Sprint(*NConfiguredCpus) + "-h " + serverVethAddress |
| 80 | } |
| 81 | s.StartClientApp(clientContainer, cmd, clnCh, clnRes) |
| 82 | }() |
| 83 | |
| 84 | s.Log(<-clnRes) |
| 85 | // wait for client's result |
| 86 | err = <-clnCh |
| 87 | s.AssertNil(err, fmt.Sprint(err)) |
| 88 | // stop server |
| 89 | doneSrv <- struct{}{} |
| 90 | } |