Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 4 | "github.com/edwarnicke/exechelper" |
| 5 | ) |
| 6 | |
| 7 | func (s *NsSuite) TestHttpTps() { |
| 8 | t := s.T() |
| 9 | finished := make(chan error, 1) |
| 10 | server_ip := "10.0.0.2" |
| 11 | port := "8080" |
| 12 | dockerInstance := "http-tps" |
| 13 | |
| 14 | t.Log("starting vpp..") |
| 15 | |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 16 | s.assertNil(dockerRun(dockerInstance, ""), "failed to start docker") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 17 | defer func() { exechelper.Run("docker stop " + dockerInstance) }() |
| 18 | |
| 19 | // start & configure vpp in the container |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 20 | _, err := hstExec("ConfigureHttpTps", dockerInstance) |
| 21 | s.assertNil(err) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 22 | |
| 23 | go startWget(finished, server_ip, port, "client") |
| 24 | // wait for client |
| 25 | err = <-finished |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 26 | s.assertNil(err) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 27 | } |
| 28 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 29 | func (s *VethsSuite) TestHttpCli() { |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 30 | t := s.T() |
| 31 | |
| 32 | srvInstance := "http-cli-srv" |
| 33 | clnInstance := "http-cli-cln" |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 34 | s.assertNil(dockerRun(srvInstance, ""), "failed to start docker (srv)") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 35 | defer func() { exechelper.Run("docker stop " + srvInstance) }() |
| 36 | |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 37 | s.assertNil(dockerRun(clnInstance, ""), "failed to start docker (cln)") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 38 | defer func() { exechelper.Run("docker stop " + clnInstance) }() |
| 39 | |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 40 | _, err := hstExec("Configure2Veths srv", srvInstance) |
| 41 | s.assertNil(err) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 42 | |
Filip Tehlar | 1a9dc75 | 2022-11-22 12:49:22 +0100 | [diff] [blame] | 43 | _, err = hstExec("Configure2Veths cln", clnInstance) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 44 | s.assertNil(err) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 45 | |
| 46 | t.Log("configured IPs...") |
| 47 | |
Filip Tehlar | 1a9dc75 | 2022-11-22 12:49:22 +0100 | [diff] [blame] | 48 | _, err = hstExec("RunHttpCliSrv", srvInstance) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 49 | s.assertNil(err) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 50 | |
| 51 | t.Log("configured http server") |
| 52 | |
Filip Tehlar | 1a9dc75 | 2022-11-22 12:49:22 +0100 | [diff] [blame] | 53 | o, err := hstExec("RunHttpCliCln /show/version", clnInstance) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 54 | s.assertNil(err) |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 55 | |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 56 | s.assertContains(o, "<html>", "<html> not found in the result!") |
Filip Tehlar | b15a000 | 2022-11-10 12:34:17 +0100 | [diff] [blame] | 57 | } |