Glue: get_jobs() (#5974)
This commit is contained in:
parent
dae4f4947e
commit
354c81b7e1
@ -2391,7 +2391,7 @@
|
|||||||
|
|
||||||
## ecs
|
## ecs
|
||||||
<details>
|
<details>
|
||||||
<summary>80% implemented</summary>
|
<summary>78% implemented</summary>
|
||||||
|
|
||||||
- [X] create_capacity_provider
|
- [X] create_capacity_provider
|
||||||
- [X] create_cluster
|
- [X] create_cluster
|
||||||
@ -2402,6 +2402,7 @@
|
|||||||
- [X] delete_capacity_provider
|
- [X] delete_capacity_provider
|
||||||
- [X] delete_cluster
|
- [X] delete_cluster
|
||||||
- [X] delete_service
|
- [X] delete_service
|
||||||
|
- [ ] delete_task_definitions
|
||||||
- [X] delete_task_set
|
- [X] delete_task_set
|
||||||
- [X] deregister_container_instance
|
- [X] deregister_container_instance
|
||||||
- [X] deregister_task_definition
|
- [X] deregister_task_definition
|
||||||
@ -3197,7 +3198,7 @@
|
|||||||
- [ ] get_job_bookmark
|
- [ ] get_job_bookmark
|
||||||
- [X] get_job_run
|
- [X] get_job_run
|
||||||
- [ ] get_job_runs
|
- [ ] get_job_runs
|
||||||
- [ ] get_jobs
|
- [X] get_jobs
|
||||||
- [ ] get_mapping
|
- [ ] get_mapping
|
||||||
- [ ] get_ml_task_run
|
- [ ] get_ml_task_run
|
||||||
- [ ] get_ml_task_runs
|
- [ ] get_ml_task_runs
|
||||||
@ -6880,6 +6881,7 @@
|
|||||||
- support-app
|
- support-app
|
||||||
- synthetics
|
- synthetics
|
||||||
- timestream-query
|
- timestream-query
|
||||||
|
- tnb
|
||||||
- transfer
|
- transfer
|
||||||
- translate
|
- translate
|
||||||
- voice-id
|
- voice-id
|
||||||
|
@ -36,6 +36,7 @@ ecs
|
|||||||
- [X] delete_capacity_provider
|
- [X] delete_capacity_provider
|
||||||
- [X] delete_cluster
|
- [X] delete_cluster
|
||||||
- [X] delete_service
|
- [X] delete_service
|
||||||
|
- [ ] delete_task_definitions
|
||||||
- [X] delete_task_set
|
- [X] delete_task_set
|
||||||
|
|
||||||
The Force-parameter is not yet implemented
|
The Force-parameter is not yet implemented
|
||||||
|
@ -124,7 +124,7 @@ glue
|
|||||||
- [ ] get_job_bookmark
|
- [ ] get_job_bookmark
|
||||||
- [X] get_job_run
|
- [X] get_job_run
|
||||||
- [ ] get_job_runs
|
- [ ] get_job_runs
|
||||||
- [ ] get_jobs
|
- [X] get_jobs
|
||||||
- [ ] get_mapping
|
- [ ] get_mapping
|
||||||
- [ ] get_ml_task_run
|
- [ ] get_ml_task_run
|
||||||
- [ ] get_ml_task_runs
|
- [ ] get_ml_task_runs
|
||||||
|
@ -88,7 +88,7 @@ mock_firehose = lazy_load(".firehose", "mock_firehose")
|
|||||||
mock_forecast = lazy_load(".forecast", "mock_forecast")
|
mock_forecast = lazy_load(".forecast", "mock_forecast")
|
||||||
mock_greengrass = lazy_load(".greengrass", "mock_greengrass")
|
mock_greengrass = lazy_load(".greengrass", "mock_greengrass")
|
||||||
mock_glacier = lazy_load(".glacier", "mock_glacier")
|
mock_glacier = lazy_load(".glacier", "mock_glacier")
|
||||||
mock_glue = lazy_load(".glue", "mock_glue")
|
mock_glue = lazy_load(".glue", "mock_glue", boto3_name="glue")
|
||||||
mock_guardduty = lazy_load(".guardduty", "mock_guardduty")
|
mock_guardduty = lazy_load(".guardduty", "mock_guardduty")
|
||||||
mock_iam = lazy_load(".iam", "mock_iam")
|
mock_iam = lazy_load(".iam", "mock_iam")
|
||||||
mock_iot = lazy_load(".iot", "mock_iot")
|
mock_iot = lazy_load(".iot", "mock_iot")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# autogenerated by /Users/danaronson/GitHub/forks/moto/scripts/update_backend_index.py
|
# autogenerated by /Users/dan/Sites/moto/scripts/update_backend_index.py
|
||||||
import re
|
import re
|
||||||
|
|
||||||
backend_url_patterns = [
|
backend_url_patterns = [
|
||||||
|
@ -69,6 +69,12 @@ class GlueBackend(BaseBackend):
|
|||||||
"limit_default": 100,
|
"limit_default": 100,
|
||||||
"unique_attribute": "name",
|
"unique_attribute": "name",
|
||||||
},
|
},
|
||||||
|
"get_jobs": {
|
||||||
|
"input_token": "next_token",
|
||||||
|
"limit_key": "max_results",
|
||||||
|
"limit_default": 100,
|
||||||
|
"unique_attribute": "name",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, region_name, account_id):
|
def __init__(self, region_name, account_id):
|
||||||
@ -329,6 +335,10 @@ class GlueBackend(BaseBackend):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise JobNotFoundException(name)
|
raise JobNotFoundException(name)
|
||||||
|
|
||||||
|
@paginate(pagination_model=PAGINATION_MODEL)
|
||||||
|
def get_jobs(self):
|
||||||
|
return [job for _, job in self.jobs.items()]
|
||||||
|
|
||||||
def start_job_run(self, name):
|
def start_job_run(self, name):
|
||||||
job = self.get_job(name)
|
job = self.get_job(name)
|
||||||
return job.start_job_run()
|
return job.start_job_run()
|
||||||
|
@ -343,6 +343,19 @@ class GlueResponse(BaseResponse):
|
|||||||
job = self.glue_backend.get_job(name)
|
job = self.glue_backend.get_job(name)
|
||||||
return json.dumps({"Job": job.as_dict()})
|
return json.dumps({"Job": job.as_dict()})
|
||||||
|
|
||||||
|
def get_jobs(self):
|
||||||
|
next_token = self._get_param("NextToken")
|
||||||
|
max_results = self._get_int_param("MaxResults")
|
||||||
|
jobs, next_token = self.glue_backend.get_jobs(
|
||||||
|
next_token=next_token, max_results=max_results
|
||||||
|
)
|
||||||
|
return json.dumps(
|
||||||
|
dict(
|
||||||
|
Jobs=[job.as_dict() for job in jobs],
|
||||||
|
NextToken=next_token,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def start_job_run(self):
|
def start_job_run(self):
|
||||||
name = self.parameters.get("JobName")
|
name = self.parameters.get("JobName")
|
||||||
job_run_id = self.glue_backend.start_job_run(name)
|
job_run_id = self.glue_backend.start_job_run(name)
|
||||||
|
@ -109,6 +109,53 @@ def test_get_job_exists():
|
|||||||
job.should.have.key("GlueVersion")
|
job.should.have.key("GlueVersion")
|
||||||
|
|
||||||
|
|
||||||
|
@mock_glue
|
||||||
|
def test_get_jobs_job_name_exists():
|
||||||
|
client = create_glue_client()
|
||||||
|
test_job_name = create_test_job(client)
|
||||||
|
response = client.get_jobs()
|
||||||
|
response["Jobs"].should.have.length_of(1)
|
||||||
|
response["Jobs"][0].should.have.key("Name").equals(test_job_name)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_glue
|
||||||
|
def test_get_jobs_with_max_results():
|
||||||
|
client = create_glue_client()
|
||||||
|
create_test_jobs(client, 4)
|
||||||
|
response = client.get_jobs(MaxResults=2)
|
||||||
|
response["Jobs"].should.have.length_of(2)
|
||||||
|
response.should.have.key("NextToken")
|
||||||
|
|
||||||
|
|
||||||
|
@mock_glue
|
||||||
|
def test_get_jobs_from_next_token():
|
||||||
|
client = create_glue_client()
|
||||||
|
create_test_jobs(client, 10)
|
||||||
|
first_response = client.get_jobs(MaxResults=3)
|
||||||
|
response = client.get_jobs(NextToken=first_response["NextToken"])
|
||||||
|
response["Jobs"].should.have.length_of(7)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_glue
|
||||||
|
def test_get_jobs_with_max_results_greater_than_actual_results():
|
||||||
|
client = create_glue_client()
|
||||||
|
create_test_jobs(client, 4)
|
||||||
|
response = client.get_jobs(MaxResults=10)
|
||||||
|
response["Jobs"].should.have.length_of(4)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_glue
|
||||||
|
def test_get_jobs_next_token_logic_does_not_create_infinite_loop():
|
||||||
|
client = create_glue_client()
|
||||||
|
create_test_jobs(client, 4)
|
||||||
|
first_response = client.get_jobs(MaxResults=1)
|
||||||
|
next_token = first_response["NextToken"]
|
||||||
|
while next_token:
|
||||||
|
response = client.get_jobs(NextToken=next_token)
|
||||||
|
next_token = response.get("NextToken")
|
||||||
|
assert not next_token
|
||||||
|
|
||||||
|
|
||||||
@mock_glue
|
@mock_glue
|
||||||
def test_list_jobs_with_max_results():
|
def test_list_jobs_with_max_results():
|
||||||
client = create_glue_client()
|
client = create_glue_client()
|
||||||
|
Loading…
Reference in New Issue
Block a user