blob: 99b509fdcff8b9193e6f3c53a32035c466f6bd6d [file] [log] [blame]
Filip Tehlarb15a0002022-11-10 12:34:17 +01001package main
2
3import (
4 "strings"
5
6 "github.com/edwarnicke/exechelper"
7)
8
9func (s *NsSuite) TestHttpTps() {
10 t := s.T()
11 finished := make(chan error, 1)
12 server_ip := "10.0.0.2"
13 port := "8080"
14 dockerInstance := "http-tps"
15
16 t.Log("starting vpp..")
17
18 err := dockerRun(dockerInstance, "")
19 if err != nil {
20 t.Errorf("%v", err)
21 return
22 }
23 defer func() { exechelper.Run("docker stop " + dockerInstance) }()
24
25 // start & configure vpp in the container
Filip Tehlar1a9dc752022-11-22 12:49:22 +010026 _, err = hstExec("ConfigureHttpTps", dockerInstance)
Filip Tehlarb15a0002022-11-10 12:34:17 +010027 if err != nil {
28 t.Errorf("%v", err)
29 return
30 }
31
32 go startWget(finished, server_ip, port, "client")
33 // wait for client
34 err = <-finished
35 if err != nil {
36 t.Errorf("%v", err)
37 }
38}
39
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010040func (s *VethsSuite) TestHttpCli() {
Filip Tehlarb15a0002022-11-10 12:34:17 +010041 t := s.T()
42
43 srvInstance := "http-cli-srv"
44 clnInstance := "http-cli-cln"
45 err := dockerRun(srvInstance, "")
46 if err != nil {
47 t.Errorf("%v", err)
48 return
49 }
50 defer func() { exechelper.Run("docker stop " + srvInstance) }()
51
52 err = dockerRun(clnInstance, "")
53 if err != nil {
54 t.Errorf("%v", err)
55 return
56 }
57 defer func() { exechelper.Run("docker stop " + clnInstance) }()
58
Filip Tehlar1a9dc752022-11-22 12:49:22 +010059 _, err = hstExec("Configure2Veths srv", srvInstance)
Filip Tehlarb15a0002022-11-10 12:34:17 +010060 if err != nil {
61 t.Errorf("%v", err)
62 return
63 }
64
Filip Tehlar1a9dc752022-11-22 12:49:22 +010065 _, err = hstExec("Configure2Veths cln", clnInstance)
Filip Tehlarb15a0002022-11-10 12:34:17 +010066 if err != nil {
67 t.Errorf("%v", err)
68 return
69 }
70
71 t.Log("configured IPs...")
72
Filip Tehlar1a9dc752022-11-22 12:49:22 +010073 _, err = hstExec("RunHttpCliSrv", srvInstance)
Filip Tehlarb15a0002022-11-10 12:34:17 +010074 if err != nil {
75 t.Errorf("%v", err)
76 return
77 }
78
79 t.Log("configured http server")
80
Filip Tehlar1a9dc752022-11-22 12:49:22 +010081 o, err := hstExec("RunHttpCliCln /show/version", clnInstance)
Filip Tehlarb15a0002022-11-10 12:34:17 +010082 if err != nil {
83 t.Errorf("%v", err)
84 return
85 }
86
87 if strings.Index(o, "<html>") < 0 {
88 t.Error("<html> not found in the result!")
89 }
90}