-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
24 lines (18 loc) · 799 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import unittest
import requests
import time
from urlparse import urljoin
class ElasticSenderTests(unittest.TestCase):
def get_logs(self):
resp = requests.get('http://{}:{}/log-*/_search?q=host:*'.format(os.environ['ELASTICSEARCH_PORT_9200_TCP_ADDR'], os.environ['ELASTICSEARCH_PORT_9200_TCP_PORT']))
return resp.json()
def test_hits_counter(self):
current = self.get_logs()['hits']['total']
requests.get('http://{}:{}/ok/'.format(os.environ['NGINX_PORT_80_TCP_ADDR'], os.environ['NGINX_PORT_80_TCP_PORT']))
# Time of sleep dependent on your env, you may change it as you need
time.sleep(3)
new = self.get_logs()['hits']['total']
self.assertEqual(new, current + 1)
if __name__ == "__main__":
unittest.main()