Skip to content

Commit

Permalink
more e2e tests. leaving out a lot of features, but testing critical p…
Browse files Browse the repository at this point in the history
…ath.
  • Loading branch information
jesseshieh committed Apr 30, 2017
1 parent 8e531e6 commit 6edaf27
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
47 changes: 44 additions & 3 deletions e2e/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This Python file uses the following encoding: utf-8
import json
import os
import time
import subprocess
Expand All @@ -8,6 +9,7 @@
import contextlib
import logging
import requests
import timeit

def test_everything():
logging.basicConfig(format='%(message)s', level=logging.DEBUG)
Expand All @@ -27,6 +29,7 @@ def test_everything():
app_name = result.output.rstrip()
gigalixir.shell.cast("git push gigalixir")
logging.info('Completed Deploy.')
start_time = timeit.default_timer()
url = 'https://%s.gigalixirapp.com/' % app_name
for i in range(30):
try:
Expand All @@ -46,11 +49,49 @@ def test_everything():
logging.info('Waiting 30 seconds to try again.')
time.sleep(30)
else:
logging.info('Exhausted retries.')
logging.info('Exhausted retries. Be sure to scale down your app manually and other necessary cleanup since we are aborting now.')
assert False

# TODO: scale down to 0
# TODO: delete?
elapsed = timeit.default_timer() - start_time
logging.info("Elapsed time: %s" % elapsed)

# check status
result = runner.invoke(gigalixir.cli, ['status', app_name])
assert result.exit_code == 0
status = json.loads(result.output)
assert status["replicas_desired"] == 1
assert status["replicas_running"] == 1

# set a config
result = runner.invoke(gigalixir.cli, ['set_config', app_name, "FOO", "foo"])
assert result.exit_code == 0

# get configs
result = runner.invoke(gigalixir.cli, ['configs', app_name])
assert result.exit_code == 0
configs = json.loads(result.output)
assert configs == {"FOO": "foo"}

# delete the config
result = runner.invoke(gigalixir.cli, ['delete_config', app_name, "FOO"])
assert result.exit_code == 0

# get configs
result = runner.invoke(gigalixir.cli, ['configs', app_name])
assert result.exit_code == 0
configs = json.loads(result.output)
assert configs == {}

# scale down to 0
result = runner.invoke(gigalixir.cli, ['scale', app_name, '--replicas=0'])
assert result.exit_code == 0

# check status
result = runner.invoke(gigalixir.cli, ['status', app_name])
assert result.exit_code == 0
status = json.loads(result.output)
assert status["replicas_desired"] == 0
assert status["replicas_running"] == 0

@contextlib.contextmanager
def cd(newdir, cleanup=lambda: True):
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
'dev': [
'Sphinx',
'sphinx_rtd_theme',
]
],
'e2e': [
'pytest',
],
}
)

0 comments on commit 6edaf27

Please sign in to comment.