Search in sources :

Example 1 with FileMetas

use of io.kestra.core.models.storage.FileMetas in project kestra by kestra-io.

the class ExecutionControllerTest method downloadFile.

@Test
void downloadFile() throws TimeoutException {
    Execution execution = runnerUtils.runOne(TESTS_FLOW_NS, "inputs", null, (flow, execution1) -> runnerUtils.typedInputs(flow, execution1, inputs));
    assertThat(execution.getTaskRunList(), hasSize(5));
    String path = (String) execution.getInputs().get("file");
    String file = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/executions/" + execution.getId() + "/file?path=" + path), String.class);
    assertThat(file, containsString("micronaut:"));
    FileMetas metas = client.retrieve(HttpRequest.GET("/api/v1/executions/" + execution.getId() + "/file/metas?path=" + path), FileMetas.class).blockingFirst();
    assertThat(metas.getSize(), equalTo(288L));
    String newExecutionId = IdUtils.create();
    HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> client.toBlocking().retrieve(HttpRequest.GET("/api/v1/executions/" + execution.getId() + "/file?path=" + path.replace(execution.getId(), newExecutionId)), String.class));
    // we redirect to good execution (that doesn't exist, so 404)
    assertThat(e.getStatus().getCode(), is(404));
    assertThat(e.getMessage(), containsString("execution id '" + newExecutionId + "'"));
}
Also used : Execution(io.kestra.core.models.executions.Execution) HttpClientResponseException(io.micronaut.http.client.exceptions.HttpClientResponseException) FileMetas(io.kestra.core.models.storage.FileMetas) InputsTest(io.kestra.core.runners.InputsTest) Test(org.junit.jupiter.api.Test) AbstractMemoryRunnerTest(io.kestra.core.runners.AbstractMemoryRunnerTest)

Aggregations

Execution (io.kestra.core.models.executions.Execution)1 FileMetas (io.kestra.core.models.storage.FileMetas)1 AbstractMemoryRunnerTest (io.kestra.core.runners.AbstractMemoryRunnerTest)1 InputsTest (io.kestra.core.runners.InputsTest)1 HttpClientResponseException (io.micronaut.http.client.exceptions.HttpClientResponseException)1 Test (org.junit.jupiter.api.Test)1