def test_health_returns_200(self, mock_request): expected = { "DockerHub": { "ok": "true" }, "Engine Database": { "ok": "true" }, "PAPI": { "ok": "true" }, "GCS": { "ok": "true" }, } def _request_callback(request, context): context.status_code = 200 context.headers['test'] = 'header' return expected for cromwell_auth in self.auth_options: mock_request.get('{0}/engine/v1/status'.format(cromwell_auth.url), json=_request_callback) result = CromwellAPI.health(cromwell_auth) self.assertEqual(result.status_code, 200) self.assertEqual(result.json(), expected)
def validate_cromwell_server(cromwell_auth): # Ping the cromwell server and check system health. Raise error if any issues returned by server. logging.info("Checking health of cromwell server...") result = CromwellAPI.health(cromwell_auth) try: result.raise_for_status() except requests.exceptions.HTTPError: logging.error("Cromwell server is reachable but not functional! " "Message from server:\n{0}".format(result.json())) raise logging.info("Cromwell server is up and running!")