52 lines
2.4 KiB
Python
52 lines
2.4 KiB
Python
import os
|
|
import re
|
|
import time
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
DATA_ROOT_DIR = os.environ['CLEARING_TEST_DIR']
|
|
CLR_TEST_DIR = os.environ['CLR_TEST_DIR']
|
|
QEMU_ALPINE_DIR = os.environ['QEMU_ALPINE_DIR']
|
|
RESULT_FILES_DIR = os.environ['RESULT_FILES_DIR']
|
|
|
|
|
|
def run_docker(folder_name):
|
|
print(f"Running docker-compose for {folder_name}")
|
|
os.chdir(QEMU_ALPINE_DIR)
|
|
subprocess.call('docker compose up -d', shell=True)
|
|
time.sleep(3)
|
|
subprocess.call('scp -P 2222 -r ../clearing-docker-compose root@localhost:/root/clr_test', shell=True)
|
|
subprocess.call('ssh root@localhost -p 2222', shell=True)
|
|
subprocess.call('cd clr_test', shell=True)
|
|
subprocess.call('docker compose pull', shell=True)
|
|
subprocess.call('docker compose build', shell=True)
|
|
subprocess.call('date --set "2020-01-01 00:00:00"', shell=True)
|
|
subprocess.call('docker compose up', shell=True)
|
|
subprocess.call('exit', shell=True)
|
|
subprocess.call("scp -P 2222 -r root@localhost:/root/clr_test/mnt/testFiles {RESULT_FILES_DIR}", shell=True)
|
|
os.remove(f"{QEMU_ALPINE_DIR}/mounted/data.qcow2")
|
|
os.chdir("..")
|
|
|
|
|
|
def main():
|
|
folders = [i for i in sorted(os.listdir(DATA_ROOT_DIR)) if re.search("\\d{1,}.\\d{1,}.*", i)]
|
|
shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/expected")
|
|
shutil.rmtree(f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/store/input")
|
|
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}/{folders[0]}/db/", f"{CLR_TEST_DIR}/db/", dirs_exist_ok=True)
|
|
shutil.copytree(f"{DATA_ROOT_DIR}/{folders[0]}/clearing_testing_utils/", f"{CLR_TEST_DIR}/clearing-all/clearing_testing_utils/", dirs_exist_ok=True)
|
|
shutil.copy2(f"{QEMU_ALPINE_DIR}/data.qcow2", f"{QEMU_ALPINE_DIR}/mounted")
|
|
run_docker(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)
|
|
|
|
|
|
if __name__=='__main__':
|
|
main()
|