blob: 665a3e4fa8629526ee8d7d789a0040081eb030b2 [file] [log] [blame]
Filip Tehlarb15a0002022-11-10 12:34:17 +01001package main
2
Filip Tehlarc204c872022-12-21 08:59:16 +01003import (
4 "os"
5 "time"
6)
7
Filip Tehlarb15a0002022-11-10 12:34:17 +01008func (s *NsSuite) TestHttpTps() {
Filip Tehlarb15a0002022-11-10 12:34:17 +01009 finished := make(chan error, 1)
10 server_ip := "10.0.0.2"
11 port := "8080"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010012
13 container := s.getContainerByName("vpp")
Filip Tehlarb15a0002022-11-10 12:34:17 +010014
Maros Ondrejicka87531802022-12-19 20:35:27 +010015 s.log("starting vpp..")
Filip Tehlarb15a0002022-11-10 12:34:17 +010016
Filip Tehlarb15a0002022-11-10 12:34:17 +010017 // start & configure vpp in the container
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010018 _, err := container.execAction("ConfigureHttpTps")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010019 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010020
Filip Tehlarc204c872022-12-21 08:59:16 +010021 go startWget(finished, server_ip, port, "test_file_10M", "client")
Filip Tehlarb15a0002022-11-10 12:34:17 +010022 // wait for client
23 err = <-finished
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010024 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010025}
26
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010027func (s *VethsSuite) TestHttpCli() {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010028 serverContainer := s.getContainerByName("server-vpp")
29 clientContainer := s.getContainerByName("client-vpp")
Filip Tehlarb15a0002022-11-10 12:34:17 +010030
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010031 _, err := serverContainer.execAction("Configure2Veths srv")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010032 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010033
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010034 _, err = clientContainer.execAction("Configure2Veths cln")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010035 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010036
Maros Ondrejicka87531802022-12-19 20:35:27 +010037 s.log("configured IPs...")
Filip Tehlarb15a0002022-11-10 12:34:17 +010038
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010039 _, err = serverContainer.execAction("RunHttpCliSrv")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010040 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010041
Maros Ondrejicka87531802022-12-19 20:35:27 +010042 s.log("configured http server")
Filip Tehlarb15a0002022-11-10 12:34:17 +010043
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010044 o, err := clientContainer.execAction("RunHttpCliCln /show/version")
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010045 s.assertNil(err)
Filip Tehlarb15a0002022-11-10 12:34:17 +010046
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010047 s.assertContains(o, "<html>", "<html> not found in the result!")
Filip Tehlarb15a0002022-11-10 12:34:17 +010048}
Filip Tehlarc204c872022-12-21 08:59:16 +010049
50func (s *NoTopoSuite) TestNginx() {
51 query := "return_ok"
52 finished := make(chan error, 1)
53 vppCont := s.getContainerByName("vpp")
54 vppInst := NewVppInstance(vppCont)
55 vppInst.actionFuncName = "ConfigureTap"
56 s.assertNil(vppInst.start(), "failed to start vpp")
57
58 nginxCont := s.getContainerByName("nginx")
59 s.assertNil(nginxCont.run())
60
61 time.Sleep(3 * time.Second)
62
63 defer func() { os.Remove(query) }()
64 go startWget(finished, "10.10.10.1", "80", query, "")
65 s.assertNil(<-finished)
66}