class TestVPNAgent(base.BaseTestCase):
device_driver = NOOP_DEVICE
def setUp(self):
super(TestVPNAgent, self).setUp()
self.conf = cfg.CONF
self.conf.set_override('vpn_device_driver', [self.device_driver],'vpnagent')
self.agent = agent.VPNAgent('fake_host')
class TestVPNAgent2(functional_base.BaseSudoTestCase, test_vpn_agent.TestVPNAgent):
device_driver = STRONGSWAN_DEVICE
def setUp(self):
super(TestVPNAgent, self).setUp()
print self.agent
self.addCleanup里传的应该是函数指针, 要传参数写到后面
self.addCleanup(self.agent._router_removed, router_id=router_id)
也可,
class BaseIPsecDeviceDriver(base.BaseTestCase):
def setUp(self, driver=ipsec_driver.OpenSwanDriver,
ipsec_process='ipsec.OpenSwanProcess'):
super(BaseIPsecDeviceDriver, self).setUp()
class TestIPsecStrongswanDeviceDriver(BaseIPsecDeviceDriver,
IPsecDeviceHelper):
def setUp(self):
super(TestIPsecStrongswanDeviceDriver, self).setUp(
driver=strongswan_ipsec.StrongSwanDriver,
ipsec_process='strongswan_ipsec.StrongSwanProcess')