b61ea6c8b0dbef169c2fb21f4302dfa59c62aca3
[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.loadNetworkTopology("2taps")
18
19         s.loadContainerTopology("nginxProxyAndServer")
20 }
21
22 func (s *NginxSuite) SetupTest() {
23         s.skipIfUnconfiguring()
24
25         s.setupVolumes()
26         s.setupContainers()
27
28         // Setup test conditions
29         var startupConfig Stanza
30         startupConfig.
31                 newStanza("session").
32                 append("enable").
33                 append("use-app-socket-api").close()
34
35         // ... for proxy
36         vppProxyContainer := s.getContainerByName(vppProxyContainerName)
37         proxyVpp, _ := vppProxyContainer.newVppInstance(startupConfig)
38         proxyVpp.start()
39
40         clientInterface := s.netInterfaces[mirroringClientInterfaceName]
41         proxyVpp.createTap(clientInterface, 1)
42
43         serverInterface := s.netInterfaces[mirroringServerInterfaceName]
44         proxyVpp.createTap(serverInterface, 2)
45
46         nginxContainer := s.getTransientContainerByName(nginxProxyContainerName)
47         nginxContainer.create()
48
49         values := struct {
50                 Proxy  string
51                 Server string
52         }{
53                 Proxy:  clientInterface.peer.ip4AddressString(),
54                 Server: serverInterface.ip4AddressString(),
55         }
56         nginxContainer.createConfig(
57                 "/nginx.conf",
58                 "./resources/nginx/nginx_proxy_mirroring.conf",
59                 values,
60         )
61         nginxContainer.start()
62
63         proxyVpp.waitForApp("nginx-", 5)
64 }