multiple validations in one test ok, client.pcap path correction, added max_value and exact_value validation of number of flows
This commit is contained in:
parent
0a47b540f3
commit
47b1110f3f
@ -65,7 +65,7 @@ for test_name in [name for name in os.listdir(tests_dir) if os.path.isdir(os.pat
|
|||||||
name = k.title().replace("_","")+"Checker"
|
name = k.title().replace("_","")+"Checker"
|
||||||
klass= globals()[name]
|
klass= globals()[name]
|
||||||
# instantiate checker with validations and test_name
|
# instantiate checker with validations and test_name
|
||||||
checker = klass(validations, test_name)
|
checker = klass(validations, test_name, destDir)
|
||||||
if checker.check():
|
if checker.check():
|
||||||
print checker.logs
|
print checker.logs
|
||||||
else:
|
else:
|
||||||
|
@ -21,6 +21,14 @@ class Validation:
|
|||||||
class MinValueValidation(Validation):
|
class MinValueValidation(Validation):
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
return self.compared<=value
|
return self.compared<=value
|
||||||
|
# checks a value passed is greater or equal (generic)
|
||||||
|
class MaxValueValidation(Validation):
|
||||||
|
def validate(self, value):
|
||||||
|
return self.compared>=value
|
||||||
|
# checks a value passed is greater or equal (generic)
|
||||||
|
class ExactValueValidation(Validation):
|
||||||
|
def validate(self, value):
|
||||||
|
return self.compared==value
|
||||||
|
|
||||||
# individual flow validation (specific)
|
# individual flow validation (specific)
|
||||||
# gets flow_spec = (index, flows) where index is the index of the flow to validate, and flows is the array of flows
|
# gets flow_spec = (index, flows) where index is the index of the flow to validate, and flows is the array of flows
|
||||||
@ -45,14 +53,15 @@ class TcptraceTest:
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
is_ok = True
|
is_ok = True
|
||||||
self.logs = ""
|
self.logs = ""
|
||||||
|
print self.yml
|
||||||
for val in self.yml:
|
for val in self.yml:
|
||||||
|
print val["name"]
|
||||||
tested_value = self.get_tested_value(val)
|
tested_value = self.get_tested_value(val)
|
||||||
klass_name=val["name"].title().replace("_","")+"Validation"
|
klass_name=val["name"].title().replace("_","")+"Validation"
|
||||||
tester_klass=globals()[klass_name]
|
tester_klass=globals()[klass_name]
|
||||||
tester = tester_klass(val)
|
tester = tester_klass(val)
|
||||||
if tester.validate(tested_value):
|
if tester.validate(tested_value):
|
||||||
self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" OK\n"
|
self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" OK\n"
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" FAILS\n"
|
self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" FAILS\n"
|
||||||
is_ok = False
|
is_ok = False
|
||||||
@ -75,9 +84,9 @@ class FlowsTest(TcptraceTest):
|
|||||||
|
|
||||||
# Runs tests based on tcptrace
|
# Runs tests based on tcptrace
|
||||||
class TcptraceChecker:
|
class TcptraceChecker:
|
||||||
def __init__(self, yml, test_id):
|
def __init__(self, yml, test_id, destDir):
|
||||||
self.yml = yml["tcptrace"]
|
self.yml = yml["tcptrace"]
|
||||||
self.trace = TcptraceData("/tmp/dest/client.pcap")
|
self.trace = TcptraceData(destDir+"/client.pcap")
|
||||||
self.test_id = test_id
|
self.test_id = test_id
|
||||||
def check(self):
|
def check(self):
|
||||||
is_ok = True
|
is_ok = True
|
||||||
|
@ -3,8 +3,12 @@ tcptrace:
|
|||||||
validations:
|
validations:
|
||||||
- name: "min_value"
|
- name: "min_value"
|
||||||
target: 2
|
target: 2
|
||||||
|
- name: "max_value"
|
||||||
|
target: 4
|
||||||
|
- name: "exact_value"
|
||||||
|
target: 4
|
||||||
- test: "flows"
|
- test: "flows"
|
||||||
validations:
|
validations:
|
||||||
- name: "min_delay"
|
- name: "min_delay"
|
||||||
index: 1
|
index: 1
|
||||||
target: 29000
|
target: 2000
|
||||||
|
Loading…
Reference in New Issue
Block a user