Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icrease sleeps depending on 'TRAVIS' environment variable #5

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@
# along with ianitor. If not, see <http://www.gnu.org/licenses/>.

from time import sleep
import os

import mock
from consul import Consul

from ianitor import service
from consul import Consul

if os.environ.get("TRAVIS", False):
SLEEP_WAIT = 3
else:
SLEEP_WAIT = 0.1


def get_tailf_service(session):
Expand All @@ -30,7 +37,7 @@ def get_tailf_service(session):
session=session,
service_name="tailf",
# small ttl for faster testing
ttl=1,
ttl=SLEEP_WAIT * 2,
)


Expand Down Expand Up @@ -158,16 +165,16 @@ def test_keep_alive():
# test that service health check is unknown or critical after registration
tailf.register()
# small sleep for cluster consensus
sleep(0.5)
sleep(SLEEP_WAIT)
assert _get_service_status(session, tailf) in ("unknown", "critical")

# assert service is healthy back again after keep alive
tailf.keep_alive()
sleep(0.5)
sleep(SLEEP_WAIT)
assert _get_service_status(session, tailf) == "passing"

# assert service health check fails after ttl passed
sleep(tailf.ttl + 0.5)
sleep(tailf.ttl + SLEEP_WAIT)
assert _get_service_status(session, tailf) == "critical"


Expand All @@ -182,7 +189,7 @@ def test_keepalive_reregister():
# [integration] assert service is healthy
tailf.register()
tailf.keep_alive()
sleep(0.5)
sleep(SLEEP_WAIT)
assert _get_service_status(session, tailf) == "passing"

# [integration] assert that check
Expand All @@ -191,7 +198,7 @@ def test_keepalive_reregister():

# [integration] assert that keepalive makes service registered again
tailf.keep_alive()
sleep(0.5)
sleep(SLEEP_WAIT)
assert _get_service_status(session, tailf) == "passing"


Expand Down