Skip to content

Commit 08ac154

Browse files
committed
Refactor the Run upload process
Refactor the process such that runs and related datasets get created/persisted synchronously whereas the datasets processing (label values calculation and so on) is deferred to the async process by making use if the dataset-even queue Signed-off-by: Andrea Lamparelli <[email protected]>
1 parent a763314 commit 08ac154

File tree

13 files changed

+359
-222
lines changed

13 files changed

+359
-222
lines changed

docs/site/content/en/openapi/openapi.yaml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -648,18 +648,25 @@ paths:
648648
jobDisplayName: upstream-perf-bre-datastructures
649649
buildDisplayName: "#125"
650650
responses:
651-
"200":
652-
description: id of the newly generated run
651+
"202":
652+
description: "The request has been accepted for processing. Returns a list\
653+
\ of created run IDs if available, or an empty list if processing is still\
654+
\ ongoing. Label values and change detection processing is performed asynchronously."
653655
content:
654656
application/json:
655657
schema:
656-
format: int32
657-
type: integer
658-
example: 101
659-
"202":
660-
description: The run data will be processed asynchronously
661-
content:
662-
text/plain: {}
658+
type: array
659+
items:
660+
format: int32
661+
type: integer
662+
example:
663+
- 101
664+
- 102
665+
- 103
666+
example:
667+
- 101
668+
- 102
669+
- 103
663670
"204":
664671
description: Data is valid but no run was created
665672
content:
@@ -841,8 +848,29 @@ paths:
841848
$ref: "#/components/schemas/Run"
842849
required: true
843850
responses:
844-
"200":
845-
description: OK
851+
"202":
852+
description: "The request has been accepted for processing. Returns a list\
853+
\ of created run IDs if available, or an empty list if processing is still\
854+
\ ongoing. Label values and change detection processing is performed asynchronously."
855+
content:
856+
application/json:
857+
schema:
858+
type: array
859+
items:
860+
format: int32
861+
type: integer
862+
example:
863+
- 101
864+
- 102
865+
- 103
866+
example:
867+
- 101
868+
- 102
869+
- 103
870+
"400":
871+
description: Some fields are missing or invalid
872+
content:
873+
application/json: {}
846874
/api/run/{id}:
847875
get:
848876
tags:

horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io.quarkus.logging.Log;
77

88
public class Version {
9-
public static final String getVersion() {
9+
public static String getVersion() {
1010
final Properties properties = new Properties();
1111
try {
1212
properties.load(Version.class.getClassLoader().getResourceAsStream("build.properties"));

horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/RunService.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ void updateAccess(@PathParam("id") int id,
166166
@Parameter(name = "access", description = "New Access level", example = "0"),
167167
})
168168
@RequestBody(name = "runBody", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Run.class)), required = true)
169+
@APIResponses(value = {
170+
@APIResponse(responseCode = "202", description = "The request has been accepted for processing. Returns a list of created run IDs if available, "
171+
+ "or an empty list if processing is still ongoing. Label values and change detection processing " +
172+
"is performed asynchronously.", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(type = SchemaType.ARRAY, implementation = Integer.class, example = "[101, 102, 103]"), example = "[101, 102, 103]")),
173+
@APIResponse(responseCode = "400", description = "Some fields are missing or invalid", content = @Content(mediaType = MediaType.APPLICATION_JSON))
174+
})
169175
Response add(@QueryParam("test") String testNameOrId,
170176
@QueryParam("owner") String owner,
171177
@QueryParam("access") Access access,
@@ -199,12 +205,6 @@ Response add(@QueryParam("test") String testNameOrId,
199205
" \"buildDisplayName\": \"#125\"\n" +
200206
" }\n" +
201207
"]"))
202-
@APIResponses(value = {
203-
@APIResponse(responseCode = "200", description = "id of the newly generated run", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(type = SchemaType.INTEGER, implementation = Integer.class), example = "101")),
204-
@APIResponse(responseCode = "202", description = "The run data will be processed asynchronously", content = @Content(mediaType = MediaType.TEXT_PLAIN)),
205-
@APIResponse(responseCode = "204", description = "Data is valid but no run was created", content = @Content(mediaType = MediaType.TEXT_PLAIN)),
206-
@APIResponse(responseCode = "400", description = "Some fields are missing or invalid", content = @Content(mediaType = MediaType.APPLICATION_JSON))
207-
})
208208
@Operation(description = "Upload a new Run")
209209
@Parameters(value = {
210210
@Parameter(name = "start", required = true, description = "start timestamp of run, or json path expression", examples = {
@@ -222,6 +222,13 @@ Response add(@QueryParam("test") String testNameOrId,
222222
@Parameter(name = "description", description = "Run description", example = "AWS runs"),
223223

224224
})
225+
@APIResponses(value = {
226+
@APIResponse(responseCode = "202", description = "The request has been accepted for processing. Returns a list of created run IDs if available, "
227+
+ "or an empty list if processing is still ongoing. Label values and change detection processing " +
228+
"is performed asynchronously.", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(type = SchemaType.ARRAY, implementation = Integer.class, example = "[101, 102, 103]"), example = "[101, 102, 103]")),
229+
@APIResponse(responseCode = "204", description = "Data is valid but no run was created", content = @Content(mediaType = MediaType.TEXT_PLAIN)),
230+
@APIResponse(responseCode = "400", description = "Some fields are missing or invalid", content = @Content(mediaType = MediaType.APPLICATION_JSON))
231+
})
225232
Response addRunFromData(@QueryParam("start") String start,
226233
@QueryParam("stop") String stop,
227234
@QueryParam("test") String test,
@@ -234,11 +241,14 @@ Response addRunFromData(@QueryParam("start") String start,
234241
@POST
235242
@Path("data")
236243
@Consumes(MediaType.MULTIPART_FORM_DATA)
237-
@Produces(MediaType.TEXT_PLAIN) // run ID as string
238244
@Operation(description = "Upload a new Run with metadata", hidden = true)
239245
@APIResponses(value = {
240-
@APIResponse(responseCode = "200", content = {
241-
@Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(type = SchemaType.STRING)) }) })
246+
@APIResponse(responseCode = "202", description = "The request has been accepted for processing. Returns a list of created run IDs if available, "
247+
+ "or an empty list if processing is still ongoing. Label values and change detection processing " +
248+
"is performed asynchronously.", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(type = SchemaType.ARRAY, implementation = Integer.class, example = "[101, 102, 103]"), example = "[101, 102, 103]")),
249+
@APIResponse(responseCode = "204", description = "Data is valid but no run was created", content = @Content(mediaType = MediaType.TEXT_PLAIN)),
250+
@APIResponse(responseCode = "400", description = "Some fields are missing or invalid", content = @Content(mediaType = MediaType.APPLICATION_JSON))
251+
})
242252
Response addRunFromData(@Parameter(required = true) @QueryParam("start") String start,
243253
@Parameter(required = true) @QueryParam("stop") String stop,
244254
@Parameter(required = true) @QueryParam("test") String test,

0 commit comments

Comments
 (0)