db-updater container added for updating db data up to current ddl version
This commit is contained in:
parent
2ac9ab49ec
commit
7c7c1a98b6
4 changed files with 37 additions and 0 deletions
|
|
@ -54,6 +54,7 @@ test:
|
|||
script:
|
||||
- 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 ./clr_test/clearing-all/bin
|
||||
- echo "Copying ddl files to clearing-all/db" && cp -r /builds/mfd/clearing/z-distr/target/clearing/db ./clr_test/clearing-all/db
|
||||
- echo "Removing old logs folder artifacts/logs" && rm -rf artifacts/logs
|
||||
- python3 clr_test/run_test_docker_containers.py
|
||||
- echo "Copying logs" && mkdir -p artifacts/logs && docker run --rm -v clr_test_logs_volume:/logs alpine tar -C /logs -cf - . | tar -C artifacts/logs -xf -
|
||||
|
|
|
|||
7
clr_test/db-updater/Dockerfile
Normal file
7
clr_test/db-updater/Dockerfile
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
FROM alpine
|
||||
|
||||
ADD combined_update_ddl.sql /init.sql
|
||||
|
||||
RUN apk add --update --no-cache postgresql-client
|
||||
|
||||
CMD [ "sh", "-c", "psql -U clearing -h db -p 5432 -d clearing -f init.sql" ]
|
||||
|
|
@ -13,6 +13,11 @@ services:
|
|||
timeout: 5s
|
||||
retries: 100
|
||||
|
||||
db-updater:
|
||||
build: db-updater
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
clearing_system:
|
||||
build:
|
||||
context: ./clearing-all
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from glob import glob
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
|
@ -12,6 +13,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(me
|
|||
DATA_ROOT_DIR = os.environ['CLEARING_TEST_DIR']
|
||||
CLR_TEST_DIR = os.environ['CLR_TEST_DIR']
|
||||
RESULT_FILES_DIR = os.environ['RESULT_FILES_DIR']
|
||||
DDL_VERSION_FROM = (3, 17)
|
||||
|
||||
|
||||
def run_docker(folder_name: str) -> int:
|
||||
|
|
@ -108,9 +110,31 @@ def stop_docker_compose() -> None:
|
|||
os.chdir("..")
|
||||
|
||||
|
||||
def combine_ddl_updates_into_file():
|
||||
pattern = re.compile(r'updateDDL_(\d+)\.(\d+)\.sql$')
|
||||
|
||||
files = []
|
||||
for filepath in glob(f"{CLR_TEST_DIR}/db/updateDDL_*.sql"):
|
||||
filename = os.path.basename(filepath)
|
||||
match = pattern.search(filename)
|
||||
if match:
|
||||
major, minor = map(int, match.groups())
|
||||
if (major, minor) > DDL_VERSION_FROM:
|
||||
files.append(((major, minor), filepath))
|
||||
|
||||
files.sort(key=lambda x: x[0])
|
||||
|
||||
with open(f"{CLR_TEST_DIR}/db-updater/combined_update_ddl.sql", 'w', encoding='utf-8') as outfile:
|
||||
for version, filepath in files:
|
||||
with open(filepath, 'r', encoding='utf-8') as infile:
|
||||
content = infile.read().rstrip('\n')
|
||||
outfile.write(content + '\n\n')
|
||||
|
||||
|
||||
def main() -> None:
|
||||
folders = [i for i in sorted(os.listdir(DATA_ROOT_DIR)) if re.search("\\d{1,}.\\d{1,}.*", i)]
|
||||
|
||||
combine_ddl_updates_into_file()
|
||||
for folder in folders:
|
||||
stop_docker_compose()
|
||||
apply_test_case(folder)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue