summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/suite_veth_test.go
diff options
context:
space:
mode:
authorMaros Ondrejicka <maros.ondrejicka@pantheon.tech>2023-01-26 10:07:29 +0100
committerFlorin Coras <florin.coras@gmail.com>2023-02-09 17:02:43 +0000
commitffa3f60290499bdacc37a97c49f2e794b5e1f18c (patch)
treec23820e0d91d2a1a0eef2596b0de60c06f1ea303 /extras/hs-test/suite_veth_test.go
parent7a6532bb9f3b9c429f92d11a6ccbf55638906d0a (diff)
hs-test: configure VPP from test context
Instead of configuring VPP instances running inside of a container, now the configuration is going to be done from within the test context by using binary API and shared volume that exposes api socket. This converts just some of the test cases, rest is to follow. Type: test Signed-off-by: Maros Ondrejicka <maros.ondrejicka@pantheon.tech> Change-Id: I87e4ab15de488f0eebb01ff514596265fc2a787f
Diffstat (limited to 'extras/hs-test/suite_veth_test.go')
-rw-r--r--extras/hs-test/suite_veth_test.go84
1 files changed, 83 insertions, 1 deletions
diff --git a/extras/hs-test/suite_veth_test.go b/extras/hs-test/suite_veth_test.go
index 5276072eed6..81a21a2ce5f 100644
--- a/extras/hs-test/suite_veth_test.go
+++ b/extras/hs-test/suite_veth_test.go
@@ -4,12 +4,94 @@ import (
"time"
)
+const (
+ // These correspond to names used in yaml config
+ serverInterfaceName = "vppsrv"
+ clientInterfaceName = "vppcln"
+)
+
type VethsSuite struct {
HstSuite
}
+var ConvertedTests = map[string]any{
+ "TestVeths/TestEchoBuiltin": "",
+ "TestVeths/TestHttpCli": "",
+ "TestVeths/TestVclEchoTcp": "",
+ "TestVeths/TestVclRetryAttach": "",
+}
+
func (s *VethsSuite) SetupSuite() {
time.Sleep(1 * time.Second)
- s.teardownSuite = setupSuite(&s.Suite, "2peerVeth")
+
+ s.configureNetworkTopology("2peerVeth")
+
s.loadContainerTopology("2peerVeth")
}
+
+func (s *VethsSuite) SetupTest() {
+ s.SetupVolumes()
+ s.SetupContainers()
+
+ // TODO remove this after all tests are converted to configuration from test suite
+ if _, ok := ConvertedTests[s.T().Name()]; !ok {
+ return
+ }
+
+ // Setup test conditions
+
+ var startupConfig Stanza
+ startupConfig.
+ NewStanza("session").
+ Append("enable").
+ Append("use-app-socket-api").Close()
+
+ // ... For server
+ serverContainer := s.getContainerByName("server-vpp")
+
+ serverVpp, _ := serverContainer.newVppInstance(startupConfig)
+ s.assertNotNil(serverVpp)
+
+ s.setupServerVpp()
+
+ // ... For client
+ clientContainer := s.getContainerByName("client-vpp")
+
+ clientVpp, _ := clientContainer.newVppInstance(startupConfig)
+ s.assertNotNil(clientVpp)
+
+ s.setupClientVpp()
+}
+
+func (s *VethsSuite) setupServerVpp() {
+ serverVpp := s.getContainerByName("server-vpp").vppInstance
+
+ err := serverVpp.start()
+ s.assertNil(err)
+
+ serverVeth := s.veths["vppsrv"]
+ idx, err := serverVpp.createAfPacket(serverVeth)
+ s.assertNil(err)
+ s.assertNotEqual(0, idx)
+
+ namespaceSecret := "1"
+ err = serverVpp.addAppNamespace(1, idx, namespaceSecret)
+ s.assertNil(err)
+
+}
+
+func (s *VethsSuite) setupClientVpp() {
+ clientVpp := s.getContainerByName("client-vpp").vppInstance
+
+ err := clientVpp.start()
+ s.assertNil(err)
+
+ clientVeth := s.veths["vppcln"]
+ idx, err := clientVpp.createAfPacket(clientVeth)
+ s.assertNil(err)
+ s.assertNotEqual(0, idx)
+
+ clientNamespaceSecret := "2"
+ err = clientVpp.addAppNamespace(2, idx, clientNamespaceSecret)
+ s.assertNil(err)
+}