blob: f49d9bcf2276ca1d8079d848eeed0b92c7a59574 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
Adrian Villincee15aa2024-03-14 11:42:55 -04003import (
Adrian Villin4677d922024-06-14 09:32:39 +02004 . "fd.io/hs-test/infra"
Adrian Villincee15aa2024-03-14 11:42:55 -04005 "fmt"
Adrian Villincee15aa2024-03-14 11:42:55 -04006 . "github.com/onsi/ginkgo/v2"
7)
8
9func init() {
Adrian Villin4677d922024-06-14 09:32:39 +020010 RegisterTapTests(LinuxIperfTest)
Adrian Villincee15aa2024-03-14 11:42:55 -040011}
12
13func LinuxIperfTest(s *TapSuite) {
Filip Tehlar229f5fc2022-08-09 14:44:47 +000014 clnCh := make(chan error)
15 stopServerCh := make(chan struct{})
16 srvCh := make(chan error, 1)
Maros Ondrejicka87531802022-12-19 20:35:27 +010017 clnRes := make(chan string, 1)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000018 defer func() {
19 stopServerCh <- struct{}{}
20 }()
21
Adrian Villincee15aa2024-03-14 11:42:55 -040022 go func() {
23 defer GinkgoRecover()
Adrian Villin4677d922024-06-14 09:32:39 +020024 s.StartServerApp(srvCh, stopServerCh, nil)
Adrian Villincee15aa2024-03-14 11:42:55 -040025 }()
Filip Tehlar229f5fc2022-08-09 14:44:47 +000026 err := <-srvCh
Adrian Villin4677d922024-06-14 09:32:39 +020027 s.AssertNil(err, fmt.Sprint(err))
28 s.Log("server running")
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010029
Adrian Villin4677d922024-06-14 09:32:39 +020030 ipAddress := s.GetInterfaceByName(TapInterfaceName).Ip4AddressString()
Adrian Villincee15aa2024-03-14 11:42:55 -040031 go func() {
32 defer GinkgoRecover()
Adrian Villin4677d922024-06-14 09:32:39 +020033 s.StartClientApp(ipAddress, nil, clnCh, clnRes)
Adrian Villincee15aa2024-03-14 11:42:55 -040034 }()
Adrian Villin4677d922024-06-14 09:32:39 +020035 s.Log("client running")
36 s.Log(<-clnRes)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000037 err = <-clnCh
Adrian Villin4677d922024-06-14 09:32:39 +020038 s.AssertNil(err, "err: '%s', ip: '%s'", err, ipAddress)
39 s.Log("Test completed")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000040}