blob: c250ed7843e717a5715ee0675ef5c8d74132454a [file] [log] [blame]
Maros Ondrejickac2f76f42023-02-27 13:22:45 +01001package main
2
3const (
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
12type NginxSuite struct {
13 HstSuite
14}
15
16func (s *NginxSuite) SetupSuite() {
Filip Tehlar608d0062023-04-28 10:29:47 +020017 s.HstSuite.SetupSuite()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010018 s.loadNetworkTopology("2taps")
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010019 s.loadContainerTopology("nginxProxyAndServer")
20}
21
22func (s *NginxSuite) SetupTest() {
Filip Tehlar608d0062023-04-28 10:29:47 +020023 s.HstSuite.SetupTest()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010024
25 // Setup test conditions
Filip Tehlar608d0062023-04-28 10:29:47 +020026 var sessionConfig Stanza
27 sessionConfig.
Maros Ondrejickae7625d02023-02-28 16:55:01 +010028 newStanza("session").
29 append("enable").
30 append("use-app-socket-api").close()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010031
Filip Tehlar608d0062023-04-28 10:29:47 +020032 cpus := s.AllocateCpus()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010033 // ... for proxy
34 vppProxyContainer := s.getContainerByName(vppProxyContainerName)
Filip Tehlar608d0062023-04-28 10:29:47 +020035 proxyVpp, _ := vppProxyContainer.newVppInstance(cpus, sessionConfig)
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010036 proxyVpp.start()
37
38 clientInterface := s.netInterfaces[mirroringClientInterfaceName]
39 proxyVpp.createTap(clientInterface, 1)
40
41 serverInterface := s.netInterfaces[mirroringServerInterfaceName]
42 proxyVpp.createTap(serverInterface, 2)
43
44 nginxContainer := s.getTransientContainerByName(nginxProxyContainerName)
45 nginxContainer.create()
Maros Ondrejicka85396a52023-02-28 12:49:43 +010046
47 values := struct {
48 Proxy string
49 Server string
50 }{
Maros Ondrejickae7625d02023-02-28 16:55:01 +010051 Proxy: clientInterface.peer.ip4AddressString(),
52 Server: serverInterface.ip4AddressString(),
Maros Ondrejicka85396a52023-02-28 12:49:43 +010053 }
54 nginxContainer.createConfig(
55 "/nginx.conf",
56 "./resources/nginx/nginx_proxy_mirroring.conf",
57 values,
58 )
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010059 nginxContainer.start()
60
Florin Corase2415f72023-02-28 14:51:03 -080061 proxyVpp.waitForApp("nginx-", 5)
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010062}