diff --git a/src/main/java/io/cryostat/reports/Reports.java b/src/main/java/io/cryostat/reports/Reports.java index 83270eca3..b7b7eea76 100644 --- a/src/main/java/io/cryostat/reports/Reports.java +++ b/src/main/java/io/cryostat/reports/Reports.java @@ -103,11 +103,7 @@ public Response get(HttpServerResponse response, @RestPath String encodedKey) { return Response.ok(request.getId(), MediaType.TEXT_PLAIN) .status(202) .location( - UriBuilder.fromUri( - String.format( - "/api/v4/targets/%d/reports/%d", - pair.getLeft(), pair.getRight())) - .build()) + UriBuilder.fromUri(String.format("/api/v4/reports/%s", encodedKey)).build()) .build(); } @@ -129,7 +125,9 @@ public Response getActive( // Check if we've already cached a result for this report, return it if so if (reportsService.keyExists(recording)) { - return Response.ok(reportsService.reportFor(recording).await().atMost(timeout)) + return Response.ok( + reportsService.reportFor(recording).await().atMost(timeout), + MediaType.APPLICATION_JSON) .status(200) .build(); } diff --git a/src/test/java/io/cryostat/reports/ReportsTest.java b/src/test/java/io/cryostat/reports/ReportsTest.java index 9669d2f4e..87cf9a79e 100644 --- a/src/test/java/io/cryostat/reports/ReportsTest.java +++ b/src/test/java/io/cryostat/reports/ReportsTest.java @@ -113,7 +113,17 @@ void testGetReportByTargetAndRemoteId() { .assertThat() .statusCode(202) .contentType(ContentType.TEXT) - .body(Matchers.any(String.class)); + .body(Matchers.any(String.class)) + .assertThat() + // 202 Indicates report generation is in progress and sends an intermediate + // response. + // Verify we get a location header from a 202. + .header( + "Location", + "http://localhost:8081/api/v4/targets/" + + targetId + + "/reports/" + + remoteId); given().log() .all() @@ -165,7 +175,12 @@ void testGetReportByUrl() { .assertThat() .statusCode(202) .contentType(ContentType.TEXT) - .body(Matchers.any(String.class)); + .body(Matchers.any(String.class)) + .assertThat() + // 202 Indicates report generation is in progress and sends an intermediate + // response. + // Verify we get a location header from a 202. + .header("Location", "http://localhost:8081" + reportUrl); given().log() .all() diff --git a/src/test/java/itest/RecordingWorkflowTest.java b/src/test/java/itest/RecordingWorkflowTest.java index 3e6abc9a6..c42a5d028 100644 --- a/src/test/java/itest/RecordingWorkflowTest.java +++ b/src/test/java/itest/RecordingWorkflowTest.java @@ -192,7 +192,6 @@ public void testWorkflow() throws Exception { Matchers.matchesRegex( TARGET_ALIAS + "_" + TEST_RECORDING_NAME + "_[\\d]{8}T[\\d]{6}Z.jfr")); String savedDownloadUrl = recordingInfo.getString("downloadUrl"); - Thread.sleep(3_000L); // wait for the dump to complete // verify the in-memory recording list has not changed, except recording is now stopped @@ -250,6 +249,7 @@ public void testWorkflow() throws Exception { MatcherAssert.assertThat( reportResponse.statusCode(), Matchers.both(Matchers.greaterThanOrEqualTo(200)).and(Matchers.lessThan(300))); + MatcherAssert.assertThat(reportResponse.getHeader("Location"), Matchers.notNullValue()); MatcherAssert.assertThat(reportResponse.bodyAsString(), Matchers.notNullValue()); // Check that report generation concludes