Skip to content

Commit

Permalink
LIU-66: Add test for logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
davepallot committed Jul 19, 2021
1 parent 7359e3f commit 59221e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions daliuge-engine/test/manager/test_mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from dlg.manager.composite_manager import MasterManager
from dlg.manager.session import SessionStates
from dlg.testutils import ManagerStarter
from dlg.exceptions import NoSessionException
from test.manager import testutils


Expand Down Expand Up @@ -272,3 +273,11 @@ def test_fullRound(self):
testutils.delete(self, '/sessions/%s' % (sessionId), restPort)
sessions = testutils.get(self, '/sessions', restPort)
self.assertEqual(0, len(sessions))

# Check log should not exist
resp, _ = testutils._get('/sessions/not_exist/logs', 8000)
self.assertEqual(resp.status, 404)

# Check logs exist and there is content
resp, _ = testutils._get('/sessions/{sessionId}/logs', restPort)
self.assertGreater(int(resp.getheader('Content-Length')), 0)
8 changes: 5 additions & 3 deletions daliuge-engine/test/manager/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
from dlg import utils
import codecs


def get(test, url, port):
def _get(url, port):
conn = http.client.HTTPConnection('localhost', port, timeout=3)
conn.request('GET', '/api' + url)
res = conn.getresponse()
return conn.getresponse(), conn

def get(test, url, port):
res, conn = _get(url, port)
test.assertEqual(http.HTTPStatus.OK, res.status)
jsonRes = json.load(codecs.getreader('utf-8')(res))
res.close()
Expand Down

0 comments on commit 59221e3

Please sign in to comment.