blob: 2249ce24e2bafe522072167c225e2cf3eadbfa2f [file] [log] [blame]
Yi Tseng0cb9b562021-09-22 17:13:58 -07001# SPDX-FileCopyrightText: Copyright 2021-present Open Networking Foundation.
2# SPDX-License-Identifier: GPL-2.0-or-later
3
Yi Tsengdda7e322021-09-20 14:21:20 -07004import os
Yi Tseng0cb9b562021-09-22 17:13:58 -07005from tests.dependencies.Network import Network
Jon Halldd05bbc2022-01-27 12:14:50 -08006from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
7 Testcaselib as run
Yi Tseng0cb9b562021-09-22 17:13:58 -07008
9class IntTest:
10
11 def __init__(self, scapy=False):
12 self.hosts = ["h1", "h2", "h3"]
13 self.scapy = scapy
14
15 def setUpTest(self, main):
16 main.Network = Network()
17 main.Network.connectToNet()
Yi Tsengdda7e322021-09-20 14:21:20 -070018 main.configPath = os.path.join(os.path.dirname(main.testFile), "dependencies")
Yi Tseng0cb9b562021-09-22 17:13:58 -070019
20 for host in self.hosts:
21 main.Network.createHostComponent(host)
22 if self.scapy:
23 hostHandle = getattr(main, host)
24 hostHandle.sudoRequired = True
25 hostHandle.startScapy()
26
27 def cleanUp(self, main):
Jon Halldd05bbc2022-01-27 12:14:50 -080028 run.saveOnosDiagsIfFailure(main)
Yi Tseng0cb9b562021-09-22 17:13:58 -070029 for host in self.hosts:
30 if self.scapy:
31 hostHandle = getattr(main, host)
32 hostHandle.stopScapy()
33 main.Network.removeHostComponent(host)
34 main.Network.disconnectFromNet()