Adding assert checks to Logical Device test recently added to
Olt/Onu Discovery Test Case
Add calico-node container specifier to log request for calico-node
similar to what was done to onos pod
Change-Id: I251ba94704bb7e1c9028f8d4df916db0ef2934f1
diff --git a/tests/atests/common/discovery.py b/tests/atests/common/discovery.py
index e125dcf..fb57a22 100755
--- a/tests/atests/common/discovery.py
+++ b/tests/atests/common/discovery.py
@@ -20,6 +20,7 @@
import testCaseUtils
import logging
+import os
class Discovery(object):
@@ -60,9 +61,35 @@
testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'),
'voltha_logical_device.log', 'logical_device ' + self.__logicalDeviceId,
'voltha_logical_device_ports.log', 'ports', 'voltha_logical_device_flows.log', 'flows')
+ assert os.path.exists(testCaseUtils.get_dir(self, 'log') + '/voltha_logical_device.log') and \
+ (os.path.getsize(testCaseUtils.get_dir(self, 'log') + '/voltha_logical_device.log') is 0), \
+ 'voltha_logical_device.log is not 0 length'
testCaseUtils.print_log_file(self, 'voltha_logical_device_ports.log')
testCaseUtils.print_log_file(self, 'voltha_logical_device_flows.log')
+ def logical_device_ports_should_exist(self):
+ statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltDeviceId, 'voltha_logical_device_ports.log')
+ assert statusLines, 'No Olt device listed under logical device ports'
+ self.__fields = testCaseUtils.parse_fields(statusLines)
+ portType = self.__fields[1].strip()
+ assert portType == 'nni', 'Port type for %s does not match expected nni' % self.__oltDeviceId
+ for onuDeviceId in self.__onuDeviceIds:
+ statusLines = testCaseUtils.get_fields_from_grep_command(self, onuDeviceId, 'voltha_logical_device_ports.log')
+ assert statusLines, 'No Onu device %s listed under logical device ports' % onuDeviceId
+ lines = statusLines.splitlines()
+ for line in lines:
+ self.__fields = testCaseUtils.parse_fields(line)
+ portType = self.__fields[1].strip()
+ assert portType == 'uni-128', 'Port type for %s does not match expected uni-128' % onuDeviceId
+
+ def logical_device_should_have_at_least_one_flow(self):
+ statusLines = testCaseUtils.get_fields_from_grep_command(self, 'Flows', 'voltha_logical_device_flows.log')
+ assert statusLines, 'No Logical device flows listed for logical device'
+ before, flows, numFlows = statusLines.partition('Flows')
+ plainNumber = numFlows.strip().strip('():')
+ if plainNumber.isdigit():
+ assert int(plainNumber) > 0, 'Zero number of flows for logical device'
+
def olt_discovery(self):
logging.info('Olt Discovery')
statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_after_enable.log')
@@ -165,6 +192,8 @@
discovery.olt_discovery()
discovery.onu_discovery()
discovery.logical_device()
+ discovery.logical_device_ports_should_exist()
+ discovery.logical_device_should_have_at_least_one_flow()
discovery.olt_ports_should_be_enabled_and_active()
discovery.onu_ports_should_be_enabled_and_active()
discovery.olt_should_have_at_least_one_flow()