summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/suite_nginx_test.go
blob: 94fd010814a18718c28c722dfe6fb2f75e30199f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main

const (
	// These correspond to names used in yaml config
	mirroringClientInterfaceName = "hstcln"
	mirroringServerInterfaceName = "hstsrv"
	vppProxyContainerName		 = "vpp-proxy"
	nginxProxyContainerName 	 = "nginx-proxy"
	nginxServerContainerName 	 = "nginx-server"
)

type NginxSuite struct {
	HstSuite
}

func (s *NginxSuite) SetupSuite() {
	s.HstSuite.SetupSuite()
	s.loadNetworkTopology("2taps")
	s.loadContainerTopology("nginxProxyAndServer")
}

func (s *NginxSuite) SetupTest() {
	s.HstSuite.SetupTest()

	// Setup test conditions
	var sessionConfig Stanza
	sessionConfig.
		newStanza("session").
		append("enable").
		append("use-app-socket-api").close()

	cpus := s.AllocateCpus()
	// ... for proxy
	vppProxyContainer := s.getContainerByName(vppProxyContainerName)
	proxyVpp, _ := vppProxyContainer.newVppInstance(cpus, sessionConfig)
	s.assertNil(proxyVpp.start())

	clientInterface := s.netInterfaces[mirroringClientInterfaceName]
	s.assertNil(proxyVpp.createTap(clientInterface, 1))

	serverInterface := s.netInterfaces[mirroringServerInterfaceName]
	s.assertNil(proxyVpp.createTap(serverInterface, 2))

	nginxContainer := s.getTransientContainerByName(nginxProxyContainerName)
	nginxContainer.create()

	values := struct {
		Proxy  string
		Server string
	}{
		Proxy:  clientInterface.peer.ip4AddressString(),
		Server: serverInterface.ip4AddressString(),
	}
	nginxContainer.createConfig(
		"/nginx.conf",
		"./resources/nginx/nginx_proxy_mirroring.conf",
		values,
	)
	s.assertNil(nginxContainer.start())

	proxyVpp.waitForApp("nginx-", 5)
}