From 88f5e6e4cff54757bbbd3bd8653d8f8cad7bee51 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Fri, 2 Nov 2018 15:05:16 +0200 Subject: [PATCH] Moved users creation in core --- .travis.yml | 4 ---- tests/compose/core/00_create_users.sh | 3 +++ tests/compose/test.py | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100755 tests/compose/core/00_create_users.sh diff --git a/.travis.yml b/.travis.yml index ffb6af43..54b3b3c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,6 @@ install: before_script: - docker-compose -v - docker-compose -f tests/build.yml build - - docker-compose up -d admin - - docker-compose exec admin python manage.py admin admin mailu.io password - - docker-compose exec admin python manage.py user --hash_scheme='SHA512-CRYPT' user mailu.io 'password' - - docker-compose down script: # test.py, test name and timeout between start and tests. diff --git a/tests/compose/core/00_create_users.sh b/tests/compose/core/00_create_users.sh new file mode 100755 index 00000000..babe307d --- /dev/null +++ b/tests/compose/core/00_create_users.sh @@ -0,0 +1,3 @@ +echo "Creating users ..." +docker-compose -f tests/compose/core/docker-compose.yml exec admin python manage.py admin admin mailu.io password || exit 1 +docker-compose -f tests/compose/core/docker-compose.yml exec admin python manage.py user --hash_scheme='SHA512-CRYPT' user mailu.io 'password' || exit 1 diff --git a/tests/compose/test.py b/tests/compose/test.py index 84281123..c90f481b 100755 --- a/tests/compose/test.py +++ b/tests/compose/test.py @@ -19,19 +19,19 @@ def stop(exit_code): print_logs() os.system("docker-compose -f " + compose_file + " down") sys.exit(exit_code) - + # Sleep for a defined amount of time def sleep(): print(Fore.LIGHTMAGENTA_EX + "Sleeping for " + str(timeout) + "m" + Style.RESET_ALL) time.sleep(timeout*60) - + def health_checks(): exit_code = 0 #Iterating trough all containers dictionary for container in client.containers(all=True): #Perform "docker container inspect" on container based on container ID and save output to a dictionary container_inspect = client.inspect_container(container['Id']) #Dict - + if "Health" in container_inspect['State'].keys(): if container_inspect['State']['Health']['Status'] == "healthy": print(Fore.GREEN + "Health status for " + container_inspect['Name'].replace("/", "") + " : " + Fore.CYAN + container_inspect['State']['Health']['Status'] + Style.RESET_ALL) @@ -46,36 +46,37 @@ def health_checks(): if container_inspect['State']['Status'] != "running": print(Fore.RED + "Container " + container_inspect['Name'].replace("/", "") + " state is: " + Fore.YELLOW + container_inspect['State']['Status'] + Style.RESET_ALL) exit_code = 1 - + #Saving Id, Name and state to a new dictionary containers_dict = {} containers_dict['Name'] = container_inspect['Name'].replace("/", "") containers_dict['Id'] = container_inspect['Id'] containers_dict['State'] = container_inspect['State'] - + #Adding the generated dictionary to a list containers.append(containers_dict) - + if exit_code != 0: stop(exit_code) - + def print_logs(): print("Printing logs ...") #Iterating through docker container inspect list and print logs for container in containers: print(Fore.LIGHTMAGENTA_EX + "Printing logs for: " + Fore.GREEN + container['Name'] + Style.RESET_ALL) os.system('docker container logs ' + container['Name']) - -#Iterating over hooks in test folder and running them + +#Iterating over hooks in test folder and running them def hooks(): print("Running hooks") - os.system("python3 tests/compose/email_test.py") for test_file in sorted(os.listdir(test_path)): if test_file.endswith(".py"): os.system("python3 " + test_path + test_file) elif test_file.endswith(".sh"): os.system("./" + test_path + test_file) + os.system("python3 tests/compose/email_test.py") + # Start up containers os.system("mkdir -p /mailu && cp -r tests/certs /mailu") os.system("chmod 600 /mailu/certs/* ")