11 func (s *NsSuite) TestHttpTps() {
12 iface := s.netInterfaces[clientInterface]
13 client_ip := iface.Ip4AddressString()
15 finished := make(chan error, 1)
17 container := s.getContainerByName("vpp")
19 // configure vpp in the container
20 container.vppInstance.vppctl("http tps uri tcp://0.0.0.0/8080")
22 go startWget(finished, client_ip, port, "test_file_10M", "client")
28 func (s *VethsSuite) TestHttpCli() {
29 serverContainer := s.getContainerByName("server-vpp")
30 clientContainer := s.getContainerByName("client-vpp")
32 serverVeth := s.netInterfaces[serverInterfaceName]
34 serverContainer.vppInstance.vppctl("http cli server")
36 uri := "http://" + serverVeth.Ip4AddressString() + "/80"
38 o := clientContainer.vppInstance.vppctl("http cli client" +
39 " uri " + uri + " query /show/version")
42 s.assertContains(o, "<html>", "<html> not found in the result!")
45 func waitForApp(vppInst *VppInstance, appName string, timeout int) error {
46 for i := 0; i < timeout; i++ {
47 o := vppInst.vppctl("show app")
48 if strings.Contains(o, appName) {
51 time.Sleep(1 * time.Second)
53 return fmt.Errorf("Timeout while waiting for app '%s'", appName)
56 func (s *NoTopoSuite) TestNginx() {
58 finished := make(chan error, 1)
59 vppCont := s.getContainerByName("vpp")
60 vppInst := NewVppInstance(vppCont)
61 vppInst.actionFuncName = "ConfigureTap"
62 s.assertNil(vppInst.start(), "failed to start vpp")
64 nginxCont := s.getContainerByName("nginx")
65 s.assertNil(nginxCont.run())
67 err := waitForApp(vppInst, "-app", 5)
70 defer func() { os.Remove(query) }()
71 go startWget(finished, "10.10.10.1", "80", query, "")
72 s.assertNil(<-finished)
75 func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
81 if ab_or_wrk == "ab" {
82 args = []string{"-n", fmt.Sprintf("%d", nRequests), "-c",
83 fmt.Sprintf("%d", nClients)}
85 args = append(args, "-k")
86 } else if mode != "cps" {
87 return fmt.Errorf("invalid mode %s; expected cps/rps", mode)
89 args = append(args, "http://10.10.10.1:80/64B.json")
92 args = []string{"-c", fmt.Sprintf("%d", nClients), "-t", "2", "-d", "30",
93 "http://10.10.10.1:80"}
97 vppCont := s.getContainerByName("vpp")
98 vppInst := NewVppInstance(vppCont)
99 vppInst.actionFuncName = "ConfigureTap"
100 s.assertNil(vppInst.start(), "failed to start vpp")
102 nginxCont := s.getContainerByName("nginx")
103 s.assertNil(nginxCont.run())
104 err := waitForApp(vppInst, "-app", 5)
107 cmd := exec.Command(exeName, args...)
109 o, _ := cmd.CombinedOutput()
114 func (s *NoTopoSuite) TestNginxPerfCps() {
115 s.assertNil(runNginxPerf(s, "cps", "ab"))
118 func (s *NoTopoSuite) TestNginxPerfRps() {
119 s.assertNil(runNginxPerf(s, "rps", "ab"))
122 func (s *NoTopoSuite) TestNginxPerfWrk() {
123 s.assertNil(runNginxPerf(s, "", "wrk"))