hs-test: add more asserts
[vpp.git] / extras / hs-test / suite_nginx_test.go
1 package main
2
3 const (
4         // These correspond to names used in yaml config
5         mirroringClientInterfaceName = "hst_client"
6         mirroringServerInterfaceName = "hst_server"
7         vppProxyContainerName        = "vpp-proxy"
8         nginxProxyContainerName      = "nginx-proxy"
9         nginxServerContainerName     = "nginx-server"
10 )
11
12 type NginxSuite struct {
13         HstSuite
14 }
15
16 func (s *NginxSuite) SetupSuite() {
17         s.HstSuite.SetupSuite()
18         s.loadNetworkTopology("2taps")
19         s.loadContainerTopology("nginxProxyAndServer")
20 }
21
22 func (s *NginxSuite) SetupTest() {
23         s.HstSuite.SetupTest()
24
25         // Setup test conditions
26         var sessionConfig Stanza
27         sessionConfig.
28                 newStanza("session").
29                 append("enable").
30                 append("use-app-socket-api").close()
31
32         cpus := s.AllocateCpus()
33         // ... for proxy
34         vppProxyContainer := s.getContainerByName(vppProxyContainerName)
35         proxyVpp, _ := vppProxyContainer.newVppInstance(cpus, sessionConfig)
36         s.assertNil(proxyVpp.start())
37
38         clientInterface := s.netInterfaces[mirroringClientInterfaceName]
39         s.assertNil(proxyVpp.createTap(clientInterface, 1))
40
41         serverInterface := s.netInterfaces[mirroringServerInterfaceName]
42         s.assertNil(proxyVpp.createTap(serverInterface, 2))
43
44         nginxContainer := s.getTransientContainerByName(nginxProxyContainerName)
45         nginxContainer.create()
46
47         values := struct {
48                 Proxy  string
49                 Server string
50         }{
51                 Proxy:  clientInterface.peer.ip4AddressString(),
52                 Server: serverInterface.ip4AddressString(),
53         }
54         nginxContainer.createConfig(
55                 "/nginx.conf",
56                 "./resources/nginx/nginx_proxy_mirroring.conf",
57                 values,
58         )
59         s.assertNil(nginxContainer.start())
60
61         proxyVpp.waitForApp("nginx-", 5)
62 }