def onu_discovery(self): logging.info('Onu Discovery') statusLines = testCaseUtils.get_fields_from_grep_command( self, self.__onuType, 'voltha_devices_after_enable.log') assert statusLines, 'No Onu listed under devices' lines = statusLines.splitlines() assert len( lines ) == self.__onuCount, 'Onu count mismatch found: %s, should be: %s' % ( len(lines), self.__onuCount) for line in lines: self.__fields = testCaseUtils.parse_fields(line, '|') onuDeviceId = self.__fields[1].strip() self.__onuDeviceIds.append(onuDeviceId) testCaseUtils.send_command_to_voltha_cli( testCaseUtils.get_dir(self, 'log'), 'voltha_onu_device_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log', 'device ' + onuDeviceId, 'voltha_onu_ports_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log', 'ports', 'voltha_onu_flows_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log', 'flows') testCaseUtils.print_log_file( self, 'voltha_onu_ports_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log') testCaseUtils.print_log_file( self, 'voltha_onu_flows_' + str(self.__onuDeviceIds.index(onuDeviceId)) + '.log')
def should_have_dhcp_assigned_ip(self): process_output = open( '%s/%s' % (testCaseUtils.get_dir( self, 'log'), self.CHECK_ASSIGNED_IP_FILENAME), 'w') ifConfigCheck1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'bash', '-c', 'ifconfig' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) ifConfigCheck2 = subprocess.Popen(['grep', '-e', 'eth0', '-A1'], stdin=ifConfigCheck1.stdout, stdout=process_output, stderr=process_output) ifConfigCheck1.wait() ifConfigCheck1.stdout.close() ifConfigCheck2.wait() process_output.close() testCaseUtils.print_log_file(self, self.CHECK_ASSIGNED_IP_FILENAME) statusLines = testCaseUtils.get_fields_from_grep_command( self, 'inet', self.CHECK_ASSIGNED_IP_FILENAME) assert statusLines, 'DHCP IP addr not assigned'
def olt_discovery(self): logging.info('Olt Discovery') statusLines = testCaseUtils.get_fields_from_grep_command( self, self.__oltType, 'voltha_devices_after_enable.log') assert statusLines, 'No Olt listed under devices' self.__fields = testCaseUtils.parse_fields(statusLines, '|') self.__oltDeviceId = self.__fields[1].strip() testCaseUtils.send_command_to_voltha_cli( testCaseUtils.get_dir(self, 'log'), 'voltha_olt_device.log', 'device ' + self.__oltDeviceId, 'voltha_olt_ports.log', 'ports', 'voltha_olt_flows.log', 'flows') testCaseUtils.print_log_file(self, 'voltha_olt_ports.log') testCaseUtils.print_log_file(self, 'voltha_olt_flows.log')
def assign_dhcp_ip_addr_to_rg(self): logging.info('Assigning IP addr on RG using DHCP') process_output = open( '%s/%s' % (testCaseUtils.get_dir(self, 'log'), self.ASSIGN_DHCP_IP_FILENAME), 'w') dhcpAssignIp1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-it', '-n', 'voltha', self.__rgName, '--', 'dhclient', '-v', 'eth0' ], stdout=process_output, stderr=process_output) dhcpAssignIp1.wait() process_output.close() testCaseUtils.print_log_file(self, self.ASSIGN_DHCP_IP_FILENAME) procPidDhclient1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'ps', '-ef' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidDhclient2 = subprocess.Popen(['grep', '-e', 'dhclient'], stdin=procPidDhclient1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidDhclient3 = subprocess.Popen(['awk', "{print $2}"], stdin=procPidDhclient2.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidDhclient1.stdout.close() procPidDhclient2.stdout.close() out, err = procPidDhclient3.communicate() dhclientPid = out.strip() if dhclientPid: procKillDhclient = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'kill', dhclientPid ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = procKillDhclient.communicate() assert not err, 'Killing dhclient returned %s' % err
def execute_ping_test(self): logging.info('Ping 1.2.3.4 IP Test') process_output = open( '%s/%s' % (testCaseUtils.get_dir(self, 'log'), self.PING_TEST_FILENAME), 'w') pingTest = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-it', '-n', 'voltha', self.__rgName, '--', '/bin/ping', '-I', 'eth0', '1.2.3.4' ], stdout=process_output, stderr=process_output) self.execute_tcpdump() self.kill_ping_test() pingTest.wait() process_output.close() testCaseUtils.print_log_file(self, self.PING_TEST_FILENAME) testCaseUtils.print_log_file(self, self.TCPDUMP_FILENAME) print
def query_for_default_ip_on_rg(self): logging.info('De-assigning default IP on RG') process_output = open( '%s/%s' % (testCaseUtils.get_dir(self, 'log'), self.CHECK_IP_FILENAME), 'w') ifconfigCheck1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'bash', '-c', 'ifconfig' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) ifconfigCheck2 = subprocess.Popen(['grep', '-e', 'eth0', '-A1'], stdin=ifconfigCheck1.stdout, stdout=process_output, stderr=process_output) ifconfigCheck1.wait() ifconfigCheck1.stdout.close() ifconfigCheck2.wait() process_output.close() testCaseUtils.print_log_file(self, self.CHECK_IP_FILENAME)
def logical_device(self): logging.info('Logical Device Info') testCaseUtils.send_command_to_voltha_cli( testCaseUtils.get_dir(self, 'log'), 'voltha_logical_devices.log', 'logical_devices') testCaseUtils.print_log_file(self, 'voltha_logical_devices.log') statusLines = testCaseUtils.get_fields_from_grep_command( self, '-i olt', 'voltha_logical_devices.log') assert statusLines, 'No Logical Device listed under logical devices' self.__fields = testCaseUtils.parse_fields(statusLines, '|') self.__logicalDeviceId = self.__fields[1].strip() 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 query_devices_before_enabling(self): testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'), 'voltha_devices_before_enable.log', 'devices') testCaseUtils.print_log_file(self, 'voltha_devices_before_enable.log') time.sleep(5)
def execute_authentication_on_rg(self): logging.info('Running Radius Authentication from RG') process_output = open( '%s/%s' % (testCaseUtils.get_dir(self, 'log'), self.AUTHENTICATE_FILENAME), 'w') proc1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'bash', '-c', '/sbin/wpa_supplicant -Dwired -ieth0 -c /etc/wpa_supplicant/wpa_supplicant.conf' ], stdout=process_output, stderr=process_output) time.sleep(15) logging.debug('return value from supplicant subprocess = %s' % proc1.returncode) procPidSupplicant1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'ps', '-ef' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidSupplicant2 = subprocess.Popen( ['grep', '-e', '/sbin/wpa_supplicant'], stdin=procPidSupplicant1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidSupplicant3 = subprocess.Popen(['awk', "{print $2}"], stdin=procPidSupplicant2.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidSupplicant1.stdout.close() procPidSupplicant2.stdout.close() out, err = procPidSupplicant3.communicate() supplicantPid = out.strip() procKillSupplicant1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'kill', supplicantPid ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = procKillSupplicant1.communicate() assert not err, 'Killing Supplicant returned %s' % err procPidBash1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'ps', '-ef' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidBash2 = subprocess.Popen(['grep', '-e', '/bin/bash'], stdin=procPidBash1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidBash3 = subprocess.Popen(['awk', "{print $2}"], stdin=procPidBash2.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) procPidBash1.stdout.close() procPidBash2.stdout.close() out, err = procPidBash3.communicate() bashPid = out.strip() procKillBash1 = subprocess.Popen([ '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName, '--', 'kill', '-9', bashPid ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = procKillBash1.communicate() assert not err, 'Killing Bash returned %s' % err process_output.close() testCaseUtils.print_log_file(self, self.AUTHENTICATE_FILENAME)