Skip to content

Commit

Permalink
Fix ZK test so it works on travis without a running ZK instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
conorbranagan committed Aug 25, 2014
1 parent 220ec9b commit 59da2e9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/test_zookeeper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import unittest
from StringIO import StringIO
from tests.common import get_check
Expand All @@ -23,6 +24,9 @@
"""

class TestZookeeper(unittest.TestCase):
def is_travis(self):
return "TRAVIS" in os.environ

def test_zk_stat_parsing_lt_v344(self):
zk, instances = get_check('zk', CONFIG)
stat_response = """Zookeeper version: 3.2.2--1, built on 03/16/2010 07:31 GMT
Expand Down Expand Up @@ -63,11 +67,14 @@ def test_zk_stat_parsing_lt_v344(self):

zk.check(instances[0])
service_checks = zk.get_service_checks()
self.assertEquals(len(service_checks), 2)
expected = 1 if self.is_travis() else 2
self.assertEquals(len(service_checks), expected)
self.assertEquals(service_checks[0]['check'], 'zookeeper.ruok')
# Don't check status of ruok because it can vary if ZK is running.
self.assertEquals(service_checks[1]['check'], 'zookeeper.mode')
self.assertEquals(service_checks[1]['status'], AgentCheck.CRITICAL)

if not self.is_travis():
self.assertEquals(service_checks[1]['check'], 'zookeeper.mode')
self.assertEquals(service_checks[1]['status'], AgentCheck.CRITICAL)

def test_zk_stat_parsing_gte_v344(self):
zk, instances = get_check('zk', CONFIG2)
Expand Down

0 comments on commit 59da2e9

Please sign in to comment.