|
17 | 17 |
|
18 | 18 | package org.apache.seatunnel.engine.e2e;
|
19 | 19 |
|
20 |
| -import org.apache.seatunnel.e2e.common.util.ContainerUtil; |
21 |
| - |
22 | 20 | import org.apache.commons.lang3.StringUtils;
|
23 | 21 |
|
24 | 22 | import org.junit.jupiter.api.Assertions;
|
25 | 23 | import org.junit.jupiter.api.BeforeAll;
|
26 | 24 | import org.junit.jupiter.api.Test;
|
27 |
| -import org.testcontainers.DockerClientFactory; |
28 | 25 | import org.testcontainers.containers.Container;
|
29 |
| -import org.testcontainers.containers.GenericContainer; |
30 |
| -import org.testcontainers.containers.output.Slf4jLogConsumer; |
31 |
| -import org.testcontainers.containers.wait.strategy.Wait; |
32 |
| -import org.testcontainers.images.PullPolicy; |
33 |
| -import org.testcontainers.utility.DockerLoggerFactory; |
34 |
| -import org.testcontainers.utility.MountableFile; |
35 | 26 |
|
36 | 27 | import java.io.IOException;
|
37 |
| -import java.nio.file.Paths; |
38 |
| -import java.util.Arrays; |
39 |
| -import java.util.Collections; |
40 |
| -import java.util.stream.Collectors; |
41 | 28 |
|
42 | 29 | import static org.apache.seatunnel.e2e.common.util.ContainerUtil.PROJECT_ROOT_PATH;
|
43 | 30 |
|
44 | 31 | public class JobClientJobProxyIT extends SeaTunnelContainer {
|
45 |
| - private static final String JDK_DOCKER_IMAGE = "openjdk:8"; |
46 |
| - private static final String SERVER_SHELL = "seatunnel-cluster.sh"; |
47 | 32 |
|
48 | 33 | @Override
|
49 | 34 | @BeforeAll
|
50 | 35 | public void startUp() throws Exception {
|
| 36 | + // use seatunnel_fixed_slot_num.yaml replace seatunnel.yaml in container |
51 | 37 | this.server =
|
52 |
| - new GenericContainer<>(getDockerImage()) |
53 |
| - .withNetwork(NETWORK) |
54 |
| - .withCommand( |
55 |
| - ContainerUtil.adaptPathForWin( |
56 |
| - Paths.get(SEATUNNEL_HOME, "bin", SERVER_SHELL).toString())) |
57 |
| - .withNetworkAliases("server") |
58 |
| - .withImagePullPolicy(PullPolicy.alwaysPull()) |
59 |
| - .withExposedPorts() |
60 |
| - .withLogConsumer( |
61 |
| - new Slf4jLogConsumer( |
62 |
| - DockerLoggerFactory.getLogger( |
63 |
| - "seatunnel-engine:" + JDK_DOCKER_IMAGE))) |
64 |
| - .waitingFor(Wait.forListeningPort()); |
65 |
| - copySeaTunnelStarterToContainer(server); |
66 |
| - server.setExposedPorts(Arrays.asList(5801)); |
67 |
| - server.setPortBindings(Collections.singletonList("5801:5801")); |
68 |
| - server.withCopyFileToContainer( |
69 |
| - MountableFile.forHostPath( |
| 38 | + createSeaTunnelContainerWithFakeSourceAndInMemorySink( |
70 | 39 | PROJECT_ROOT_PATH
|
71 |
| - + "/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/"), |
72 |
| - Paths.get(SEATUNNEL_HOME, "config").toString()); |
| 40 | + + "/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/seatunnel_fixed_slot_num.yaml"); |
| 41 | + } |
73 | 42 |
|
74 |
| - // use seatunnel_fixed_slot_num.yaml replace seatunnel.yaml in container |
75 |
| - server.withCopyFileToContainer( |
76 |
| - MountableFile.forHostPath( |
77 |
| - PROJECT_ROOT_PATH |
78 |
| - + "/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/seatunnel_fixed_slot_num.yaml"), |
79 |
| - Paths.get(SEATUNNEL_HOME, "config/seatunnel.yaml").toString()); |
| 43 | + @Test |
| 44 | + public void testJobRetryTimes() throws IOException, InterruptedException { |
| 45 | + Container.ExecResult execResult = |
| 46 | + executeJob(server, "/retry-times/stream_fake_to_inmemory_with_error_retry_1.conf"); |
| 47 | + Assertions.assertNotEquals(0, execResult.getExitCode()); |
| 48 | + Assertions.assertTrue(server.getLogs().contains("Restore time 1, pipeline")); |
| 49 | + Assertions.assertFalse(server.getLogs().contains("Restore time 3, pipeline")); |
80 | 50 |
|
81 |
| - server.withCopyFileToContainer( |
82 |
| - MountableFile.forHostPath( |
83 |
| - PROJECT_ROOT_PATH |
84 |
| - + "/seatunnel-shade/seatunnel-hadoop3-3.1.4-uber/target/seatunnel-hadoop3-3.1.4-uber.jar"), |
85 |
| - Paths.get(SEATUNNEL_HOME, "lib/seatunnel-hadoop3-3.1.4-uber.jar").toString()); |
86 |
| - LOG.info( |
87 |
| - "find images: " |
88 |
| - + DockerClientFactory.lazyClient().listImagesCmd().exec().stream() |
89 |
| - .map( |
90 |
| - image -> { |
91 |
| - if (image.getRepoTags() != null) { |
92 |
| - return image.getRepoTags()[0]; |
93 |
| - } else { |
94 |
| - return image.getRepoDigests()[0]; |
95 |
| - } |
96 |
| - }) |
97 |
| - .collect(Collectors.joining(","))); |
98 |
| - server.start(); |
99 |
| - // execute extra commands |
100 |
| - executeExtraCommands(server); |
| 51 | + Container.ExecResult execResult2 = |
| 52 | + executeJob(server, "/retry-times/stream_fake_to_inmemory_with_error.conf"); |
| 53 | + Assertions.assertNotEquals(0, execResult2.getExitCode()); |
| 54 | + Assertions.assertTrue(server.getLogs().contains("Restore time 3, pipeline")); |
101 | 55 | }
|
102 | 56 |
|
103 | 57 | @Test
|
|
0 commit comments