Skip to content

Commit

Permalink
Merge pull request #5 from swistakm/fix/issue-3-increase-sleeps-on-tr…
Browse files Browse the repository at this point in the history
…avis-builds

icrease sleeps depending on 'TRAVIS' environment variable
  • Loading branch information
swistakm committed Mar 13, 2015
2 parents 6a2c1a8 + 3de72a8 commit 0defc5f
Showing 1 changed file with 14 additions and 7 deletions.
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

0 comments on commit 0defc5f

Please sign in to comment.