Skip to content

Commit

Permalink
fix #375 conn_rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Lvov committed Jul 14, 2016
1 parent 23d08aa commit 6299a3d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
3 changes: 3 additions & 0 deletions tempesta_fw/t/functional/tests/helpers/tfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def start_bomber():

def stop_bomber():
_sh("./scripts/tfw_bomber.sh --stop")

def del_db():
_sh("rm -rf /opt/tempesta/db")
# The teardown line is commented-out because we have the issue:
# #10 -Oops on shutdown
# At this point it is not solved and Tempesta FW simply can't be stopped.
Expand Down
30 changes: 20 additions & 10 deletions tempesta_fw/t/functional/tests/test_frang.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def conn_rate(self):
print("conn_rate\n")
self.__init__()
self.cfg.add_section('frang_limits')
self.cfg.add_option('request_rate', '5')
self.cfg.add_option('ip_block', 'on')
self.cfg.add_option('concurrent_connections', '5')
self.cfg.add_option('connection_rate', '5')
self.cfg.add_option('connection_burst', '5')
Expand All @@ -103,30 +103,40 @@ def conn_rate(self):

try:
conncount = 0
for x in range(0,8):
port = 8095
for x in range(0,7):
self.s = socket(AF_INET, SOCK_STREAM)
self.s.settimeout(2)
self.s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
self.s.bind(('127.0.0.5', port))
self.s.connect(("127.0.0.1", 8081))
conncount += 1

conncount += 1
port += conncount
print(conncount)
# time.sleep(0.2)
# self.s.send(self.vs_get)
# data = self.s.recv(1024)
# print(len(data))
# self.s.close()

self.s = socket(AF_INET, SOCK_STREAM)
self.s.connect(('127.0.0.1', 8081))
self.s.send(self.vs_get)
# self.s = socket(AF_INET, SOCK_STREAM)
# self.s.connect(('127.0.0.1', 8081))
# self.s.send(self.vs_get)
# self.s.shutdown(1)
except OSError as e:
print("conn except:", e.strerror)
# print("conn except:", e)
self.res = True
else:
self.res = False
finally:
pass
print("conncount:", conncount)
print("res:", self.res)
self.s.shutdown(SHUT_RDWR)
self.s.close()
time.sleep(5)
tfw.stop()
tfw.del_db()

def header_timeout(self):
part1 = b'GET / HTTP/1.0\r\n'
Expand All @@ -148,11 +158,11 @@ def header_timeout(self):
def get_name(self):
return 'test Frang'
def run(self):
tests = [self.header_timeout()]
tests = [self.conn_rate()]
for f in tests:
if hasattr(f, '__call__'):
f()
print("res:\n")
print("res:\n", self.res)


t = Test()
Expand Down

0 comments on commit 6299a3d

Please sign in to comment.