Assaf Muller has posted comments on this change.
Change subject: Functional Tests [2/3]: Added ipwrapper.ruleExists+routeExists ......................................................................
Patch Set 1:
(5 comments)
.................................................... File lib/vdsm/ipwrapper.py Line 246: Line 247: Line 248: def _validate(validator, entry): Line 249: try: Line 250: validator.fromText(entry) fromText returns a class instance if successful. I view it as a constructor so I go with the Java/C#/C++ way of throwing exceptions in constructors to raise a red flag if something goes wrong. Line 251: except: Line 252: return False Line 253: else: Line 254: return True
.................................................... File tests/functional/networkTests.py Line 21: from testrunner import (VdsmTestCase as TestCaseBase, Line 22: expandPermutations, permutations) Line 23: from testValidation import RequireDummyMod, ValidateRunningAsRoot Line 24: Line 25: import dummyUtils Done Line 26: from dummyUtils import dummyIf Line 27: from utils import cleanupNet, restoreNetConfig, SUCCESS, VdsProxy Line 28: Line 29: from vdsm.ipwrapper import ruleAdd, ruleDel, routeAdd, routeDel, routeExists, \
Line 25: import dummyUtils Line 26: from dummyUtils import dummyIf Line 27: from utils import cleanupNet, restoreNetConfig, SUCCESS, VdsProxy Line 28: Line 29: from vdsm.ipwrapper import ruleAdd, ruleDel, routeAdd, routeDel, routeExists, \ Done Line 30: ruleExists, Route, Rule Line 31: Line 32: Line 33: NETWORK_NAME = 'test-network'
Line 410: @ValidateRunningAsRoot Line 411: def testRuleExists(self): Line 412: with dummyIf(1) as nics: Line 413: nic = nics[0] Line 414: dummyUtils.setIP(nic, IP_ADDRESS + '/' + IP_CIDR) Done Line 415: dummyUtils.setLinkUp(nic) Line 416: Line 417: rules = [Rule(source=IP_NETWORK_AND_CIDR, table=IP_TABLE), Line 418: Rule(destination=IP_NETWORK_AND_CIDR, table=IP_TABLE,
Line 419: srcDevice=nic)] Line 420: for rule in rules: Line 421: self.assertFalse(ruleExists(rule)) Line 422: ruleAdd(rule) Line 423: self.assertTrue(ruleExists(rule)) Done Line 424: ruleDel(rule) Line 425: self.assertFalse(ruleExists(rule)) Line 426: Line 427: @RequireDummyMod