Commit 797ae722 authored by Fernanda Hernández's avatar Fernanda Hernández
Browse files

[DUMMY] test_image: add test-enable parameter in wdemo db

parent 85bc5cdd
Pipeline #114544 passed with stage
in 9 seconds
......@@ -22,6 +22,7 @@ TO_SCAN = ['git.vauxoo.com',
'github.com',
'gitlab.com',
'bitbucket.org']
PATH_COVERAGE = "/temporal/fer"
def pull_images(images):
......@@ -327,18 +328,24 @@ def start_instance(config):
"DB_HOST": config['postgres_container'],
"ODOO_CONFIG_FILE": "/home/odoo/.openerp_serverrc"
}
volume_name = "{path}".format(path=PATH_COVERAGE)
volume_binds = "/tmp:{path}".format(path=PATH_COVERAGE)
for env_var in ['COUNTRY', 'LANGUAGE']:
env.update({env_var: environ.get(env_var, "")})
links = {
config['postgres_container']: config['postgres_container']
}
host_config = _cli.create_host_config(links=links)
host_config = _cli.create_host_config(
links=links,
binds=[volume_binds],
)
_logger.info('Starting container %s', config['container_name'])
_logger.debug('Env vars %s', json.dumps(env, sort_keys=True, indent=4))
container = _cli.create_container(image=config['instance_image'],
name=config['container_name'],
environment=env,
host_config=host_config)
volumes=[volume_name],
host_config=host_config,)
_cli.start(container=container.get('Id'))
_logger.info(container)
......@@ -427,32 +434,66 @@ def install_module(config):
extra = ''
if config.get('language', False):
extra += ' --load-language={lang}'.format(lang=config.get('language'))
install_wdemo = (
"/home/odoo/instance/odoo/odoo-bin -d wdemo -i {mod}"
"{extra} --stop-after-init".format(mod=module, extra=extra)
)
install_wodemo = (
"/home/odoo/instance/odoo/odoo-bin -d wodemo -i {mod}"
"{extra} --stop-after-init --without-demo=all".format(mod=module, extra=extra)
# install_wdemo = (
# "/home/odoo/instance/odoo/odoo-bin -d wdemo -i {mod}"
# "{extra} --stop-after-init".format(mod=module, extra=extra)
# )
# install_wodemo = (
# "/home/odoo/instance/odoo/odoo-bin -d wodemo -i {mod}"
# "{extra} --stop-after-init --without-demo=all".format(mod=module, extra=extra)
# )
exec_cmd(config['container_name'], 'pip3 install coverage')
# _logger.info('result of which: ', which_cov.strip())
install_wdemo_wunittest = (
"coverage run /home/odoo/instance/odoo/odoo-bin -d wdemo -u {mod} --test-enable --workers 0 "
"{extra} --stop-after-init ".format(mod=module, extra=extra)
)
# Create a .coveragerc
fcoveragerc = path.join(PATH_COVERAGE, '.coveragerc')
_logger.info('Creating .coveragerc file in: {fcove}'.format(fcove=fcoveragerc))
# if not path.exists(path.dirname(fcoveragerc)):
# makedirs(path.dirname(fcoveragerc))
if path.exists(path.dirname(fcoveragerc)):
_logger.info('si existe la ruta: %s', path.dirname(fcoveragerc))
with open(fcoveragerc, "a") as f_coveragerc:
f_coveragerc.write(get_coverage_content(config.get('main_app')))
if path.exists(fcoveragerc):
_logger.info('si existe el archivo: %s', fcoveragerc)
chmod_coverage = 'chown odoo {path_cov}'.format(path_cov=PATH_COVERAGE)
ouput_chomd = exec_cmd(config['container_name'], chmod_coverage)
_logger.info('chown: %s', ouput_chomd.strip())
_logger.info('Verifying supervisorctl')
is_running(config)
_logger.info('Stopping odoo')
exec_cmd(config['container_name'], 'supervisorctl stop odoo')
_logger.info('\nInstalling %s with demo', module)
_logger.debug('Command : %s', install_wdemo)
wdemo_res = exec_cmd(config['container_name'], install_wdemo, 'odoo', stream=True)
wdemo_log = resume_log(wdemo_res, config['allow_deprecated'])
_logger.info('\nInstalling %s without demo', module)
_logger.debug('Command : %s', install_wodemo)
wodemo_res = exec_cmd(config['container_name'], install_wodemo, 'odoo', stream=True)
wodemo_log = resume_log(wodemo_res, config['allow_deprecated'])
show_log(wdemo_log[1], 'Installation with demo', config)
show_log(wodemo_log[1], 'Installation without demo', config)
_logger.debug('Installation wdemo res: %s', wdemo_log[0])
_logger.debug('Installation wodemo res: %s', wodemo_log[0])
if not wdemo_log[0] or not wodemo_log[0]:
return False
# _logger.info('\nInstalling %s with demo', module)
# _logger.debug('Command : %s', install_wdemo)
# wdemo_res = exec_cmd(config['container_name'], install_wdemo, 'odoo', stream=True)
# wdemo_log = resume_log(wdemo_res, config['allow_deprecated'])
# _logger.info('\nInstalling %s without demo', module)
# _logger.debug('Command : %s', install_wodemo)
# wodemo_res = exec_cmd(config['container_name'], install_wodemo, 'odoo', stream=True)
# wodemo_log = resume_log(wodemo_res, config['allow_deprecated'])
_logger.info('\nInstalling %s with demo and run tests', module)
_logger.debug('Command : %s', install_wdemo_wunittest)
wodemo_wtests_res = exec_cmd(config['container_name'], install_wdemo_wunittest, 'odoo', stream=True)
wodemo_wtests_log = resume_log(wodemo_wtests_res, config['allow_deprecated'])
# show_log(wdemo_log[1], 'Installation with demo', config)
# show_log(wodemo_log[1], 'Installation without demo', config)
show_log(wodemo_wtests_log[1], 'Installation with demo and tests', config)
# _logger.debug('Installation wdemo res: %s', wdemo_log[0])
# _logger.debug('Installation wodemo res: %s', wodemo_log[0])
_logger.debug('Installation wdemo and tests res: %s', wodemo_wtests_log[0])
# Save odoo log
odoo_log = config.get('stdout_log',
path.join('.', config.get('ci_commit_ref_slug'), 'odoo.log'))
if not path.exists(path.dirname(odoo_log)):
makedirs(path.dirname(odoo_log))
with open(odoo_log, "a") as fodoo_log:
for line in wodemo_wtests_res:
fodoo_log.write(line)
# if not wdemo_log[0] or not wodemo_log[0]:
# return False
return True
......@@ -531,6 +572,36 @@ def resume_log(log_lines, allow_deprecated=False):
break
return success, res
def get_coverage_content(config_main_app):
coveragerc_content = """
# Config file .coveragerc
[report]
include =
{main_app}/*
omit =
*/scenario/*
*/scenarios/*
*/test/*
*/tests/*
*_example/*
*__init__.py
*__openerp__.py
*__manifest__.py
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about null context checking
if context is None:
# Don't check obviously not implemented
raise NotImplementedError
# We don't really care what happens if fail
except ImportError:
""".format(main_app=config_main_app)
return coveragerc_content
def run_image_tests(config):
clean_containers(config)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment