예제 #1
0
    def test_submit_job_disabled_timeout(self, genie_call):
        """Test Genie 3 adapter submit_job() (disabled timeout)."""

        job = PrestoJob().script('select * from table')

        self.adapter.submit_job(job)

        assert_equals(None, genie_call.call_args[1]['timeout'])
예제 #2
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)
예제 #3
0
    def test_set_job_name_with_script_has_params(self):
        """Test Genie 3 adapter setting job name (if not set) with script containing parameters."""

        job = PrestoJob() \
            .script('select * from ${table}') \
            .parameter('table', 'foo.fizz').username('test')

        payload = get_payload(job)

        assert_true('test.PrestoJob.Query' in payload['name'])
예제 #4
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)
예제 #5
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)