Merge pull request #44 from ERPLibre/sandbox_test_parallel
Sandbox test parallel
This commit is contained in:
commit
dac3518b4b
13 changed files with 816 additions and 156 deletions
2
Makefile
2
Makefile
|
|
@ -357,6 +357,8 @@ test_full:
|
|||
test_full_fast:
|
||||
./script/make.sh clean
|
||||
./script/test/run_parallel_test.py
|
||||
# TODO This test is broken in parallel
|
||||
./script/make.sh test_code_generator_hello_world
|
||||
|
||||
.PHONY: test_base
|
||||
test_base:
|
||||
|
|
|
|||
18
poetry.lock
generated
18
poetry.lock
generated
|
|
@ -6,6 +6,14 @@ category = "main"
|
|||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "aioshutil"
|
||||
version = "1.1"
|
||||
description = "Asynchronous shutil module."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "alabaster"
|
||||
version = "0.7.12"
|
||||
|
|
@ -1820,7 +1828,7 @@ typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""
|
|||
|
||||
[[package]]
|
||||
name = "pylint-odoo"
|
||||
version = "5.0.5"
|
||||
version = "5.0.6.dev1"
|
||||
description = "Pylint plugin for Odoo"
|
||||
category = "main"
|
||||
optional = false
|
||||
|
|
@ -1844,7 +1852,7 @@ whichcraft = "*"
|
|||
type = "git"
|
||||
url = "https://github.com/oca/pylint-odoo.git"
|
||||
reference = "master"
|
||||
resolved_reference = "c03dd158acd79dea665588af38a00a49f54e210a"
|
||||
resolved_reference = "151d31d452f8963c560672e2abe1919649769a45"
|
||||
|
||||
[[package]]
|
||||
name = "pylint-plugin-utils"
|
||||
|
|
@ -3062,13 +3070,17 @@ python-versions = "*"
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.7.12"
|
||||
content-hash = "83010756f7980ae45b19114177a7018314bede3c0fd49ab139d1a73782b8c851"
|
||||
content-hash = "a0ff20f5203ceac245624c04e5d9b96956a3453545738056f9a24be8f22f9775"
|
||||
|
||||
[metadata.files]
|
||||
agithub = [
|
||||
{file = "agithub-2.2.2-py2.py3-none-any.whl", hash = "sha256:5f50071536db0cc9611859e761d7c3dc6f951a8535029bf6af7fb22744b7e118"},
|
||||
{file = "agithub-2.2.2.tar.gz", hash = "sha256:321aa5fc688fde2970562b35c991881b69a13f57372d554a0fab184df85fa8a7"},
|
||||
]
|
||||
aioshutil = [
|
||||
{file = "aioshutil-1.1-py3-none-any.whl", hash = "sha256:4c17e1da55cf928b4a85bd6ff5e4f1560cf21db7a16b5da5844f8f3edf3e2895"},
|
||||
{file = "aioshutil-1.1.tar.gz", hash = "sha256:d2e8d6baddab13137410b27ce24f39ce9889684cb47503d5af182ea8d038b0f1"},
|
||||
]
|
||||
alabaster = [
|
||||
{file = "alabaster-0.7.12-py2.py3-none-any.whl", hash = "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359"},
|
||||
{file = "alabaster-0.7.12.tar.gz", hash = "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02"},
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ xmlformatter = "^0.2.4"
|
|||
xmltodict = "^0.12.0"
|
||||
zeep = "^4.1.0"
|
||||
zxcvbn = "^4.4.28"
|
||||
aioshutil = "^1.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
websocket_client = "^1.1.0"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ openupgradelib
|
|||
unidiff
|
||||
colorama
|
||||
wheel
|
||||
aioshutil
|
||||
|
||||
# For OSX
|
||||
cython
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import os
|
|||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
CONFIG_PATH = "./config.conf"
|
||||
|
||||
logging.basicConfig(
|
||||
format=(
|
||||
"%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d]"
|
||||
|
|
@ -34,6 +32,12 @@ def get_config():
|
|||
required=True,
|
||||
help="Module name to search, a list can be use separate by ,",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--config",
|
||||
default="./config.conf",
|
||||
help="The config path.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--debug",
|
||||
action="store_true",
|
||||
|
|
@ -49,18 +53,18 @@ def main():
|
|||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
config_parser = configparser.ConfigParser()
|
||||
config_parser.read(CONFIG_PATH)
|
||||
config_parser.read(config.config)
|
||||
if "options" in config_parser:
|
||||
if "addons_path" in config_parser["options"]:
|
||||
addons_path = config_parser["options"]["addons_path"]
|
||||
else:
|
||||
_logger.error(
|
||||
"Missing item 'addons_path' in section 'options' in"
|
||||
f" '{CONFIG_PATH}'"
|
||||
f" '{config.config}'"
|
||||
)
|
||||
return -1
|
||||
else:
|
||||
_logger.error(f"Missing section 'options' in '{CONFIG_PATH}'")
|
||||
_logger.error(f"Missing section 'options' in '{config.config}'")
|
||||
return -1
|
||||
|
||||
lst_addons_path = addons_path.split(",")
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
# Argument 3 is config
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./script/addons/check_addons_exist.py -m "$2" -c "$3"
|
||||
else
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
fi
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error install_addons.sh"
|
||||
exit 1
|
||||
echo "Error check_addons_exist.py into install_addons.sh"
|
||||
exit 1
|
||||
fi
|
||||
./run.sh --no-http --stop-after-init -d "$1" -i "$2" -u "$2"
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./run.sh --no-http --stop-after-init -d "$1" -i "$2" -u "$2" -c "$3"
|
||||
else
|
||||
./run.sh --no-http --stop-after-init -d "$1" -i "$2" -u "$2"
|
||||
fi
|
||||
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error install_addons.sh"
|
||||
exit 1
|
||||
echo "Error run.sh into install_addons.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
# Argument 3 is config
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./script/addons/check_addons_exist.py -m "$2" -c "$3"
|
||||
else
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
fi
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error install_addons.sh"
|
||||
exit 1
|
||||
echo "Error check_addons_exist.py into install_addons_dev.sh"
|
||||
exit 1
|
||||
fi
|
||||
./run.sh --no-http --stop-after-init --dev qweb -d "$1" -i "$2" -u "$2"
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./run.sh --no-http --stop-after-init --dev qweb -d "$1" -i "$2" -u "$2" -c "$3"
|
||||
else
|
||||
./run.sh --no-http --stop-after-init --dev qweb -d "$1" -i "$2" -u "$2"
|
||||
fi
|
||||
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error install_addons_dev.sh"
|
||||
exit 1
|
||||
echo "Error run.sh into install_addons_dev.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,14 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
# Argument 3 is config
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./script/addons/check_addons_exist.py -m "$2" -c "$3"
|
||||
else
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
fi
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error install_addons.sh"
|
||||
exit 1
|
||||
echo "Error check_addons_exist.py into reinstall_addons_dev.sh"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./script/addons/uninstall_addons.sh "$1" "$2" "$3"
|
||||
else
|
||||
./script/addons/uninstall_addons.sh "$1" "$2"
|
||||
fi
|
||||
# Ignore if not uninstall
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./script/addons/install_addons_dev.sh "$1" "$2" "$3"
|
||||
else
|
||||
./script/addons/install_addons_dev.sh "$1" "$2"
|
||||
fi
|
||||
./script/addons/uninstall_addons.sh "$1" "$2"
|
||||
./script/addons/install_addons_dev.sh "$1" "$2"
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error reinstall_addons.sh"
|
||||
exit 1
|
||||
echo "Error install_addons_dev.sh into reinstall_addons.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,8 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
# Argument 3 is config
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./script/addons/check_addons_exist.py -m "$2" -c "$3"
|
||||
else
|
||||
./script/addons/check_addons_exist.py -m "$2"
|
||||
fi
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error install_addons.sh"
|
||||
exit 1
|
||||
echo "Error check_addons_exist.py into uninstall_addons.sh"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $# -eq 3 ]]; then
|
||||
./run.sh --no-http --stop-after-init -d "$1" --uninstall "$2" "$3"
|
||||
else
|
||||
./run.sh --no-http --stop-after-init -d "$1" --uninstall "$2"
|
||||
fi
|
||||
./run.sh --no-http --stop-after-init -d "$1" --uninstall "$2"
|
||||
|
|
|
|||
|
|
@ -3,31 +3,41 @@
|
|||
# $2 is module name separate by ,
|
||||
# $3 is directory path to check
|
||||
# $4 is generated module name separate by ,
|
||||
# $5 optional, the config path
|
||||
|
||||
if (($# < 4)); then
|
||||
if [[ $# -lt 4 ]]; then
|
||||
echo "ERROR, need 4 arguments: 1-database name, 2-list of module to install, 3-directory to check difference, 4-list of generated module"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INIT_DATETIME=$(date +%s)
|
||||
|
||||
./script/addons/install_addons_dev.sh "$1" "$2"
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
if [[ $# -eq 5 ]]; then
|
||||
./script/addons/install_addons_dev.sh "$1" "$2" "$5"
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error ./script/addons/install_addons_dev.sh ${1} ${2} ${5}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
./script/addons/install_addons_dev.sh "$1" "$2"
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error ./script/addons/install_addons_dev.sh ${1} ${2}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if the code was updated
|
||||
./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}"
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error ./script/code_generator/test_code_generator_update_module.py ${4} ${3}"
|
||||
exit 1
|
||||
echo "Error ./script/code_generator/test_code_generator_update_module.py ${4} ${3}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO check output when got warning
|
||||
./script/repo_revert_git_diff_date_from_code_generator.py
|
||||
./script/repo_revert_git_diff_date_from_code_generator.py --repo "$3"
|
||||
# Remove pot and po diff
|
||||
cd "$3" || exit 1
|
||||
# git 2.22 and more, else use next command
|
||||
|
|
@ -44,6 +54,6 @@ echo "TEST ${2}"
|
|||
./script/code_generator/check_git_change_code_generator.sh "$3"
|
||||
retVal=$?
|
||||
if [[ $retVal -ne 0 ]]; then
|
||||
echo "Error ./script/code_generator/check_git_change_code_generator.sh"
|
||||
exit 1
|
||||
echo "Error ./script/code_generator/check_git_change_code_generator.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import argparse
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
from git import Repo
|
||||
|
|
@ -73,14 +74,6 @@ def get_config():
|
|||
action="store_true",
|
||||
help="Force override directory and module.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--do_not_update_config",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Ignore updating config file. This is a patch for a bug for"
|
||||
" duplicate path, but 1 relative and the other is absolute."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--keep_bd_alive",
|
||||
action="store_true",
|
||||
|
|
@ -105,11 +98,9 @@ class ProjectManagement:
|
|||
template_name="",
|
||||
template_directory="",
|
||||
force=False,
|
||||
ignore_config=False,
|
||||
keep_bd_alive=False,
|
||||
):
|
||||
self.force = force
|
||||
self.ignore_config = ignore_config
|
||||
self.keep_bd_alive = keep_bd_alive
|
||||
self.msg_error = ""
|
||||
self.origin_config_txt = ""
|
||||
|
|
@ -233,6 +224,7 @@ class ProjectManagement:
|
|||
git_repo.git.restore(relative_path)
|
||||
|
||||
def generate_module(self):
|
||||
# TODO copy directory in temp workspace file before update it
|
||||
module_path = os.path.join(self.module_directory, self.module_name)
|
||||
if not self.force and not self.validate_path_ready_to_be_override(
|
||||
self.module_name, self.module_directory, path=module_path
|
||||
|
|
@ -316,7 +308,7 @@ class ProjectManagement:
|
|||
)
|
||||
):
|
||||
return False
|
||||
self.update_config()
|
||||
config_path = self.update_config()
|
||||
|
||||
bd_name_demo = f"new_project_code_generator_demo_{uuid.uuid4()}"[:63]
|
||||
cmd = f"./script/db_restore.py --database {bd_name_demo}"
|
||||
|
|
@ -325,7 +317,7 @@ class ProjectManagement:
|
|||
_logger.info("========= GENERATE code_generator_demo =========")
|
||||
cmd = (
|
||||
f"./script/addons/install_addons_dev.sh {bd_name_demo}"
|
||||
" code_generator_demo"
|
||||
f" code_generator_demo {config_path}"
|
||||
)
|
||||
os.system(cmd)
|
||||
|
||||
|
|
@ -345,7 +337,6 @@ class ProjectManagement:
|
|||
# Validate
|
||||
if not os.path.exists(template_path):
|
||||
_logger.error(f"Module template not exists '{template_path}'")
|
||||
self.revert_config()
|
||||
return False
|
||||
else:
|
||||
_logger.info(f"Module template exists '{template_path}'")
|
||||
|
|
@ -363,7 +354,7 @@ class ProjectManagement:
|
|||
# Execute all
|
||||
bd_name_template = (
|
||||
f"new_project_code_generator_template_{uuid.uuid4()}"[:63]
|
||||
)[:63]
|
||||
)
|
||||
cmd = f"./script/db_restore.py --database {bd_name_template}"
|
||||
os.system(cmd)
|
||||
_logger.info(cmd)
|
||||
|
|
@ -379,14 +370,14 @@ class ProjectManagement:
|
|||
os.system(cmd)
|
||||
cmd = (
|
||||
f"./script/addons/install_addons_dev.sh {bd_name_template}"
|
||||
f" {self.module_name}"
|
||||
f" {self.module_name} {config_path}"
|
||||
)
|
||||
_logger.info(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
cmd = (
|
||||
f"./script/addons/install_addons_dev.sh {bd_name_template}"
|
||||
f" {self.template_name}"
|
||||
f" {self.template_name} {config_path}"
|
||||
)
|
||||
_logger.info(cmd)
|
||||
os.system(cmd)
|
||||
|
|
@ -402,7 +393,6 @@ class ProjectManagement:
|
|||
# Validate
|
||||
if not os.path.exists(cg_path):
|
||||
_logger.error(f"Module cg not exists '{cg_path}'")
|
||||
self.revert_config()
|
||||
return False
|
||||
else:
|
||||
_logger.info(f"Module cg exists '{cg_path}'")
|
||||
|
|
@ -415,7 +405,7 @@ class ProjectManagement:
|
|||
|
||||
cmd = (
|
||||
f"./script/addons/install_addons_dev.sh {bd_name_generator}"
|
||||
f" {self.cg_name}"
|
||||
f" {self.cg_name} {config_path}"
|
||||
)
|
||||
_logger.info(cmd)
|
||||
os.system(cmd)
|
||||
|
|
@ -424,24 +414,20 @@ class ProjectManagement:
|
|||
cmd = (
|
||||
"./.venv/bin/python3 ./odoo/odoo-bin db --drop --database"
|
||||
f" {bd_name_generator}"
|
||||
)[:63]
|
||||
)
|
||||
_logger.info(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
# Validate
|
||||
if not os.path.exists(template_path):
|
||||
_logger.error(f"Module not exists '{module_path}'")
|
||||
self.revert_config()
|
||||
return False
|
||||
else:
|
||||
_logger.info(f"Module exists '{module_path}'")
|
||||
|
||||
self.revert_config()
|
||||
return True
|
||||
|
||||
def update_config(self):
|
||||
if self.ignore_config:
|
||||
return
|
||||
# Backup config and restore it after, check if path exist or add it temporary
|
||||
with open("./config.conf") as config:
|
||||
config_txt = config.read()
|
||||
|
|
@ -462,14 +448,11 @@ class ProjectManagement:
|
|||
if lst_directory_to_add:
|
||||
new_str = "addons_path = " + ",".join(lst_directory_to_add) + ","
|
||||
config_txt = config_txt.replace("addons_path = ", new_str)
|
||||
with open("./config.conf", "w") as config:
|
||||
config.write(config_txt)
|
||||
|
||||
def revert_config(self):
|
||||
if self.ignore_config:
|
||||
return
|
||||
with open("./config.conf", "w") as config:
|
||||
config.write(self.origin_config_txt)
|
||||
temp_file = tempfile.mktemp()
|
||||
with open(temp_file, "w") as config:
|
||||
config.write(config_txt)
|
||||
print(f"mathben \n {temp_file} \n")
|
||||
return temp_file
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -482,7 +465,6 @@ def main():
|
|||
cg_name=config.code_generator_name,
|
||||
template_name=config.template_name,
|
||||
force=config.force,
|
||||
ignore_config=config.do_not_update_config,
|
||||
keep_bd_alive=config.keep_bd_alive,
|
||||
)
|
||||
if project.msg_error:
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ def get_config():
|
|||
epilog="""\
|
||||
""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--repo",
|
||||
default="./addons/TechnoLibre_odoo-code-generator-template;./addons/OCA_server-tools",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
|
@ -43,11 +47,7 @@ def main():
|
|||
r"[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])"
|
||||
r" (2[0-3]|[01][0-9]):[0-5][0-9]"
|
||||
)
|
||||
# TODO support argument instead of hardcoded values
|
||||
lst_path = [
|
||||
"./addons/TechnoLibre_odoo-code-generator-template",
|
||||
"./addons/OCA_server-tools",
|
||||
]
|
||||
lst_path = config.repo.split(";")
|
||||
for path in lst_path:
|
||||
repo = git.Repo(path)
|
||||
supported_ext = [".xml", ".pot", ".po"]
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue