blob: d2fb5a3c85a3a4dc85e09ba77d85a8162e10ab6f [file] [log] [blame]
Filip Tehlarb15a0002022-11-10 12:34:17 +01001package main
2
3import (
Filip Tehlarb15a0002022-11-10 12:34:17 +01004 "github.com/edwarnicke/exechelper"
5)
6
7func (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 Ondrejicka98a91e82022-12-06 15:38:05 +010016 s.assertNil(dockerRun(dockerInstance, ""), "failed to start docker")
Filip Tehlarb15a0002022-11-10 12:34:17 +010017 defer func() { exechelper.Run("docker stop " + dockerInstance) }()
18
19 // start & configure vpp in the container
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010020 _, err := hstExec("ConfigureHttpTps", dockerInstance)
21 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010022
23 go startWget(finished, server_ip, port, "client")
24 // wait for client
25 err = <-finished
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010026 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010027}
28
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010029func (s *VethsSuite) TestHttpCli() {
Filip Tehlarb15a0002022-11-10 12:34:17 +010030 t := s.T()
31
32 srvInstance := "http-cli-srv"
33 clnInstance := "http-cli-cln"
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010034 s.assertNil(dockerRun(srvInstance, ""), "failed to start docker (srv)")
Filip Tehlarb15a0002022-11-10 12:34:17 +010035 defer func() { exechelper.Run("docker stop " + srvInstance) }()
36
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010037 s.assertNil(dockerRun(clnInstance, ""), "failed to start docker (cln)")
Filip Tehlarb15a0002022-11-10 12:34:17 +010038 defer func() { exechelper.Run("docker stop " + clnInstance) }()
39
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010040 _, err := hstExec("Configure2Veths srv", srvInstance)
41 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010042
Filip Tehlar1a9dc752022-11-22 12:49:22 +010043 _, err = hstExec("Configure2Veths cln", clnInstance)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010044 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010045
46 t.Log("configured IPs...")
47
Filip Tehlar1a9dc752022-11-22 12:49:22 +010048 _, err = hstExec("RunHttpCliSrv", srvInstance)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010049 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010050
51 t.Log("configured http server")
52
Filip Tehlar1a9dc752022-11-22 12:49:22 +010053 o, err := hstExec("RunHttpCliCln /show/version", clnInstance)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010054 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010055
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010056 s.assertContains(o, "<html>", "<html> not found in the result!")
Filip Tehlarb15a0002022-11-10 12:34:17 +010057}