Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 3 | import ( |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 4 | . "fd.io/hs-test/infra" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 5 | "fmt" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 6 | . "github.com/onsi/ginkgo/v2" |
| 7 | ) |
| 8 | |
| 9 | func init() { |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 10 | RegisterTapTests(LinuxIperfTest) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | func LinuxIperfTest(s *TapSuite) { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 14 | clnCh := make(chan error) |
| 15 | stopServerCh := make(chan struct{}) |
| 16 | srvCh := make(chan error, 1) |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 17 | clnRes := make(chan string, 1) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 18 | defer func() { |
| 19 | stopServerCh <- struct{}{} |
| 20 | }() |
| 21 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 22 | go func() { |
| 23 | defer GinkgoRecover() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 24 | s.StartServerApp(srvCh, stopServerCh, nil) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 25 | }() |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 26 | err := <-srvCh |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 27 | s.AssertNil(err, fmt.Sprint(err)) |
| 28 | s.Log("server running") |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 29 | |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 30 | ipAddress := s.GetInterfaceByName(TapInterfaceName).Ip4AddressString() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 31 | go func() { |
| 32 | defer GinkgoRecover() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 33 | s.StartClientApp(ipAddress, nil, clnCh, clnRes) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 34 | }() |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 35 | s.Log("client running") |
| 36 | s.Log(<-clnRes) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 37 | err = <-clnCh |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 38 | s.AssertNil(err, "err: '%s', ip: '%s'", err, ipAddress) |
| 39 | s.Log("Test completed") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 40 | } |