Enable python3 fort the test suite

Enable the suite to be used with python3 and added  enough documentation
to README that are required for this support.

Note: only version 3.5.2 tested

Change-Id: I327757e51b8c45bb82f425f7753aef761d0b86a6
Signed-off-by: Jose Perez Carranza <jose.perez.carranza@intel.com>
This commit is contained in:
Jose Perez Carranza 2019-09-29 09:57:35 -05:00
parent e4cdc8cbb6
commit 66734b5877
8 changed files with 25 additions and 22 deletions

View File

@ -157,7 +157,7 @@ def string_to_dict(string_table):
# in unicode format, so we need the following
# 1. converting string_table variable from unicode to ascii code
# 2. split in a list with line breaks
line_breaks_list = string_table['stdout'].encode('utf-8').split('\n')
line_breaks_list = string_table['stdout'].split('\n')
robot_dictionary = {}
@ -339,7 +339,7 @@ def grub_checker(iso, mode, grub_option, grub_cmd):
regex = '-e "label [0-9]" -e "label [A-Z][0-9]" -e append'
grub_extracted_lines = bash.run_command('grep {} {}'.format(
regex, grub))
grub_option_list = grub_extracted_lines[1].split('\n')
grub_option_list = grub_extracted_lines[1].decode('utf-8').split('\n')
key_dict = []
values_dict = []

View File

@ -138,7 +138,7 @@ class Installer(object):
try:
for stdout in self.child:
cmd_stdout.append(stdout.strip())
cmd_stdout.append(stdout.strip().decode('utf-8'))
except pexpect.exceptions.TIMEOUT:
LOG.info('custom timeout reached')

View File

@ -142,7 +142,7 @@ class PxeServer(object):
for service in services:
active_service = bash('sudo systemctl is-active {}'
.format(service))
if 'active' in active_service.stdout:
if 'active'.encode('utf-8') in active_service.stdout:
LOG.info('%s service is active', service)
continue
else:
@ -246,9 +246,12 @@ class Node(object):
LOG.info('Booting %s To PXE', self.name)
LOG.info('Node %s : Setting PXE as first boot option', self.name)
set_pxe = bash('ipmitool -I lanplus -H %s -U %s -P %s '
'chassis bootdev pxe', self.bmc_ip, self.bmc_user,
self.bmc_pswd)
set_pxe = bash('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} '
'chassis bootdev pxe'.format(
node_bmc_ip=self.bmc_ip,
node_bmc_user=self.bmc_user,
node_bmc_pswd=self.bmc_pswd))
if set_pxe.stderr:
LOG.info(set_pxe.stderr)

View File

@ -25,8 +25,7 @@ be ready soon.
Suite is based on Robot Framework and Python, please follow below instructions
to properly use the suite.
***NOTE***: Currently the suite is designed to run on Pyhton 2.7 environment,
migration to Python 3.5 is undergoing and will be ready soon.
Suite should be executed with Python3 (tested with 3.5.2)
__ https://docs.starlingx.io/deploy_install_guides/index.html
@ -168,6 +167,7 @@ Make sure you have python **virtualenv** package installed in your host machine.
.. code:: bash
$ sudo apt install python-pip
$ sudo apt-get install python3-dev
$ sudo pip install virtualenv
You can manage your virtual environments for the two options explained below:
@ -227,7 +227,7 @@ you can follow below steps:
.. code:: bash
$ virtualenv my-venv
$ virtualenv -p python3 my-venv
$ source my-venv/bin/activate
Install the project requirements on virtual environment.

View File

@ -27,7 +27,7 @@ def delete_network_interfaces():
# becoming in root
elevate(graphical=False)
ifdata = Ifcfg(subprocess.check_output(['ifconfig', '-a']))
ifdata = Ifcfg(subprocess.check_output(['ifconfig', '-a']).decode('utf-8'))
# Destroy NAT network if exist
try:
@ -75,7 +75,7 @@ def configure_network_interfaces():
for net in networks:
eval_cmd = bash('sudo ifconfig {} up'.format(net))
if 'ERROR' in eval_cmd.stderr:
if 'ERROR'.encode('utf-8') in eval_cmd.stderr:
LOG.error(eval_cmd.stderr)
raise EnvironmentError(eval_cmd.stderr)
@ -84,7 +84,7 @@ def configure_network_interfaces():
'MASQUERADE')
eval_cmd = bash(iptables)
if 'ERROR' in eval_cmd.stderr:
if 'ERROR'.encode('utf-8') in eval_cmd.stderr:
LOG.error(eval_cmd.stderr)
raise EnvironmentError(eval_cmd.stderr)

View File

@ -117,21 +117,21 @@ def clean_qemu_environment():
for vm in vms:
# check if the current image is running to shutting down
cmd = ebash('sudo virsh domstate {}'.format(vm))
stdout = cmd.stdout.strip()
stderr = cmd.stderr.strip()
cmd = ebash('sudo virsh domstate {}'.format(vm.decode('utf-8')))
stdout = cmd.stdout.strip().decode('utf-8')
stderr = cmd.stderr.strip().decode('utf-8')
if stdout == 'running' and 'failed to get domain' not in stderr:
# the vm is running
ebash('sudo virsh destroy {}'.format(vm))
ebash('sudo virsh destroy {}'.format(vm.decode('utf-8')))
# removing controller/compute from Virtual Machine Manager
ebash(
'sudo virsh undefine {} --remove-all-storage --snapshots-metadata'
.format(vm))
.format(vm.decode('utf-8')))
for partition in partitions:
ebash('sudo rm {}/{}'.format(images_path, partition))
ebash('sudo rm {}/{}'.format(images_path, partition.decode('utf-8')))
def qemu_configuration_files():

View File

@ -1,6 +1,5 @@
watchdog
robotframework==3.1.1
robotframework-debuglibrary
robotframework-seleniumlibrary
robotframework-sshlibrary
pexpect
@ -9,6 +8,6 @@ netifaces
bash
elevate
ifparser
pynetlinux
git+https://github.com/rlisagor/pynetlinux.git@master#egg=pynetlinux
kmodpy
psutil

View File

@ -3,7 +3,8 @@ hacking
flake8-import-order
mock
coverage
pylint
pylint==2.3.0
pep8-naming
ipdb
ipython
mccabe==0.5.3