blob: 8f40590d1f2f16200e4b473c37b0c03d9a243309 [file] [log] [blame]
Maros Ondrejickac2f76f42023-02-27 13:22:45 +01001package main
2
adrianvillin28bd8f02024-02-13 06:00:02 -05003// These correspond to names used in yaml config
Maros Ondrejickac2f76f42023-02-27 13:22:45 +01004const (
adrianvillinfbf5f2b2024-02-13 03:26:25 -05005 vppProxyContainerName = "vpp-proxy"
6 nginxProxyContainerName = "nginx-proxy"
7 nginxServerContainerName = "nginx-server"
adrianvillin28bd8f02024-02-13 06:00:02 -05008 mirroringClientInterfaceName = "hstcln"
9 mirroringServerInterfaceName = "hstsrv"
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010010)
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)
Filip Tehlar56e17cf2024-01-11 17:17:33 +010036 s.assertNil(proxyVpp.start())
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010037
adrianvillin28bd8f02024-02-13 06:00:02 -050038 clientInterface := s.getInterfaceByName(mirroringClientInterfaceName)
Filip Tehlar56e17cf2024-01-11 17:17:33 +010039 s.assertNil(proxyVpp.createTap(clientInterface, 1))
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010040
adrianvillin28bd8f02024-02-13 06:00:02 -050041 serverInterface := s.getInterfaceByName(mirroringServerInterfaceName)
Filip Tehlar56e17cf2024-01-11 17:17:33 +010042 s.assertNil(proxyVpp.createTap(serverInterface, 2))
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010043
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 )
Filip Tehlar56e17cf2024-01-11 17:17:33 +010059 s.assertNil(nginxContainer.start())
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010060
Florin Corase2415f72023-02-28 14:51:03 -080061 proxyVpp.waitForApp("nginx-", 5)
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010062}