Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
rwillard committed Feb 11, 2016
1 parent de378a6 commit 5721791
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
Binary file added __pycache__/sidekick.cpython-35.pyc
Binary file not shown.
9 changes: 5 additions & 4 deletions sidekick.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
parser.add_argument( '--type', action='store', default='http',
help='type for Vulcand')

def announce_services( services, etcd_folder, etcd_client, timeout , ttl):
def announce_services( services, etcd_folder, etcd_client, timeout , ttl, vulcand):
for key, value in services:
logger.info( 'Health check for {}'.format( key ) )
healthy = check_health( value )

if value['vulcand']:
if vulcand:
backend = "/vulcand/backends/"+key+"/backend"
server = "/vulcand/backends/"+key+"/servers/srv1"
frontend = "/vulcand/frontends/"+key+"/frontend"
Expand Down Expand Up @@ -189,7 +189,7 @@ def find_matching_container( containers, args ):
port = port[ 'PublicPort' ]

if args.vulcand:
matching[args.name] = { 'ip': args.ip, 'port': port, 'domain': args.domain, 'vulcand': args.vulcand, 'type': args.type}
matching[args.name] = { 'ip': args.ip, 'port': port, 'domain': args.domain, 'type': args.type}
else:
# Create a UUID
m = hashlib.md5()
Expand Down Expand Up @@ -243,7 +243,8 @@ def main():
etcd_folder,
etcd_client,
args.timeout,
args.ttl, )
args.ttl,
args.vulcand )

if __name__ == '__main__':
main()
Binary file added tests/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file not shown.
7 changes: 4 additions & 3 deletions tests/test_sidekick.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sidekick import check_health, public_ports

# Used to test command line arguments
Args = namedtuple('Args', ['name', 'ip', 'check_ip'])
Args = namedtuple('Args', ['name', 'ip', 'check_ip', 'vulcand'])


class MockEtcd( object ):
Expand All @@ -26,7 +26,7 @@ class TestSidekick( unittest.TestCase ):

def setUp( self ):

self.args = Args( name='test', ip='localhost', check_ip='0.0.0.0' )
self.args = Args( name='test', ip='localhost', check_ip='0.0.0.0', vulcand=False )

self.etcd_client = MockEtcd()

Expand All @@ -48,7 +48,8 @@ def setUp( self ):
def test_announce_services( self ):
''' Test `announce_services` functionality '''
services = find_matching_container( [self.container], self.args )
announce_services( services.items(), 'test', self.etcd_client, 0, 0 )
print(services)
announce_services( services.items(), 'test', self.etcd_client, 0, 0, False )

def test_check_health( self ):
''' Test `check_health` functionality '''
Expand Down

0 comments on commit 5721791

Please sign in to comment.