Exemplo n.º 1
0
    def test_get_info_for_rj_job(self, get):
        """Test Genie 3 adapter get info call for job (job section)."""

        adapter = Genie3Adapter()
        adapter.get_info_for_rj('111-job', job=True)

        assert_equals([call('111-job', timeout=30)], get.call_args_list)
Exemplo n.º 2
0
    def test_get_info_for_rj_all_timeout(self, get):
        """Test Genie 3 adapter get info call for job (all) (with timeout)."""


        get.side_effect = [
            {'_links':{'self':{'href':'http://example.com'}}},
            {},
            [],
            {},
            {},
            {},
            {}
        ]
        adapter = Genie3Adapter()
        adapter.get_info_for_rj('111-all-timeout', timeout=1)

        assert_equals(
            [
                call('111-all-timeout', timeout=1),
                call('111-all-timeout', path='request', timeout=1),
                call('111-all-timeout', path='applications', timeout=1, if_not_found=[]),
                call('111-all-timeout', path='cluster', timeout=1, if_not_found={}),
                call('111-all-timeout', path='command', timeout=1, if_not_found={}),
                call('111-all-timeout', path='execution', timeout=1, if_not_found={}),
                call('111-all-timeout', path='output', timeout=1, headers={'Accept': 'application/json'}, if_not_found={})
            ],
            get.call_args_list
        )
Exemplo n.º 3
0
    def test_disable_adapter_timeout_conf(self):
        """Test Genie 3 adapter disable_adapter_timeout values."""

        for value in {'True', 'true', 'TRUE', True, '1', 1}:
            conf = GenieConf()
            conf.genie.set('disable_adapter_timeout', value)
            adapter = Genie3Adapter(conf=conf)
            assert_equals(True, adapter.disable_timeout)
Exemplo n.º 4
0
    def test_stderr_log_not_found(self, request):
        """Test Genie 3 adapter getting stderr log which does not exist."""

        request.return_value = fake_response(None, status_code=404)

        adapter = Genie3Adapter()

        with assert_raises(GenieLogNotFoundError):
            adapter.get_stderr('job_id_dne')
Exemplo n.º 5
0
    def test_job_submit(self, request):
        """Test Genie 3 adapter job submit."""

        request.return_value = fake_response(None, status_code=202)

        adapter = Genie3Adapter()

        adapter.submit_job(PrestoJob().script("select * from dual"))

        assert_equals(1, request.call_count)
Exemplo n.º 6
0
    def test_get_404(self, request):
        """Test Genie 3 adapter get with if_not_found (404)."""

        request.side_effect = [
            fake_response(None, status_code=404),
            fake_response(None, status_code=111),
            fake_response(None, status_code=112),
            fake_response(None, status_code=113),
        ]

        adapter = Genie3Adapter()

        assert_equals(
            'DEFAULT',
            Genie3Adapter().get(job_id='job-get-404',
                                path='output',
                                if_not_found='DEFAULT'))

        assert_equals(1, request.call_count)
Exemplo n.º 7
0
    def test_get_info_for_rj_job(self, get):
        """Test Genie 3 adapter get info call for job (job section)."""

        get.side_effect = [{'_links':{'self':{'href':'http://example.com'}}}]

        adapter = Genie3Adapter()
        adapter.get_info_for_rj('111-job', job=True)

        assert_equals(
            [
                call('111-job', timeout=30),
            ],
            get.call_args_list
        )
Exemplo n.º 8
0
    def test_get_info_for_rj_all(self, get):
        """Test Genie 3 adapter get info call for job (all)."""

        adapter = Genie3Adapter()
        adapter.get_info_for_rj('111-all')

        assert_equals([
            call('111-all', timeout=30),
            call('111-all', path='request', timeout=30),
            call('111-all', if_not_found=[], path='applications', timeout=30),
            call('111-all', if_not_found={}, path='cluster', timeout=30),
            call('111-all', if_not_found={}, path='command', timeout=30),
            call('111-all', if_not_found={}, path='execution', timeout=30)
        ], get.call_args_list)
Exemplo n.º 9
0
    def test_get_500(self, request):
        """Test Genie 3 adapter get with if_not_found (500)."""

        request.side_effect = [
            fake_response(None, status_code=500),
            fake_response(None, status_code=500),
            fake_response(None, status_code=500),
            fake_response(None, status_code=500),
            fake_response(None, status_code=500),
            fake_response(None, status_code=500),
            fake_response(None, status_code=500),
        ]

        adapter = Genie3Adapter()

        assert_equals({},
                      Genie3Adapter().get(job_id='job-get-500',
                                          path='output',
                                          if_not_found={},
                                          attempts=3,
                                          backoff=0))

        assert_equals(3, request.call_count)
Exemplo n.º 10
0
    def test_job_submit_409(self, request):
        """Test Genie 3 adapter job submit (409 response)."""

        request.side_effect = [
            fake_response(None, status_code=409),
            fake_response(None, status_code=202),
            fake_response(None, status_code=503),
        ]

        adapter = Genie3Adapter()

        with assert_raises(GenieHTTPError):
            adapter.submit_job(PrestoJob().script("select * from dual"))

        assert_equals(1, request.call_count)
Exemplo n.º 11
0
    def test_get_info_for_rj_all(self, get):
        """Test Genie 3 adapter get info call for job (all)."""

        get.side_effect = [{
            '_links': {
                'self': {
                    'href': 'http://example.com'
                }
            }
        }, {}, [], {}, {}, {}]

        adapter = Genie3Adapter()
        adapter.get_info_for_rj('111-all')

        assert_equals([
            call('111-all', timeout=30),
            call('111-all', path='request', timeout=30),
            call('111-all', if_not_found=[], path='applications', timeout=30),
            call('111-all', if_not_found={}, path='cluster', timeout=30),
            call('111-all', if_not_found={}, path='command', timeout=30),
            call('111-all', if_not_found={}, path='execution', timeout=30)
        ], get.call_args_list)
Exemplo n.º 12
0
    def test_job_submit_various_responses(self, request):
        """Test Genie 3 adapter job submit (various response codes then 202)."""

        request.side_effect = [
            fake_response(None, status_code=403),
            fake_response(None, status_code=404),
            fake_response(None, status_code=412),
            fake_response(None, status_code=503),
            fake_response(None, status_code=504),
            fake_response(None, status_code=202),
            fake_response(None, status_code=403),
            fake_response(None, status_code=404),
            fake_response(None, status_code=412),
            fake_response(None, status_code=503),
            fake_response(None, status_code=504),
        ]

        adapter = Genie3Adapter()

        adapter.submit_job(PrestoJob().script("select * from dual"),
                           attempts=15,
                           backoff=0)

        assert_equals(6, request.call_count)
Exemplo n.º 13
0
 def setUp(self):
     conf = GenieConf()
     conf.genie.set('disable_adapter_timeout', 'True')
     self.adapter = Genie3Adapter(conf=conf)