Skip to content

Commit

Permalink
Merge pull request #1020 from ASFHyP3/name-fix
Browse files Browse the repository at this point in the history
Allow job queries with names longer than 20 characters
  • Loading branch information
asjohnston-asf authored May 19, 2022
2 parents fad883f + 35ee734 commit 76eb595
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [2.17.2]
### Fixed
- `GET /jobs` requests now accept `name` parameters up to 100 characters. Fixes [#1019](https://github.com/ASFHyP3/hyp3/issues/1019).

## [2.17.1]
### Fixed
- Fix how we fetch jobs that are waiting for step function execution, so that we actually start up to 400 executions at a time.
Expand Down
8 changes: 2 additions & 6 deletions apps/api/src/hyp3_api/api-spec/job_parameters.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ components:
enum:
- {{ job_type }}
name:
type: string
minLength: 1
maxLength: 100
$ref: "./openapi-spec.yml#components/schemas/name"
job_parameters:
$ref: "#/components/schemas/{{ job_type }}Parameters"

Expand All @@ -78,9 +76,7 @@ components:
enum:
- {{ job_type }}
name:
type: string
minLength: 1
maxLength: 100
$ref: "./openapi-spec.yml#components/schemas/name"
job_parameters:
type: object
additionalProperties: false
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/hyp3_api/api-spec/openapi-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ components:
description: User provided text to name the job
type: string
minLength: 1
maxLength: 20
maxLength: 100
example: Job Name

start_token:
Expand Down
12 changes: 11 additions & 1 deletion tests/test_api/test_list_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ def test_list_jobs(client, tables):


def test_list_jobs_by_name(client, tables):
long_name = 'item with a long name' + '-' * 79
assert len(long_name) == 100

items = [
make_db_record('0ddaeb98-7636-494d-9496-03ea4a7df266', name='item1'),
make_db_record('27836b79-e5b2-4d8f-932f-659724ea02c3', name='item2')
make_db_record('27836b79-e5b2-4d8f-932f-659724ea02c3', name=long_name)
]
for item in items:
tables.jobs_table.put_item(Item=item)
Expand All @@ -66,6 +69,13 @@ def test_list_jobs_by_name(client, tables):
assert response.status_code == HTTPStatus.OK
assert response.json == {'jobs': []}

response = client.get(JOBS_URI, query_string={'name': long_name})
assert response.status_code == HTTPStatus.OK
assert response.json == {'jobs': [items[1]]}

response = client.get(JOBS_URI, query_string={'name': long_name + '-'})
assert response.status_code == HTTPStatus.BAD_REQUEST


def test_list_jobs_by_type(client, tables):
items = [
Expand Down

0 comments on commit 76eb595

Please sign in to comment.