File tree Expand file tree Collapse file tree 6 files changed +24
-16
lines changed
Expand file tree Collapse file tree 6 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def __init__(self,
2828 tag ,
2929 host = 'localhost' ,
3030 port = 24224 ,
31- bufmax = 1 * 1024 * 1024 ,
31+ bufmax = 1 * 1024 * 1024 ,
3232 timeout = 3.0 ,
3333 verbose = False ):
3434
@@ -102,9 +102,14 @@ def _send_internal(self, bytes_):
102102
103103 def _reconnect (self ):
104104 if not self .socket :
105- sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
106- sock .settimeout (self .timeout )
107- sock .connect ((self .host , self .port ))
105+ if self .host .startswith ('unix://' ):
106+ sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
107+ sock .settimeout (self .timeout )
108+ sock .connect (self .host [len ('unix://' ):])
109+ else :
110+ sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
111+ sock .settimeout (self .timeout )
112+ sock .connect ((self .host , self .port ))
108113 self .socket = sock
109114
110115 def _close (self ):
Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22
33from tests .test_event import *
4- from tests .test_sender import *
54from tests .test_handler import *
5+ from tests .test_sender import *
6+ from tests .test_unix_domain_socket_sender import *
Original file line number Diff line number Diff line change @@ -16,9 +16,13 @@ class MockRecvServer(threading.Thread):
1616 """
1717 Single threaded server accepts one connection and recv until EOF.
1818 """
19- def __init__ (self , port ):
20- self ._sock = socket .socket ()
21- self ._sock .bind (('localhost' , port ))
19+ def __init__ (self , host = 'localhost' , port = 24224 ):
20+ if host .startswith ('unix://' ):
21+ self ._sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
22+ self ._sock .bind (host [len ('unix://' ):])
23+ else :
24+ self ._sock = socket .socket ()
25+ self ._sock .bind ((host , port ))
2226 self ._buf = BytesIO ()
2327
2428 threading .Thread .__init__ (self )
Original file line number Diff line number Diff line change 88sender .setup (server = 'localhost' , tag = 'app' )
99
1010
11- class TestHandler (unittest .TestCase ):
11+ class TestEvent (unittest .TestCase ):
1212 def testLogging (self ):
1313 # send event with tag app.follow
1414 event .Event ('follow' , {
Original file line number Diff line number Diff line change 88from tests import mockserver
99
1010
11- class TestLogger (unittest .TestCase ):
11+ class TestHandler (unittest .TestCase ):
1212 def setUp (self ):
13- super (TestLogger , self ).setUp ()
13+ super (TestHandler , self ).setUp ()
1414 for port in range (10000 , 20000 ):
1515 try :
16- self ._server = mockserver .MockRecvServer (port )
16+ self ._server = mockserver .MockRecvServer ('localhost' , port )
1717 self ._port = port
1818 break
1919 except IOError :
Original file line number Diff line number Diff line change @@ -13,13 +13,11 @@ def setUp(self):
1313 super (TestSender , self ).setUp ()
1414 for port in range (10000 , 20000 ):
1515 try :
16- self ._server = mockserver .MockRecvServer (port )
16+ self ._server = mockserver .MockRecvServer ('localhost' , port )
1717 break
1818 except IOError as exc :
1919 print (exc )
20- self ._sender = fluent .sender .FluentSender (tag = 'test' ,
21- port = port ,
22- )
20+ self ._sender = fluent .sender .FluentSender (tag = 'test' , port = port )
2321
2422 def get_data (self ):
2523 return self ._server .get_recieved ()
You can’t perform that action at this time.
0 commit comments