added number of packets ration validator
This commit is contained in:
parent
ac1e857f79
commit
20f1288603
@ -16,6 +16,9 @@ class Validation:
|
|||||||
return self.__class__.__name__
|
return self.__class__.__name__
|
||||||
def validate(self,value):
|
def validate(self,value):
|
||||||
raise Exception("Method not implemented")
|
raise Exception("Method not implemented")
|
||||||
|
def setup(self):
|
||||||
|
raise Exception("Method not implemented")
|
||||||
|
|
||||||
|
|
||||||
# checks a value passed is greater or equal (generic)
|
# checks a value passed is greater or equal (generic)
|
||||||
class MinValueValidation(Validation):
|
class MinValueValidation(Validation):
|
||||||
@ -56,13 +59,39 @@ class MinDelayBetweenValidation(Validation):
|
|||||||
self.value = val
|
self.value = val
|
||||||
return self.compared<=val
|
return self.compared<=val
|
||||||
|
|
||||||
class AttributeMinimumDifferenceValidation(Validation):
|
class AttributeValidation(Validation):
|
||||||
def validate(self, flow_spec):
|
def setup(self, flow_spec):
|
||||||
(yml ,trace) = flow_spec
|
(yml ,trace) = flow_spec
|
||||||
[index0, index1] = yml["index"]
|
[index0, index1] = yml["index"]
|
||||||
val = trace.get(index1, yml["attribute"]) - trace.get(index0, yml["attribute"])
|
self.val0 = trace.get(index0, yml["attribute"])
|
||||||
self.value = val
|
self.val1 = trace.get(index1, yml["attribute"])
|
||||||
return self.compared<=val
|
|
||||||
|
class AttributeMinimumDifferenceValidation(AttributeValidation):
|
||||||
|
def validate(self, flow_spec):
|
||||||
|
self.setup(flow_spec)
|
||||||
|
self.value = self.val1 - self.val0
|
||||||
|
return self.compared<=self.value
|
||||||
|
|
||||||
|
class AttributeMaximumDifferenceValidation(AttributeValidation):
|
||||||
|
def validate(self, flow_spec):
|
||||||
|
self.setup(flow_spec)
|
||||||
|
self.value = self.val1 - self.val0
|
||||||
|
return self.compared>=self.value
|
||||||
|
|
||||||
|
|
||||||
|
class AttributeMinimumRatioValidation(AttributeValidation):
|
||||||
|
def validate(self, flow_spec):
|
||||||
|
self.setup(flow_spec)
|
||||||
|
self.value = float(self.val1)/+float(self.val1)
|
||||||
|
return self.compared<=self.value
|
||||||
|
|
||||||
|
class AttributeMaximumRatioValidation(AttributeValidation):
|
||||||
|
def validate(self, flow_spec):
|
||||||
|
self.setup(flow_spec)
|
||||||
|
self.value = float(self.val1)/float(self.val0)
|
||||||
|
return self.compared>=self.value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Base class testing tcptrace results
|
# Base class testing tcptrace results
|
||||||
|
@ -20,6 +20,8 @@ tcptrace:
|
|||||||
desc: "Minimum 2 seconds delay between opening of first and second flow"
|
desc: "Minimum 2 seconds delay between opening of first and second flow"
|
||||||
# validates time between first packets of streams for which the index is passed.
|
# validates time between first packets of streams for which the index is passed.
|
||||||
# index is now a compound value, handled by the validate method of the class MinDelayBetweenValidation
|
# index is now a compound value, handled by the validate method of the class MinDelayBetweenValidation
|
||||||
|
# first index value is the base flow we compare to
|
||||||
|
# second index is the flow we want to validate
|
||||||
- name: "min_delay_between"
|
- name: "min_delay_between"
|
||||||
index:
|
index:
|
||||||
- 1
|
- 1
|
||||||
@ -28,8 +30,20 @@ tcptrace:
|
|||||||
desc: "Minimum 1 second delay between opening of second and third flow"
|
desc: "Minimum 1 second delay between opening of second and third flow"
|
||||||
- name: "attribute_minimum_difference"
|
- name: "attribute_minimum_difference"
|
||||||
attribute: "first_packet"
|
attribute: "first_packet"
|
||||||
|
# first index value is the base flow we compare to
|
||||||
|
# second index is the flow we want to validate
|
||||||
index:
|
index:
|
||||||
- 0
|
- 0
|
||||||
- 1
|
- 1
|
||||||
target: 2
|
target: 2
|
||||||
desc: "first packet delay 2nd flow"
|
desc: "first packet delay 2nd flow"
|
||||||
|
- name: "attribute_maximum_ratio"
|
||||||
|
attribute: "total_packets_a2b"
|
||||||
|
# first index value is the base flow we compare to
|
||||||
|
# second index is the flow we want to validate
|
||||||
|
index:
|
||||||
|
- 0
|
||||||
|
- 1
|
||||||
|
# 5%
|
||||||
|
target: 0.05
|
||||||
|
desc: "a->b packet ration flow 2 compard to flow1"
|
||||||
|
Loading…
Reference in New Issue
Block a user