Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "github.com/edwarnicke/exechelper" |
| 7 | ) |
| 8 | |
| 9 | func (s *Veths2Suite) TestVclEchoQuic() { |
| 10 | s.T().Skip("quic test skipping..") |
| 11 | s.testVclEcho("quic") |
| 12 | } |
| 13 | |
| 14 | func (s *Veths2Suite) TestVclEchoUdp() { |
| 15 | s.T().Skip("udp echo currently broken in vpp, skipping..") |
| 16 | s.testVclEcho("udp") |
| 17 | } |
| 18 | |
| 19 | func (s *Veths2Suite) TestVclEchoTcp() { |
| 20 | s.testVclEcho("tcp") |
| 21 | } |
| 22 | |
| 23 | func (s *Veths2Suite) testVclEcho(proto string) { |
| 24 | t := s.T() |
| 25 | |
| 26 | exechelper.Run("docker volume create --name=echo-srv-vol") |
| 27 | exechelper.Run("docker volume create --name=echo-cln-vol") |
| 28 | |
| 29 | srvInstance := "vpp-echo-srv" |
| 30 | clnInstance := "vpp-echo-cln" |
| 31 | echoSrv := "echo-srv" |
| 32 | echoCln := "echo-cln" |
| 33 | |
| 34 | err := dockerRun(srvInstance, "-v echo-srv-vol:/tmp/2veths") |
| 35 | if err != nil { |
| 36 | t.Errorf("%v", err) |
| 37 | return |
| 38 | } |
| 39 | defer func() { exechelper.Run("docker stop " + srvInstance) }() |
| 40 | |
| 41 | err = dockerRun(clnInstance, "-v echo-cln-vol:/tmp/2veths") |
| 42 | if err != nil { |
| 43 | t.Errorf("%v", err) |
| 44 | return |
| 45 | } |
| 46 | defer func() { exechelper.Run("docker stop " + clnInstance) }() |
| 47 | |
| 48 | err = dockerRun(echoSrv, fmt.Sprintf("-v echo-srv-vol:/tmp/%s", echoSrv)) |
| 49 | if err != nil { |
| 50 | t.Errorf("%v", err) |
| 51 | return |
| 52 | } |
| 53 | defer func() { exechelper.Run("docker stop " + echoSrv) }() |
| 54 | |
| 55 | err = dockerRun(echoCln, fmt.Sprintf("-v echo-cln-vol:/tmp/%s", echoCln)) |
| 56 | if err != nil { |
| 57 | t.Errorf("%v", err) |
| 58 | return |
| 59 | } |
| 60 | defer func() { exechelper.Run("docker stop " + echoCln) }() |
| 61 | |
| 62 | _, err = hstExec("2veths srv", srvInstance) |
| 63 | if err != nil { |
| 64 | t.Errorf("%v", err) |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | _, err = hstExec("2veths cln", clnInstance) |
| 69 | if err != nil { |
| 70 | t.Errorf("%v", err) |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | // run server app |
| 75 | _, err = hstExec("echo-server "+proto, echoSrv) |
| 76 | if err != nil { |
| 77 | t.Errorf("echo server: %v", err) |
| 78 | return |
| 79 | } |
| 80 | |
| 81 | o, err := hstExec("echo-client "+proto, echoCln) |
| 82 | if err != nil { |
| 83 | t.Errorf("echo client: %v", err) |
| 84 | } |
| 85 | fmt.Println(o) |
| 86 | } |