.gitlab-ci.yml updated v109

This commit is contained in:
Ivan Nikolaev-Axenov 2024-07-04 11:48:06 +03:00
parent f092833de8
commit 92f6d7ab02
11 changed files with 45 additions and 64 deletions

View file

@ -24,35 +24,16 @@ preflight:
paths:
- clearing_test
#build:
# image: ${DOCKER_PROXY}/maven:latest
# stage: build
# script:
# - mvn clean package -DskipTests -Pdistributive
# artifacts:
# name: "$CI_COMMIT_REF_NAME"
# expire_in: 1 day
# paths:
# - /builds/mfd/clearing/z-distr/target/clearing
#test:
# stage: test
# variables:
# CLEARING_TEST_DIR: "/builds/mfd/clearing/clearing_test"
# CLR_TEST_DIR: "/builds/mfd/clearing/clr_test"
# RESULT_FILES_DIR: "/builds/mfd/clearing/clr_test/result-files"
# script:
# - echo $CI_PROJECT_DIR
# - pwd
# - echo "Installing maven and python" && apk update && apk add maven python3
## - echo "Copying jar files to clearing-all/bin" && cp -r /builds/mfd/clearing/z-distr/target/clearing/bin ./clearing-all/bin
## - echo "Copying DDL.sql to db directory" && cp /builds/mfd/clearing/z-distr/target/clearing/db/DDL.sql ./db
# - python3 clr_test/run_test_docker_containers.py
# artifacts:
# expire_in: 1 day
# when: always
# paths:
# - $CI_PROJECT_DIR/
build:
image: ${DOCKER_PROXY}/maven:latest
stage: build
script:
- mvn clean package -DskipTests -Pdistributive
artifacts:
name: "$CI_COMMIT_REF_NAME"
expire_in: 1 day
paths:
- /builds/mfd/clearing/z-distr/target/clearing
test:
stage: test
@ -61,16 +42,10 @@ test:
CLR_TEST_DIR: "/builds/mfd/clearing/clr_test"
RESULT_FILES_DIR: "/builds/mfd/clearing/clr_test/result-files"
script:
- cd clr_test
- rm -rf /builds/mfd/clearing/clr_test/clearing-all/clearing_testing_utils/store/expected
- rm -rf /builds/mfd/clearing/clr_test/clearing-all/clearing_testing_utils/store/input
- rm /builds/mfd/clearing/clr_test/db/export.sql
- rm /builds/mfd/clearing/clr_test/db/test-data.sql
- cp -r /builds/mfd/clearing/clearing_test/1.0.SESN.MKR.CURR/db/. /builds/mfd/clearing/clr_test/db/
- cp -r /builds/mfd/clearing/clearing_test/1.0.SESN.MKR.CURR/clearing_testing_utils/. /builds/mfd/clearing/clr_test/clearing-all/clearing_testing_utils/
- docker compose pull
- docker compose build --no-cache
- docker compose up --abort-on-container-exit --exit-code-from clearing_system
- echo "Installing maven and python" && apk update && apk add maven python3
- echo "Copying jar files to clearing-all/bin" && cp -r /builds/mfd/clearing/z-distr/target/clearing/bin ./clearing-all/bin
- echo "Copying DDL.sql to db directory" && cp /builds/mfd/clearing/z-distr/target/clearing/db/DDL.sql ./db
- python3 clr_test/run_test_docker_containers.py
artifacts:
expire_in: 1 day
when: always

Binary file not shown.

View file

@ -14,6 +14,10 @@ clearing-tester.sftp.xml.importer.in-dir=/opt/clearing/files/xml/importer/in
clearing-tester.sftp.xml.importer.out-dir=/opt/clearing/files/xml/importer/out
clearing-tester.sftp.xml.exporter.out-dir=/opt/clearing/files/xml/exporter
#mock dates settings
clearing-tester.mock-date-for-sdf=2024-01-20
clearing-tester.mock-date-for-execution=2023-01-25
clearing-tester.sftp.user=user
clearing-tester.sftp.password=Aa111111
clearing-tester.sftp.server-ip=sftp

View file

@ -14,7 +14,7 @@ CLR_TEST_DIR = os.environ['CLR_TEST_DIR']
RESULT_FILES_DIR = os.environ['RESULT_FILES_DIR']
def run_docker(folder_name, date):
def run_docker(folder_name):
print(f"Running docker-compose for {folder_name}")
os.chdir("clr_test")
subprocess.call('docker compose pull', shell=True)
@ -24,9 +24,16 @@ def run_docker(folder_name, date):
os.chdir("..")
def read_date(folder_name):
with open(f"{DATA_ROOT_DIR}/{folder_name}/date.txt") as f:
return f.read()
def change_date(folder_name):
pattern = r"((?<=clearing-tester\.mock-date-for-sdf=)|(?<=clearing-tester\.mock-date-for-execution=))(.+)"
with open(f"{DATA_ROOT_DIR}/{folder_name}/date.txt", 'r') as f:
date = f.read()
with open(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/clearing-tester/application.properties", 'r') as f:
file = f.read()
re.sub(pattern, date, file)
with open(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/clearing-tester/application.properties", 'w') as f:
f.write(file)
def remove_files_with_extensions(extension):
@ -40,32 +47,27 @@ def remove_files_with_extensions(extension):
def main():
folders = [i for i in sorted(os.listdir(DATA_ROOT_DIR)) if re.search("\\d{1,}.\\d{1,}.*", i)]
logging.info(f"Removing folder {CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/expected")
shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/expected")
for folder in folders:
logging.info(f"Removing folder {CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/expected")
shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/expected")
logging.info(f"Removing folder {CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/input")
shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/input")
logging.info(f"Removing folder {CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/input")
shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/input")
logging.info(f"Removing file {CLR_TEST_DIR}/db/export.sql")
os.remove(f"{CLR_TEST_DIR}/db/export.sql")
logging.info(f"Removing file {CLR_TEST_DIR}/db/export.sql")
os.remove(f"{CLR_TEST_DIR}/db/export.sql")
logging.info(f"Removing file {CLR_TEST_DIR}/db/test-data.sql")
os.remove(f"{CLR_TEST_DIR}/db/test-data.sql")
logging.info(f"Removing file {CLR_TEST_DIR}/db/test-data.sql")
os.remove(f"{CLR_TEST_DIR}/db/test-data.sql")
logging.info(f"Copying files from {DATA_ROOT_DIR}/{folders[0]}/db/ to {CLR_TEST_DIR}/db/")
shutil.copytree(f"{DATA_ROOT_DIR}/{folders[0]}/db/", f"{CLR_TEST_DIR}/db/", dirs_exist_ok=True)
logging.info(f"Copying files from {DATA_ROOT_DIR}/{folder}/db/ to {CLR_TEST_DIR}/db/")
shutil.copytree(f"{DATA_ROOT_DIR}/{folder}/db/", f"{CLR_TEST_DIR}/db/", dirs_exist_ok=True)
logging.info(f"Copying files from {DATA_ROOT_DIR}/{folders[0]}/clearing_testing_utils/ to {CLR_TEST_DIR}/clearing-all/clearing_testing_utils/")
shutil.copytree(f"{DATA_ROOT_DIR}/{folders[0]}/clearing_testing_utils/", f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/", dirs_exist_ok=True)
remove_files_with_extensions(".xml")
run_docker(folders[0], read_date(folders[0]))
# for folder in folders:
# shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store")
# os.remove(f"{CLR_TEST_DIR}/db/export.sql")
# os.remove(f"{CLR_TEST_DIR}/db/test-data.sql")
# shutil.copytree(f"{DATA_ROOT_DIR}/{folder}/db/", f"{CLR_TEST_DIR}/db/", dirs_exist_ok=True)
# shutil.copytree(f"{DATA_ROOT_DIR}/{folder}/clearing_testing_utils/", f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/", dirs_exist_ok=True)
# run_docker(folder)
logging.info(f"Copying files from {DATA_ROOT_DIR}/{folder}/clearing_testing_utils/ to {CLR_TEST_DIR}/clearing-all/clearing_testing_utils/")
shutil.copytree(f"{DATA_ROOT_DIR}/{folder}/clearing_testing_utils/", f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/", dirs_exist_ok=True)
remove_files_with_extensions(".xml")
change_date(folder)
run_docker(folder)
if __name__=='__main__':