Beispiel #1
0
 def alter_freeradius_ip_in_onos_aaa_application_configuration(self):
     logging.info('Altering the Onos NetCfg AAA apps with Freeradius IP address')
     logging.debug('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
                   'http://*****:*****@%s/tests/atests/build/aaa_json'
                   % testCaseUtils.get_dir(self, 'voltha'))
     os.system('curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
               'http://*****:*****@%s/tests/atests/build/aaa_json'
               % testCaseUtils.get_dir(self, 'voltha'))
Beispiel #2
0
 def add_dhcp_server_configuration_data_in_onos(self):
     logging.info('Adding DHCP Configuration Data to Onos NetCfg')
     logging.debug(
         'curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
         'http://*****:*****@%s/tests/atests/build/dhcp_json'
         % testCaseUtils.get_dir(self, 'voltha'))
     os.system(
         'curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
         'http://*****:*****@%s/tests/atests/build/dhcp_json'
         % testCaseUtils.get_dir(self, 'voltha'))
Beispiel #3
0
 def collect_pod_logs(self):
     logging.info('Collect logs from all Pods')
     allRunningPods = get_all_running_pods()
     for nsName in allRunningPods:
         Namespace = nsName.get('NS')
         podName = nsName.get('Name')
         if 'onos' in podName:
             os.system('/usr/bin/kubectl logs -n %s -f %s onos > %s/%s.log 2>&1 &' %
                       (Namespace, podName, testCaseUtils.get_dir(self, 'log'), podName))
         elif 'calico-node' in podName:
             os.system('/usr/bin/kubectl logs -n %s -f %s calico-node > %s/%s.log 2>&1 &' %
                       (Namespace, podName, testCaseUtils.get_dir(self, 'log'), podName))
         else:
             os.system('/usr/bin/kubectl logs -n %s -f %s > %s/%s.log 2>&1 &' %
                       (Namespace, podName, testCaseUtils.get_dir(self, 'log'), podName))
Beispiel #4
0
 def preprovision_olt(self):
     logging.info('Do PROVISIONING')
     testCaseUtils.send_command_to_voltha_cli(
         testCaseUtils.get_dir(self, 'log'), 'voltha_preprovision_olt.log',
         'preprovision_olt -t %s -H %s:%s' %
         (self.__oltType, self.__oltIpAddress, self.__oltPort))
     time.sleep(5)
Beispiel #5
0
 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')
Beispiel #6
0
 def reset_kube_adm(self, simtype=DEFAULT_SIMTYPE):
     proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'clear', simtype],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     output = proc1.communicate()[0]
     print(output)
     proc1.stdout.close()
Beispiel #7
0
 def stop_all_pods(self, simtype=DEFAULT_SIMTYPE):
     proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'stop', simtype],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     output = proc1.communicate()[0]
     print(output)
     proc1.stdout.close()
Beispiel #8
0
    def de_assign_default_ip_on_rg(self):

        statusLines = testCaseUtils.get_fields_from_grep_command(
            self, 'inet', self.CHECK_IP_FILENAME)
        if statusLines:
            process_output = open(
                '%s/%s' % (testCaseUtils.get_dir(
                    self, 'log'), self.DE_ASSIGN_IP_FILENAME), 'w')
            os.system(
                '/usr/bin/kubectl exec -n voltha %s -- bash -c "ifconfig eth0 0.0.0.0"'
                % self.__rgName)
            ifconfigDeassign1 = subprocess.Popen([
                '/usr/bin/kubectl', 'exec', '-n', 'voltha', self.__rgName,
                '--', 'bash', '-c', 'ifconfig'
            ],
                                                 stdout=subprocess.PIPE,
                                                 stderr=subprocess.PIPE)

            ifconfigDeassign2 = subprocess.Popen(
                ['grep', '-e', 'eth0', '-A1'],
                stdin=ifconfigDeassign1.stdout,
                stdout=process_output,
                stderr=process_output)
            ifconfigDeassign1.wait()
            ifconfigDeassign1.stdout.close()
            ifconfigDeassign2.wait()

            process_output.close()

            statusLines = testCaseUtils.get_fields_from_grep_command(
                self, 'inet', self.DE_ASSIGN_IP_FILENAME)
            assert not statusLines, 'IP addr not de-assigned'

        else:
            logging.info('No default IP addr assigned to eth0')
Beispiel #9
0
    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'
Beispiel #10
0
 def deactivate_dhcp_server_in_onos(self):
     logging.info('Deactivating DHCP server on Onos')
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self, 'log'),
         'voltha_dhcp_server_deactivate.log', 'app deactivate dhcp')
     statusLines = testCaseUtils.get_fields_from_grep_command(
         self, 'Deactivated', 'voltha_dhcp_server_deactivate.log')
     assert statusLines, 'DHCP server failed to be Deactivated'
Beispiel #11
0
 def deactivate_aaa_app_in_onos(self):
     logging.info('Deactivating AAA Application on Onos')
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self, 'log'),
         'voltha_aaa_application_deactivate.log', 'app deactivate aaa')
     statusLines = testCaseUtils.get_fields_from_grep_command(
         self, 'Deactivated', 'voltha_aaa_application_deactivate.log')
     assert statusLines, 'AAA Application failed to be Deactivated'
Beispiel #12
0
 def alter_onos_net_cfg(self):
     logging.info('Altering the Onos NetCfg to suit Voltha\'s needs')
     logging.debug(
         'curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
         'http://*****:*****@%s/tests/atests/build/devices_json'
         % testCaseUtils.get_dir(self, 'voltha'))
     os.system(
         'curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
         'http://*****:*****@%s/tests/atests/build/devices_json'
         % testCaseUtils.get_dir(self, 'voltha'))
     logging.debug(
         'curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
         'http://*****:*****@%s/tests/atests/build/sadis_json'
         % testCaseUtils.get_dir(self, 'voltha'))
     os.system(
         'curl --user karaf:karaf -X POST -H "Content-Type: application/json" '
         'http://*****:*****@%s/tests/atests/build/sadis_json'
         % testCaseUtils.get_dir(self, 'voltha'))
Beispiel #13
0
 def should_have_all_onus_authenticated(self):
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self, 'log'), 'voltha_onu_auth.log',
         'aaa-users')
     statusLines = testCaseUtils.get_fields_from_grep_command(
         self, 'AUTHORIZED', 'voltha_onu_auth.log')
     lines = statusLines.splitlines()
     auth_count = len(lines)
     assert self.__onuCount == auth_count, 'There are only %s ONUS Authenticated' % auth_count
Beispiel #14
0
 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')
Beispiel #15
0
 def proceed(self):
     logging.info('Pre-provisioning hold')
     onuOnline = 0
     if self.__oltType == 'ponsim_olt':
         portType = 'PON_OLT'
         while onuOnline < self.__onuCount:
             testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'), 'voltha_olt_device.log', 'device ' +
                                                      self.__oltDeviceId, 'voltha_olt_ports.log', 'ports')
             statusLines = testCaseUtils.get_fields_from_grep_command(self, portType, 'voltha_olt_ports.log')
             lines = statusLines.splitlines()
             onuOnline = len(lines)
             time.sleep(5)
             logging.info('All ONUs now Online!')
     elif self.__oltType == 'openolt':
         while onuOnline < self.__onuCount:
             testCaseUtils.send_command_to_onos_cli(testCaseUtils.get_dir(self, 'log'),
                                                    'voltha_onu_auth.log', 'aaa-users')
             statusLines = testCaseUtils.get_fields_from_grep_command(self, 'AUTHORIZED', 'voltha_onu_auth.log')
             lines = statusLines.splitlines()
             onuOnline = len(lines)
             time.sleep(5)
         logging.info('All ONUs now AUTHORIZED')
Beispiel #16
0
 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')
Beispiel #17
0
    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
Beispiel #18
0
    def execute_tcpdump(self):
        logging.info('Execute tcpdump')
        process_output = open(
            '%s/%s' %
            (testCaseUtils.get_dir(self, 'log'), self.TCPDUMP_FILENAME), 'w')
        tcpdump = subprocess.Popen(
            ['sudo', '/usr/sbin/tcpdump', '-nei', 'nni0'],
            stdout=process_output,
            stderr=process_output)
        self.__tcpdumpPid = tcpdump.pid

        time.sleep(20)

        self.kill_tcpdump()
        tcpdump.wait()
        process_output.close()
Beispiel #19
0
 def should_have_ips_assigned_to_all_onus(self):
     logging.info('Verifying IP Address assignment on all ONUs')
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self, 'log'),
         '_voltha_onos_dhcpl2relay_allocations.log',
         'dhcpl2relay-allocations')
     statusLines = testCaseUtils.get_fields_from_grep_command(
         self, 'DHCPACK', '_voltha_onos_dhcpl2relay_allocations.log')
     assert statusLines, 'No DHCP addresses allocated'
     lines = statusLines.splitlines()
     assert len(
         lines
     ) == self.__onuCount, 'Allocated IPs does not match ONU count but result was %s' % len(
         lines)
     for line in lines:
         self.__fields = testCaseUtils.parse_fields(line, ',')
         allocIp = self.__fields[5].strip()
         allocated, delimiter, ipAddr = allocIp.partition('=')
         assert ipAddr != '0.0.0.0', 'Invalid IP Address Allocated'
Beispiel #20
0
 def should_now_have_two_dhcp_flows(self):
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self, 'log'), 'voltha_onos_flows.log',
         'flows -s')
     statusLines = testCaseUtils.get_fields_from_grep_command(
         self, 'IP_PROTO:17', 'voltha_onos_flows.log')
     assert statusLines, 'No DHCP Detection flows'
     lines = statusLines.splitlines()
     assert len(
         lines
     ) >= 2, 'Expected at least 2 DHCP Detection Flows but result was %s' % len(
         lines)
     for line in lines:
         self.__fields = testCaseUtils.parse_fields(line, ',')
         inPortStr = self.__fields[5].strip()
         selector, delimiter, inPort = inPortStr.partition('=[')
         assert (
             inPort == 'IN_PORT:2' or inPort == 'IN_PORT:128'
         ), 'DHCP detection flows not associated with expected ports'
Beispiel #21
0
    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
Beispiel #22
0
    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)
Beispiel #23
0
 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)
Beispiel #24
0
 def enable(self):
     logging.info('Enable %s OLT device' % self.__oltDeviceId)
     testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'),
                                              'voltha_enable.log', 'enable ' + self.__oltDeviceId)
Beispiel #25
0
 def read_sadis_entries_from_sadis_json(self):
     with open(
             '%s/tests/atests/build/sadis_json' %
             testCaseUtils.get_dir(self, 'voltha'), 'r') as sadis:
         self.__datastore = json.load(sadis)
Beispiel #26
0
    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)
Beispiel #27
0
 def add_subscriber_access(self):
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self,
                               'log'), 'voltha_add_subscriber_access.log',
         'volt-add-subscriber-access %s %s' %
         (self.__deviceId, self.__portNumber))
Beispiel #28
0
 def discover_authorized_users(self):
     testCaseUtils.send_command_to_onos_cli(
         testCaseUtils.get_dir(self, 'log'), 'voltha_onos_users.log',
         'aaa-users')