coucou
This commit is contained in:
parent
954d83e6b6
commit
a0eb99fd48
|
|
@ -1,5 +1,6 @@
|
|||
image: docker:18.09
|
||||
|
||||
# TODO, ne sert à rien.
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
|
|
@ -41,9 +42,6 @@ pytest:
|
|||
- echo $PYTHONPATH
|
||||
- poetry run pytest --version
|
||||
|
||||
# # Create a postgresql container
|
||||
# - docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --publish 9542:5432 --name db postgres:13
|
||||
|
||||
- poetry run pytest --cov odoo_openupgrade_wizard --verbose --verbose --exitfirst tests/cli_A_init_test.py tests/cli_B_01_get_code_test.py tests/cli_B_02_docker_build_test.py tests/cli_B_03_run_test.py tests/cli_B_05_execute_script_sql_test.py
|
||||
|
||||
# tests/cli_B_04_execute_script_python_test.py
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ sudo apt-get install python3.6 python3.6-distutils
|
|||
sudo apt-get install python3.7 python3.7-distutils
|
||||
sudo apt-get install python3.8 python3.8-distutils
|
||||
sudo apt-get install python3.9 python3.9-distutils
|
||||
sudo apt-get install python3.10 python3.10-distutils
|
||||
```
|
||||
|
||||
## Via Gitlab Runner locally
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ _LEGACY_OPENUPGRADELIB = (
|
|||
|
||||
```
|
||||
|
||||
py310 is not available, due to dependencies to ``odoorpc``
|
||||
that raise an error :
|
||||
* py310 is not available, due to dependencies to ``odoorpc`` that raise an error :
|
||||
``ERROR tests/cli_A_init_test.py - AttributeError: module 'collections' has no attribute 'MutableMapping'``
|
||||
|
||||
|
||||
|
|
@ -62,8 +61,6 @@ docker exec db psql --username=odoo --dbname=test_v12 -c "update res_partner set
|
|||
|
||||
- add a tools to analyze workload.
|
||||
|
||||
- execute ``pre-migration.sql`` files.
|
||||
|
||||
# TODO Nice To have
|
||||
|
||||
- Fix gitlabci-local. For the time being, it is not possible to debug
|
||||
|
|
@ -72,3 +69,5 @@ docker exec db psql --username=odoo --dbname=test_v12 -c "update res_partner set
|
|||
|
||||
- ``.absolute()`` has been added in test to try to fix some things,
|
||||
but maybe it's not necessary.
|
||||
|
||||
- Check if there are default values for containers, limiting ressources.
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@ from loguru import logger
|
|||
from odoo_openupgrade_wizard.cli_options import (
|
||||
database_option,
|
||||
get_migration_steps_from_options,
|
||||
step_option,
|
||||
)
|
||||
from odoo_openupgrade_wizard.configuration_version_dependant import (
|
||||
generate_analysis_files,
|
||||
generate_records,
|
||||
get_installable_odoo_modules,
|
||||
get_upgrade_analysis_module,
|
||||
)
|
||||
from odoo_openupgrade_wizard.tools_odoo import kill_odoo, run_odoo
|
||||
|
|
@ -14,26 +17,19 @@ from odoo_openupgrade_wizard.tools_odoo_instance import OdooInstance
|
|||
|
||||
|
||||
@click.command()
|
||||
@step_option
|
||||
@database_option
|
||||
@click.option(
|
||||
"--last-step",
|
||||
required=True,
|
||||
prompt=True,
|
||||
type=int,
|
||||
help="Last step in witch the analysis will be generated",
|
||||
)
|
||||
@click.option(
|
||||
"-m",
|
||||
"--modules",
|
||||
type=str,
|
||||
help="Coma-separated list of modules to analysis."
|
||||
" Let empty to analyse all the modules.",
|
||||
" Let empty to analyse all the Odoo modules.",
|
||||
)
|
||||
@database_option
|
||||
@click.pass_context
|
||||
def generate_module_analysis(ctx, last_step, database, modules):
|
||||
def generate_module_analysis(ctx, step, database, modules):
|
||||
|
||||
migration_steps = get_migration_steps_from_options(
|
||||
ctx, last_step - 1, last_step
|
||||
)
|
||||
migration_steps = get_migration_steps_from_options(ctx, step - 1, step)
|
||||
|
||||
initial_step = migration_steps[0].copy()
|
||||
final_step = migration_steps[1].copy()
|
||||
|
|
@ -54,7 +50,7 @@ def generate_module_analysis(ctx, last_step, database, modules):
|
|||
str(final_step["release"]).replace(".", ""),
|
||||
)
|
||||
|
||||
modules = (modules or "").split(",")
|
||||
modules = modules and modules.split(",") or []
|
||||
|
||||
# Force to be in openupgrade mode
|
||||
initial_step["action"] = final_step["action"] = "upgrade"
|
||||
|
|
@ -77,11 +73,15 @@ def generate_module_analysis(ctx, last_step, database, modules):
|
|||
database=initial_database,
|
||||
detached_container=True,
|
||||
)
|
||||
|
||||
# # INITIAL : install modules to analyse and generate records
|
||||
initial_instance = OdooInstance(ctx, initial_database)
|
||||
|
||||
# INITIAL : install modules to analyse and generate records
|
||||
|
||||
initial_instance.install_modules(modules)
|
||||
initial_modules = (
|
||||
modules
|
||||
and modules
|
||||
or get_installable_odoo_modules(initial_instance, initial_step)
|
||||
)
|
||||
initial_instance.install_modules(initial_modules)
|
||||
generate_records(initial_instance, initial_step)
|
||||
|
||||
# FINAL : Run odoo and install analysis module
|
||||
|
|
@ -103,14 +103,28 @@ def generate_module_analysis(ctx, last_step, database, modules):
|
|||
detached_container=True,
|
||||
alternative_xml_rpc_port=alternative_xml_rpc_port,
|
||||
)
|
||||
final_instance = OdooInstance(ctx, final_database)
|
||||
|
||||
# FINAL : install modules to analyse and generate records
|
||||
# # FINAL : install modules to analyse and generate records
|
||||
final_instance = OdooInstance(
|
||||
ctx,
|
||||
final_database,
|
||||
alternative_xml_rpc_port=alternative_xml_rpc_port,
|
||||
)
|
||||
final_modules = (
|
||||
modules
|
||||
and modules
|
||||
or get_installable_odoo_modules(final_instance, final_step)
|
||||
)
|
||||
final_instance.install_modules(final_modules)
|
||||
generate_records(final_instance, final_step)
|
||||
|
||||
final_instance.install_modules(modules)
|
||||
generate_records(final_instance, initial_step)
|
||||
generate_analysis_files(
|
||||
final_instance,
|
||||
final_step,
|
||||
initial_database,
|
||||
ctx.obj["config"]["odoo_host_xmlrpc_port"],
|
||||
)
|
||||
|
||||
final_database = final_database
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
logger.info("Received Keyboard Interrupt or System Exiting...")
|
||||
finally:
|
||||
|
|
|
|||
|
|
@ -155,3 +155,73 @@ def generate_records(odoo_instance, migration_step: dict):
|
|||
"upgrade.generate.record.wizard", {}
|
||||
)
|
||||
wizard.generate()
|
||||
|
||||
|
||||
def get_installable_odoo_modules(odoo_instance, migraton_step):
|
||||
if migraton_step["release"] < 14.0:
|
||||
# TODO, improve that algorithm, if possible
|
||||
modules = odoo_instance.browse_by_search(
|
||||
"ir.module.module",
|
||||
[
|
||||
("state", "!=", "uninstallable"),
|
||||
("website", "not ilike", "github/OCA"),
|
||||
],
|
||||
)
|
||||
|
||||
else:
|
||||
# We use here a new feature implemented in the upgrade_analysis
|
||||
# in a wizard to install odoo modules
|
||||
wizard = odoo_instance.browse_by_create("upgrade.install.wizard", {})
|
||||
wizard.select_odoo_modules()
|
||||
modules = wizard.module_ids
|
||||
|
||||
return modules.mapped("name")
|
||||
|
||||
|
||||
def generate_analysis_files(
|
||||
final_odoo_instance, final_step, initial_database, initial_xmlrpc_port
|
||||
):
|
||||
logger.info(
|
||||
"Generate analysis files for"
|
||||
" the modules installed on %s ..." % (initial_database)
|
||||
)
|
||||
proxy_vals = {
|
||||
"name": "Proxy to Previous Release",
|
||||
"server": "localhost",
|
||||
"port": initial_xmlrpc_port,
|
||||
"database": initial_database,
|
||||
"username": "admin",
|
||||
"password": "admin",
|
||||
}
|
||||
if final_step["release"] < 14.0:
|
||||
logger.info("> Create proxy ...")
|
||||
proxy = final_odoo_instance.browse_by_create(
|
||||
"openupgrade.comparison.config", proxy_vals
|
||||
)
|
||||
|
||||
logger.info("> Create wizard ...")
|
||||
|
||||
wizard = final_odoo_instance.browse_by_create(
|
||||
"openupgrade.analysis.wizard",
|
||||
{
|
||||
"server_config": proxy.id,
|
||||
"write_files": True,
|
||||
},
|
||||
)
|
||||
logger.info("> Launch analysis. This can take a while ...")
|
||||
wizard.get_communication()
|
||||
|
||||
else:
|
||||
logger.info("> Create proxy ...")
|
||||
proxy = final_odoo_instance.browse_by_create(
|
||||
"upgrade.comparison.config", proxy_vals
|
||||
)
|
||||
logger.info("> Create wizard ...")
|
||||
analysis = final_odoo_instance.browse_by_create(
|
||||
"upgrade.analysis",
|
||||
{
|
||||
"config_id": proxy.id,
|
||||
},
|
||||
)
|
||||
logger.info("> Launch analysis. This can take a while ...")
|
||||
analysis.analyze()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import time
|
|||
import odoorpc
|
||||
from loguru import logger
|
||||
|
||||
# Wait for the launch of odoo instance 60 seconds
|
||||
_ODOO_RPC_MAX_TRY = 60
|
||||
_ODOO_RPC_TIMEOUT = 60
|
||||
|
||||
# Timeout for odoorpc call is 24 hours
|
||||
_ODOO_RPC_TIMEOUT = 86400
|
||||
|
||||
|
||||
class OdooInstance:
|
||||
|
|
@ -14,10 +17,6 @@ class OdooInstance:
|
|||
version = False
|
||||
|
||||
def __init__(self, ctx, database, alternative_xml_rpc_port=False):
|
||||
# # TODO, improve me waith for response on http://localhost:port
|
||||
# # with a time out
|
||||
# # the docker container take a little time to be up.
|
||||
# time.sleep(60)
|
||||
port = (
|
||||
alternative_xml_rpc_port
|
||||
and alternative_xml_rpc_port
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user