-
Notifications
You must be signed in to change notification settings - Fork 5k
[Fix-16617][Seatunnel] Use master option for engine deploy mode #18315
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * 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.dolphinscheduler.plugin.task.seatunnel.self; | ||
|
|
||
| import org.apache.dolphinscheduler.common.utils.JSONUtils; | ||
| import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; | ||
| import org.apache.dolphinscheduler.plugin.task.seatunnel.DeployModeEnum; | ||
|
|
||
| import org.apache.commons.io.FileUtils; | ||
|
|
||
| import java.lang.reflect.Field; | ||
|
|
||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.MockedStatic; | ||
| import org.mockito.Mockito; | ||
|
|
||
| public class SeatunnelEngineTaskTest { | ||
|
Check warning on line 35 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
|
|
||
| private static final String EXECUTE_PATH = "/tmp"; | ||
| private static final String TASK_ID = "1234"; | ||
| private static final String RAW_SCRIPT = | ||
| "env {\n job.mode = \"BATCH\"\n}\nsource {\n FakeSource {}\n}\nsink {\n Console {}\n}"; | ||
|
|
||
| private MockedStatic<FileUtils> mockedStaticFileUtils; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() { | ||
|
Check warning on line 45 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
| mockedStaticFileUtils = Mockito.mockStatic(FileUtils.class); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void after() { | ||
|
Check warning on line 50 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
| mockedStaticFileUtils.close(); | ||
| } | ||
|
|
||
| @Test | ||
| public void buildOptionsUsesMasterForDeployMode() throws Exception { | ||
|
Check warning on line 55 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
| SeatunnelEngineParameters seatunnelParameters = newSeatunnelEngineParameters(); | ||
| seatunnelParameters.setDeployMode(DeployModeEnum.cluster); | ||
|
|
||
| SeatunnelEngineTask task = newSeatunnelEngineTask(seatunnelParameters); | ||
|
|
||
| String command = String.join(" ", task.buildOptions()); | ||
| String expectedCommand = String.format("--config %s/seatunnel_%s.conf --master cluster", EXECUTE_PATH, TASK_ID); | ||
| Assertions.assertEquals(expectedCommand, command); | ||
| } | ||
|
|
||
| @Test | ||
| public void buildOptionsOmitsMasterWhenDeployModeMissing() throws Exception { | ||
|
Check warning on line 67 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
| SeatunnelEngineParameters seatunnelParameters = newSeatunnelEngineParameters(); | ||
|
|
||
| SeatunnelEngineTask task = newSeatunnelEngineTask(seatunnelParameters); | ||
|
|
||
| String command = String.join(" ", task.buildOptions()); | ||
| String expectedCommand = String.format("--config %s/seatunnel_%s.conf", EXECUTE_PATH, TASK_ID); | ||
| Assertions.assertEquals(expectedCommand, command); | ||
| } | ||
|
|
||
| @Test | ||
| public void buildOptionsAppendsOthersWhenPresent() throws Exception { | ||
|
Check warning on line 78 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
| SeatunnelEngineParameters seatunnelParameters = newSeatunnelEngineParameters(); | ||
| seatunnelParameters.setDeployMode(DeployModeEnum.local); | ||
| seatunnelParameters.setOthers("--name demo-job"); | ||
|
|
||
| SeatunnelEngineTask task = newSeatunnelEngineTask(seatunnelParameters); | ||
|
|
||
| String command = String.join(" ", task.buildOptions()); | ||
| String expectedCommand = | ||
| String.format("--config %s/seatunnel_%s.conf --master local --name demo-job", EXECUTE_PATH, TASK_ID); | ||
| Assertions.assertEquals(expectedCommand, command); | ||
| } | ||
|
|
||
| private SeatunnelEngineParameters newSeatunnelEngineParameters() { | ||
| SeatunnelEngineParameters seatunnelParameters = new SeatunnelEngineParameters(); | ||
| seatunnelParameters.setUseCustom(true); | ||
| seatunnelParameters.setRawScript(RAW_SCRIPT); | ||
| return seatunnelParameters; | ||
| } | ||
|
|
||
| private SeatunnelEngineTask newSeatunnelEngineTask(SeatunnelEngineParameters seatunnelParameters) throws Exception { | ||
| TaskExecutionContext taskExecutionContext = new TaskExecutionContext(); | ||
| taskExecutionContext.setExecutePath(EXECUTE_PATH); | ||
| taskExecutionContext.setTaskAppId(TASK_ID); | ||
|
Check warning on line 101 in dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/test/java/org/apache/dolphinscheduler/plugin/task/seatunnel/self/SeatunnelEngineTaskTest.java
|
||
| taskExecutionContext.setTaskParams(JSONUtils.toJsonString(seatunnelParameters)); | ||
|
|
||
| SeatunnelEngineTask task = new SeatunnelEngineTask(taskExecutionContext); | ||
| task.setSeatunnelParameters(seatunnelParameters); | ||
| setPrivateSeatunnelParameters(task, seatunnelParameters); | ||
| return task; | ||
| } | ||
|
|
||
| private void setPrivateSeatunnelParameters(SeatunnelEngineTask task, | ||
| SeatunnelEngineParameters seatunnelParameters) throws Exception { | ||
| Field field = SeatunnelEngineTask.class.getDeclaredField("seatunnelParameters"); | ||
| field.setAccessible(true); | ||
| field.set(task, seatunnelParameters); | ||
| } | ||
| } | ||
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.
You should remove
Constants.DEPLOY_MODE_OPTIONSsince it's useless.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.
Addressed in 935c4b6 by removing
Constants.DEPLOY_MODE_OPTIONSand inlining the Spark task--deploy-modeargument to preserve the existing Spark command behavior.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.
You remove the usage of
Constants.DEPLOY_MODE_OPTIONS. But it didn't modify its test and remove this constant.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.
Updated in the latest push:
Constants.DEPLOY_MODE_OPTIONSis removed, and the engine path is covered bySeatunnelEngineTaskTest.