Moved users creation in core

master
Ionut Filip 6 years ago
parent c3bc7988c9
commit 88f5e6e4cf

@ -18,10 +18,6 @@ install:
before_script: before_script:
- docker-compose -v - docker-compose -v
- docker-compose -f tests/build.yml build - 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: script:
# test.py, test name and timeout between start and tests. # test.py, test name and timeout between start and tests.

@ -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

@ -19,19 +19,19 @@ def stop(exit_code):
print_logs() print_logs()
os.system("docker-compose -f " + compose_file + " down") os.system("docker-compose -f " + compose_file + " down")
sys.exit(exit_code) sys.exit(exit_code)
# Sleep for a defined amount of time # Sleep for a defined amount of time
def sleep(): def sleep():
print(Fore.LIGHTMAGENTA_EX + "Sleeping for " + str(timeout) + "m" + Style.RESET_ALL) print(Fore.LIGHTMAGENTA_EX + "Sleeping for " + str(timeout) + "m" + Style.RESET_ALL)
time.sleep(timeout*60) time.sleep(timeout*60)
def health_checks(): def health_checks():
exit_code = 0 exit_code = 0
#Iterating trough all containers dictionary #Iterating trough all containers dictionary
for container in client.containers(all=True): for container in client.containers(all=True):
#Perform "docker container inspect" on container based on container ID and save output to a dictionary #Perform "docker container inspect" on container based on container ID and save output to a dictionary
container_inspect = client.inspect_container(container['Id']) #Dict container_inspect = client.inspect_container(container['Id']) #Dict
if "Health" in container_inspect['State'].keys(): if "Health" in container_inspect['State'].keys():
if container_inspect['State']['Health']['Status'] == "healthy": 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) 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": 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) print(Fore.RED + "Container " + container_inspect['Name'].replace("/", "") + " state is: " + Fore.YELLOW + container_inspect['State']['Status'] + Style.RESET_ALL)
exit_code = 1 exit_code = 1
#Saving Id, Name and state to a new dictionary #Saving Id, Name and state to a new dictionary
containers_dict = {} containers_dict = {}
containers_dict['Name'] = container_inspect['Name'].replace("/", "") containers_dict['Name'] = container_inspect['Name'].replace("/", "")
containers_dict['Id'] = container_inspect['Id'] containers_dict['Id'] = container_inspect['Id']
containers_dict['State'] = container_inspect['State'] containers_dict['State'] = container_inspect['State']
#Adding the generated dictionary to a list #Adding the generated dictionary to a list
containers.append(containers_dict) containers.append(containers_dict)
if exit_code != 0: if exit_code != 0:
stop(exit_code) stop(exit_code)
def print_logs(): def print_logs():
print("Printing logs ...") print("Printing logs ...")
#Iterating through docker container inspect list and print logs #Iterating through docker container inspect list and print logs
for container in containers: for container in containers:
print(Fore.LIGHTMAGENTA_EX + "Printing logs for: " + Fore.GREEN + container['Name'] + Style.RESET_ALL) print(Fore.LIGHTMAGENTA_EX + "Printing logs for: " + Fore.GREEN + container['Name'] + Style.RESET_ALL)
os.system('docker container logs ' + container['Name']) 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(): def hooks():
print("Running hooks") print("Running hooks")
os.system("python3 tests/compose/email_test.py")
for test_file in sorted(os.listdir(test_path)): for test_file in sorted(os.listdir(test_path)):
if test_file.endswith(".py"): if test_file.endswith(".py"):
os.system("python3 " + test_path + test_file) os.system("python3 " + test_path + test_file)
elif test_file.endswith(".sh"): elif test_file.endswith(".sh"):
os.system("./" + test_path + test_file) os.system("./" + test_path + test_file)
os.system("python3 tests/compose/email_test.py")
# Start up containers # Start up containers
os.system("mkdir -p /mailu && cp -r tests/certs /mailu") os.system("mkdir -p /mailu && cp -r tests/certs /mailu")
os.system("chmod 600 /mailu/certs/* ") os.system("chmod 600 /mailu/certs/* ")

Loading…
Cancel
Save