|
15 | 15 | */
|
16 | 16 | package com.datasqrl;
|
17 | 17 |
|
| 18 | +import static java.util.concurrent.TimeUnit.SECONDS; |
18 | 19 | import static org.assertj.core.api.Assertions.assertThat;
|
19 |
| -import static org.assertj.core.api.Assertions.assertThatNoException; |
| 20 | +import static org.junit.jupiter.api.Assertions.fail; |
20 | 21 |
|
21 |
| -import com.nextbreakpoint.flinkclient.model.JarRunResponseBody; |
22 |
| -import com.nextbreakpoint.flinkclient.model.JarUploadResponseBody; |
23 |
| -import com.nextbreakpoint.flinkclient.model.JarUploadResponseBody.StatusEnum; |
| 22 | +import com.nextbreakpoint.flink.client.model.JarRunResponseBody; |
| 23 | +import com.nextbreakpoint.flink.client.model.JobExceptionsInfoWithHistory; |
| 24 | +import com.nextbreakpoint.flink.client.model.JobStatus; |
| 25 | +import com.nextbreakpoint.flink.client.model.TerminationMode; |
| 26 | +import com.nextbreakpoint.flink.client.model.UploadStatus; |
24 | 27 | import java.io.File;
|
25 | 28 | import java.util.ArrayList;
|
26 | 29 | import java.util.Arrays;
|
27 | 30 | import java.util.List;
|
28 | 31 | import java.util.stream.Collectors;
|
29 | 32 | import java.util.stream.Stream;
|
30 | 33 | import lombok.SneakyThrows;
|
| 34 | +import org.apache.flink.shaded.curator5.com.google.common.base.Objects; |
31 | 35 | import org.apache.flink.shaded.curator5.com.google.common.collect.Lists;
|
32 | 36 | import org.junit.jupiter.params.ParameterizedTest;
|
33 | 37 | import org.junit.jupiter.params.provider.Arguments;
|
@@ -79,34 +83,42 @@ void givenPlansScript_whenExecuting_thenSuccess(String filename, boolean config)
|
79 | 83 | }
|
80 | 84 |
|
81 | 85 | @SneakyThrows
|
82 |
| - void execute(String... arguments) { |
83 |
| - File jarFile = new File("target/flink-jar-runner.uber.jar"); |
| 86 | + JarRunResponseBody execute(String... arguments) { |
| 87 | + var jarFile = new File("target/flink-jar-runner.uber.jar"); |
84 | 88 |
|
85 |
| - JarUploadResponseBody uploadResponse = client.uploadJar(jarFile); |
| 89 | + var uploadResponse = client.uploadJar(jarFile); |
86 | 90 |
|
87 |
| - assertThat(uploadResponse.getStatus()).isEqualTo(StatusEnum.SUCCESS); |
| 91 | + assertThat(uploadResponse.getStatus()).isEqualTo(UploadStatus.SUCCESS); |
88 | 92 |
|
89 | 93 | // Step 2: Extract jarId from the response
|
90 | 94 | String jarId =
|
91 | 95 | uploadResponse.getFilename().substring(uploadResponse.getFilename().lastIndexOf("/") + 1);
|
92 | 96 |
|
93 | 97 | // Step 3: Submit the job
|
94 |
| - assertThatNoException() |
95 |
| - .as("Running script %s", Arrays.toString(arguments)) |
96 |
| - .isThrownBy( |
97 |
| - () -> { |
98 |
| - JarRunResponseBody jobResponse = |
99 |
| - client.runJar( |
100 |
| - jarId, |
101 |
| - null, |
102 |
| - null, |
103 |
| - null, |
104 |
| - Arrays.stream(arguments).collect(Collectors.joining(",")), |
105 |
| - null, |
106 |
| - 1); |
107 |
| - String jobId = jobResponse.getJobid(); |
108 |
| - assertThat(jobId).isNotNull(); |
109 |
| - }); |
| 98 | + var jobResponse = |
| 99 | + client.submitJobFromJar( |
| 100 | + jarId, |
| 101 | + null, |
| 102 | + null, |
| 103 | + null, |
| 104 | + null, |
| 105 | + Arrays.stream(arguments).collect(Collectors.joining(",")), |
| 106 | + null, |
| 107 | + 1); |
| 108 | + String jobId = jobResponse.getJobid(); |
| 109 | + assertThat(jobId).isNotNull(); |
| 110 | + |
| 111 | + SECONDS.sleep(10); |
| 112 | + |
| 113 | + var status = client.getJobStatusInfo(jobId); |
| 114 | + if (Objects.equal(status.getStatus(), JobStatus.RUNNING)) { |
| 115 | + client.cancelJob(jobId, TerminationMode.CANCEL); |
| 116 | + } else { |
| 117 | + JobExceptionsInfoWithHistory exceptions = client.getJobExceptions(jobId, 5, null); |
| 118 | + fail(exceptions.toString()); |
| 119 | + } |
| 120 | + |
| 121 | + return jobResponse; |
110 | 122 | }
|
111 | 123 |
|
112 | 124 | @ParameterizedTest(name = "{0}")
|
|
0 commit comments