1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-12 10:45:38 +02:00

Moved users creation in core

This commit is contained in:
Ionut Filip 2018-11-02 15:05:16 +02:00
parent c3bc7988c9
commit 88f5e6e4cf
3 changed files with 14 additions and 14 deletions

View File

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

View File

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

View File

@ -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/* ")