-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hotfix][Zeta] Fix zeta scheduler bug #6050
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
13d03a0
Fix zeta scheduler bug
EricJoy2048 2b9e82f
Update seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-bas…
EricJoy2048 5b8f4d0
improve state change
EricJoy2048 ca47855
Merge branch '163_fix_zeta_scheduler_bug' of https://github.com/EricJ…
EricJoy2048 499f464
add comment to code
EricJoy2048 02e0d96
Update seatunnel-engine/seatunnel-engine-server/src/main/java/org/apa…
EricJoy2048 9673438
Add zeta starter test
EricJoy2048 f246365
Merge branch '163_fix_zeta_scheduler_bug' of https://github.com/EricJ…
EricJoy2048 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/JobClientJobProxyIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.seatunnel.engine.e2e; | ||
|
||
import org.apache.seatunnel.e2e.common.util.ContainerUtil; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.testcontainers.containers.Container; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.output.Slf4jLogConsumer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.DockerLoggerFactory; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
|
||
import static org.apache.seatunnel.e2e.common.util.ContainerUtil.PROJECT_ROOT_PATH; | ||
|
||
public class JobClientJobProxyIT extends SeaTunnelContainer { | ||
private static final String JDK_DOCKER_IMAGE = "openjdk:8"; | ||
private static final String SERVER_SHELL = "seatunnel-cluster.sh"; | ||
|
||
@Override | ||
@BeforeAll | ||
public void startUp() throws Exception { | ||
this.server = | ||
new GenericContainer<>(getDockerImage()) | ||
.withNetwork(NETWORK) | ||
.withCommand( | ||
ContainerUtil.adaptPathForWin( | ||
Paths.get(SEATUNNEL_HOME, "bin", SERVER_SHELL).toString())) | ||
.withNetworkAliases("server") | ||
.withExposedPorts() | ||
.withLogConsumer( | ||
new Slf4jLogConsumer( | ||
DockerLoggerFactory.getLogger( | ||
"seatunnel-engine:" + JDK_DOCKER_IMAGE))) | ||
.waitingFor(Wait.forListeningPort()); | ||
copySeaTunnelStarterToContainer(server); | ||
server.setExposedPorts(Arrays.asList(5801)); | ||
server.withCopyFileToContainer( | ||
MountableFile.forHostPath( | ||
PROJECT_ROOT_PATH | ||
+ "/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/"), | ||
Paths.get(SEATUNNEL_HOME, "config").toString()); | ||
|
||
// use seatunnel_fixed_slot_num.yaml replace seatunnel.yaml in container | ||
server.withCopyFileToContainer( | ||
MountableFile.forHostPath( | ||
PROJECT_ROOT_PATH | ||
+ "/seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/seatunnel_fixed_slot_num.yaml"), | ||
Paths.get(SEATUNNEL_HOME, "config/seatunnel.yaml").toString()); | ||
|
||
server.withCopyFileToContainer( | ||
MountableFile.forHostPath( | ||
PROJECT_ROOT_PATH | ||
+ "/seatunnel-shade/seatunnel-hadoop3-3.1.4-uber/target/seatunnel-hadoop3-3.1.4-uber.jar"), | ||
Paths.get(SEATUNNEL_HOME, "lib/seatunnel-hadoop3-3.1.4-uber.jar").toString()); | ||
server.start(); | ||
// execute extra commands | ||
executeExtraCommands(server); | ||
} | ||
|
||
@Test | ||
public void testJobFailedWillThrowException() throws IOException, InterruptedException { | ||
Container.ExecResult execResult = executeSeaTunnelJob("/batch_slot_not_enough.conf"); | ||
Assertions.assertNotEquals(0, execResult.getExitCode()); | ||
Assertions.assertTrue( | ||
StringUtils.isNotBlank(execResult.getStderr()) | ||
&& execResult | ||
.getStderr() | ||
.contains( | ||
"org.apache.seatunnel.engine.server.resourcemanager.NoEnoughResourceException: can't apply resource request")); | ||
} | ||
} |
145 changes: 145 additions & 0 deletions
145
...tor-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SeaTunnelSlotIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.seatunnel.engine.e2e; | ||
|
||
import org.apache.seatunnel.common.config.Common; | ||
import org.apache.seatunnel.common.config.DeployMode; | ||
import org.apache.seatunnel.engine.client.SeaTunnelClient; | ||
import org.apache.seatunnel.engine.client.job.ClientJobExecutionEnvironment; | ||
import org.apache.seatunnel.engine.client.job.ClientJobProxy; | ||
import org.apache.seatunnel.engine.common.config.ConfigProvider; | ||
import org.apache.seatunnel.engine.common.config.JobConfig; | ||
import org.apache.seatunnel.engine.common.config.SeaTunnelConfig; | ||
import org.apache.seatunnel.engine.core.job.JobStatus; | ||
import org.apache.seatunnel.engine.server.SeaTunnelServerStarter; | ||
|
||
import org.awaitility.Awaitility; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.hazelcast.client.config.ClientConfig; | ||
import com.hazelcast.instance.impl.HazelcastInstanceImpl; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class SeaTunnelSlotIT { | ||
@Test | ||
public void testSlotNotEnough() throws Exception { | ||
HazelcastInstanceImpl node1 = null; | ||
SeaTunnelClient engineClient = null; | ||
|
||
try { | ||
String testClusterName = "testSlotNotEnough"; | ||
SeaTunnelConfig seaTunnelConfig = ConfigProvider.locateAndGetSeaTunnelConfig(); | ||
seaTunnelConfig.getHazelcastConfig().setClusterName(testClusterName); | ||
// slot num is 3 | ||
seaTunnelConfig.getEngineConfig().getSlotServiceConfig().setDynamicSlot(false); | ||
seaTunnelConfig.getEngineConfig().getSlotServiceConfig().setSlotNum(3); | ||
|
||
node1 = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig); | ||
|
||
// client config | ||
Common.setDeployMode(DeployMode.CLIENT); | ||
String filePath = TestUtils.getResource("batch_slot_not_enough.conf"); | ||
JobConfig jobConfig = new JobConfig(); | ||
jobConfig.setName(testClusterName); | ||
|
||
ClientConfig clientConfig = ConfigProvider.locateAndGetClientConfig(); | ||
clientConfig.setClusterName(testClusterName); | ||
engineClient = new SeaTunnelClient(clientConfig); | ||
ClientJobExecutionEnvironment jobExecutionEnv = | ||
engineClient.createExecutionContext(filePath, jobConfig, seaTunnelConfig); | ||
|
||
final ClientJobProxy clientJobProxy = jobExecutionEnv.execute(); | ||
CompletableFuture<JobStatus> objectCompletableFuture = | ||
CompletableFuture.supplyAsync(clientJobProxy::waitForJobComplete); | ||
Awaitility.await() | ||
.atMost(600000, TimeUnit.MILLISECONDS) | ||
.untilAsserted( | ||
() -> { | ||
Thread.sleep(2000); | ||
Assertions.assertTrue( | ||
objectCompletableFuture.isDone() | ||
&& JobStatus.FAILED.equals( | ||
objectCompletableFuture.get())); | ||
}); | ||
|
||
} finally { | ||
if (engineClient != null) { | ||
engineClient.shutdown(); | ||
} | ||
|
||
if (node1 != null) { | ||
node1.shutdown(); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testSlotEnough() throws Exception { | ||
HazelcastInstanceImpl node1 = null; | ||
SeaTunnelClient engineClient = null; | ||
|
||
try { | ||
String testClusterName = "testSlotEnough"; | ||
SeaTunnelConfig seaTunnelConfig = ConfigProvider.locateAndGetSeaTunnelConfig(); | ||
seaTunnelConfig.getHazelcastConfig().setClusterName(testClusterName); | ||
// slot num is 10 | ||
seaTunnelConfig.getEngineConfig().getSlotServiceConfig().setDynamicSlot(false); | ||
seaTunnelConfig.getEngineConfig().getSlotServiceConfig().setSlotNum(10); | ||
|
||
node1 = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig); | ||
|
||
// client config | ||
Common.setDeployMode(DeployMode.CLIENT); | ||
String filePath = TestUtils.getResource("batch_slot_not_enough.conf"); | ||
JobConfig jobConfig = new JobConfig(); | ||
jobConfig.setName(testClusterName); | ||
|
||
ClientConfig clientConfig = ConfigProvider.locateAndGetClientConfig(); | ||
clientConfig.setClusterName(testClusterName); | ||
engineClient = new SeaTunnelClient(clientConfig); | ||
ClientJobExecutionEnvironment jobExecutionEnv = | ||
engineClient.createExecutionContext(filePath, jobConfig, seaTunnelConfig); | ||
|
||
final ClientJobProxy clientJobProxy = jobExecutionEnv.execute(); | ||
CompletableFuture<JobStatus> objectCompletableFuture = | ||
CompletableFuture.supplyAsync(clientJobProxy::waitForJobComplete); | ||
Awaitility.await() | ||
.atMost(600000, TimeUnit.MILLISECONDS) | ||
.untilAsserted( | ||
() -> { | ||
Thread.sleep(2000); | ||
Assertions.assertTrue( | ||
objectCompletableFuture.isDone() | ||
&& JobStatus.FINISHED.equals( | ||
objectCompletableFuture.get())); | ||
}); | ||
|
||
} finally { | ||
if (engineClient != null) { | ||
engineClient.shutdown(); | ||
} | ||
|
||
if (node1 != null) { | ||
node1.shutdown(); | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...nel-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/batch_slot_not_enough.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
###### | ||
###### This config file is a demonstration of streaming processing in seatunnel config | ||
###### | ||
|
||
env { | ||
# You can set engine configuration here | ||
job.mode = "BATCH" | ||
#execution.checkpoint.data-uri = "hdfs://localhost:9000/checkpoint" | ||
} | ||
|
||
source { | ||
# This is a example source plugin **only for test and demonstrate the feature source plugin** | ||
FakeSource { | ||
result_table_name = "fake" | ||
parallelism = 4 | ||
schema = { | ||
fields { | ||
name = "string" | ||
age = "int" | ||
} | ||
} | ||
} | ||
} | ||
|
||
transform { | ||
} | ||
|
||
sink { | ||
console { | ||
source_table_name="fake" | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...-engine-e2e/connector-seatunnel-e2e-base/src/test/resources/seatunnel_fixed_slot_num.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
seatunnel: | ||
engine: | ||
history-job-expire-minutes: 1 | ||
backup-count: 2 | ||
queue-type: blockingqueue | ||
print-execution-info-interval: 10 | ||
slot-service: | ||
dynamic-slot: false | ||
slot-num: 3 | ||
checkpoint: | ||
interval: 300000 | ||
timeout: 100000 | ||
storage: | ||
type: localfile | ||
max-retained: 3 | ||
plugin-config: | ||
namespace: /tmp/seatunnel/checkpoint_snapshot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If client never throw exception even job failed. The shell status code always return 0, does not meet shell standards. Also client side will not get job result error msg. We need test case to cover it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I have added test cases.