You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/01 13:48:38 UTC
[shardingsphere-elasticjob-lite] branch master updated: Dev (#882)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-lite.git
The following commit(s) were added to refs/heads/master by this push:
new 729522f Dev (#882)
729522f is described below
commit 729522f9d6f9d7422c9e269120ac8a2535c5bbef
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Jul 1 21:48:28 2020 +0800
Dev (#882)
* Remove WaitingUtils
* Refactor AbstractBaseStdJobTest
* Add BaseMonitorServiceTest
* rename AbstractBaseStdJobAutoScheduleTest
* rename AbstractBaseStdJobTest
* rename BaseIntegrateTest
* rename EnabledJobIntegrateTest
* rename DisabledJobIntegrateTest
* move package for integrate test
* Add integrate test cases for OneOffJobBootstrap
---
.../lite/api/bootstrap/JobBootstrap.java | 5 +
.../lite/api/bootstrap/OneOffJobBootstrap.java | 6 +-
.../lite/api/bootstrap/ScheduleJobBootstrap.java | 4 +-
...tBaseStdJobTest.java => BaseIntegrateTest.java} | 137 +++++++++------------
...dJobTest.java => DisabledJobIntegrateTest.java} | 14 +--
...oInitTest.java => EnabledJobIntegrateTest.java} | 14 +--
.../oneoff/OneOffDisabledJobIntegrateTest.java} | 29 ++---
.../ScheduleDisabledJobIntegrateTest.java} | 24 ++--
.../dataflow/OneOffDataflowElasticJobTest.java | 23 ++--
...ingDataflowElasticJobForExecuteFailureTest.java | 21 ++--
...lowElasticJobForExecuteThrowsExceptionTest.java | 21 ++--
...ngDataflowElasticJobForMultipleThreadsTest.java | 21 ++--
...reamingDataflowElasticJobForNotMonitorTest.java | 24 ++--
.../dataflow/StreamingDataflowElasticJobTest.java | 21 ++--
.../oneoff}/script/ScriptElasticJobTest.java | 23 ++--
.../oneoff}/simple/SimpleElasticJobTest.java | 22 ++--
.../dataflow/OneOffDataflowElasticJobTest.java | 23 ++--
...ingDataflowElasticJobForExecuteFailureTest.java | 21 ++--
...lowElasticJobForExecuteThrowsExceptionTest.java | 21 ++--
...ngDataflowElasticJobForMultipleThreadsTest.java | 21 ++--
...reamingDataflowElasticJobForNotMonitorTest.java | 24 ++--
.../dataflow/StreamingDataflowElasticJobTest.java | 21 ++--
.../schedule}/script/ScriptElasticJobTest.java | 23 ++--
.../schedule}/simple/SimpleElasticJobTest.java | 22 ++--
.../internal/monitor/BaseMonitorServiceTest.java | 77 ++++++++++++
.../monitor/MonitorServiceDisableTest.java | 7 +-
.../internal/monitor/MonitorServiceEnableTest.java | 7 +-
27 files changed, 388 insertions(+), 288 deletions(-)
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java
index 5784351..3010737 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/JobBootstrap.java
@@ -150,6 +150,11 @@ public abstract class JobBootstrap {
return result;
}
+ /**
+ * Schedule job.
+ */
+ public abstract void schedule();
+
/**
* Shutdown job.
*/
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java
index 08ce449..12fb1df 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/OneOffJobBootstrap.java
@@ -37,10 +37,8 @@ public final class OneOffJobBootstrap extends JobBootstrap {
super(regCenter, elasticJob, jobConfig, tracingConfig, elasticJobListeners);
}
- /**
- * Execute job.
- */
- public void execute() {
+ @Override
+ public void schedule() {
createJobScheduleController().executeJob();
}
}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java
index d903daa..9e8df28 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/bootstrap/ScheduleJobBootstrap.java
@@ -39,9 +39,7 @@ public final class ScheduleJobBootstrap extends JobBootstrap {
super(regCenter, elasticJob, jobConfig, tracingConfig, elasticJobListeners);
}
- /**
- * Schedule job.
- */
+ @Override
public void schedule() {
Preconditions.checkArgument(!Strings.isNullOrEmpty(getJobConfig().getCron()), "Cron can not be empty.");
createJobScheduleController().scheduleJob(getJobConfig().getCron());
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java
similarity index 57%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java
index 7653a88..6d4425a 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/BaseIntegrateTest.java
@@ -19,23 +19,17 @@ package org.apache.shardingsphere.elasticjob.lite.integrate;
import lombok.AccessLevel;
import lombok.Getter;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.JobBootstrap;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.OneOffJobBootstrap;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
-import org.apache.shardingsphere.elasticjob.lite.api.dataflow.DataflowJob;
import org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener;
import org.apache.shardingsphere.elasticjob.lite.api.listener.ElasticJobListener;
-import org.apache.shardingsphere.elasticjob.lite.api.script.ScriptJob;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration.Builder;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.fixture.EmbedTestingServer;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.internal.election.LeaderService;
-import org.apache.shardingsphere.elasticjob.lite.internal.monitor.MonitorService;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.lite.internal.server.ServerStatus;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
@@ -50,91 +44,44 @@ import org.junit.Before;
import org.junit.BeforeClass;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public abstract class AbstractBaseStdJobTest {
-
- protected static final int MONITOR_PORT = 9000;
+public abstract class BaseIntegrateTest {
private static ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), "zkRegTestCenter");
@Getter(value = AccessLevel.PROTECTED)
private static CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(zkConfig);
-
- @Getter(value = AccessLevel.PROTECTED)
- private static MonitorService monitorService = new MonitorService(regCenter, MONITOR_PORT);
@Getter(AccessLevel.PROTECTED)
private final JobConfiguration jobConfiguration;
- private final ScheduleJobBootstrap scheduleJobBootstrap;
-
- private final boolean disabled;
+ private final JobBootstrap bootstrap;
private final LeaderService leaderService;
@Getter(AccessLevel.PROTECTED)
private final String jobName = System.nanoTime() + "_test_job";
- @SneakyThrows
- protected AbstractBaseStdJobTest(final Class<? extends ElasticJob> elasticJobClass, final boolean disabled) {
- this.disabled = disabled;
- jobConfiguration = initJobConfig(elasticJobClass);
- scheduleJobBootstrap = new ScheduleJobBootstrap(regCenter, ScriptJob.class == elasticJobClass ? null : elasticJobClass.newInstance(), jobConfiguration, new ElasticJobListener() {
-
- @Override
- public void beforeJobExecuted(final ShardingContexts shardingContexts) {
- regCenter.persist("/" + jobName + "/listener/every", "test");
- }
-
- @Override
- public void afterJobExecuted(final ShardingContexts shardingContexts) {
- }
- }, new AbstractDistributeOnceElasticJobListener(-1L, -1L) {
-
- @Override
- public void doBeforeJobExecutedAtLastStarted(final ShardingContexts shardingContexts) {
- regCenter.persist("/" + jobName + "/listener/once", "test");
- }
-
- @Override
- public void doAfterJobExecutedAtLastCompleted(final ShardingContexts shardingContexts) {
- }
- });
- leaderService = new LeaderService(regCenter, jobName);
- }
-
- @SneakyThrows
- protected AbstractBaseStdJobTest(final Class<? extends ElasticJob> elasticJobClass) {
- jobConfiguration = initJobConfig(elasticJobClass);
- scheduleJobBootstrap = new ScheduleJobBootstrap(regCenter, elasticJobClass.newInstance(), jobConfiguration);
- disabled = false;
+ protected BaseIntegrateTest(final TestType type, final ElasticJob elasticJob) {
+ jobConfiguration = getJobConfiguration(elasticJob, jobName);
+ bootstrap = createJobBootstrap(type, elasticJob);
leaderService = new LeaderService(regCenter, jobName);
}
- private JobConfiguration initJobConfig(final Class<? extends ElasticJob> elasticJobClass) {
- String cron = "0/1 * * * * ?";
- int totalShardingCount = 3;
- String shardingParameters = "0=A,1=B,2=C";
- Builder builder = JobConfiguration.newBuilder(jobName, getJobType(elasticJobClass), totalShardingCount).cron(cron).shardingItemParameters(shardingParameters)
- .jobErrorHandlerType("IGNORE").disabled(disabled).overwrite(true);
- if (DataflowJob.class.isAssignableFrom(elasticJobClass)) {
- builder.setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
- } else if (ScriptJob.class.isAssignableFrom(elasticJobClass)) {
- builder.setProperty(ScriptJobExecutor.SCRIPT_KEY, AbstractBaseStdJobTest.class.getResource("/script/test.sh").getPath());
- }
- return builder.build();
- }
+ protected abstract JobConfiguration getJobConfiguration(ElasticJob elasticJob, String jobName);
- private JobType getJobType(final Class<? extends ElasticJob> elasticJobClass) {
- if (DataflowJob.class.isAssignableFrom(elasticJobClass)) {
- return JobType.DATAFLOW;
- }
- if (ScriptJob.class.isAssignableFrom(elasticJobClass)) {
- return JobType.SCRIPT;
+ private JobBootstrap createJobBootstrap(final TestType type, final ElasticJob elasticJob) {
+ switch (type) {
+ case SCHEDULE:
+ return new ScheduleJobBootstrap(regCenter, elasticJob, jobConfiguration, new TestElasticJobListener(), new TestDistributeOnceElasticJobListener());
+ case ONE_OFF:
+ return new OneOffJobBootstrap(regCenter, elasticJob, jobConfiguration, new TestElasticJobListener(), new TestDistributeOnceElasticJobListener());
+ default:
+ throw new RuntimeException(String.format("Cannot support `%s`", type));
}
- return JobType.SIMPLE;
}
@BeforeClass
@@ -147,19 +94,16 @@ public abstract class AbstractBaseStdJobTest {
@Before
public void setUp() {
regCenter.init();
+ bootstrap.schedule();
}
@After
public void tearDown() {
- scheduleJobBootstrap.shutdown();
+ bootstrap.shutdown();
ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null);
}
- protected final void scheduleJob() {
- scheduleJobBootstrap.schedule();
- }
-
- final void assertRegCenterCommonInfoWithEnabled() {
+ protected final void assertRegCenterCommonInfoWithEnabled() {
assertRegCenterCommonInfo();
assertTrue(leaderService.isLeaderUntilBlock());
}
@@ -173,9 +117,13 @@ public abstract class AbstractBaseStdJobTest {
assertThat(JobRegistry.getInstance().getJobInstance(jobName).getIp(), is(IpUtils.getIp()));
JobConfiguration jobConfig = YamlEngine.unmarshal(regCenter.get("/" + jobName + "/config"), YamlJobConfiguration.class).toJobConfiguration();
assertThat(jobConfig.getShardingTotalCount(), is(3));
+ if (bootstrap instanceof ScheduleJobBootstrap) {
+ assertThat(jobConfig.getCron(), is("0/1 * * * * ?"));
+ } else {
+ assertNull(jobConfig.getCron());
+ }
assertThat(jobConfig.getShardingItemParameters(), is("0=A,1=B,2=C"));
- assertThat(jobConfig.getCron(), is("0/1 * * * * ?"));
- if (disabled) {
+ if (jobConfiguration.isDisabled()) {
assertThat(regCenter.get("/" + jobName + "/servers/" + JobRegistry.getInstance().getJobInstance(jobName).getIp()), is(ServerStatus.DISABLED.name()));
while (null != regCenter.get("/" + jobName + "/leader/election/instance")) {
BlockUtils.waitingShortTime();
@@ -188,4 +136,37 @@ public abstract class AbstractBaseStdJobTest {
assertTrue(regCenter.isExisted("/" + jobName + "/instances/" + JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId()));
regCenter.remove("/" + jobName + "/leader/election");
}
+
+ public enum TestType {
+
+ SCHEDULE, ONE_OFF
+ }
+
+ private final class TestElasticJobListener implements ElasticJobListener {
+
+ @Override
+ public void beforeJobExecuted(final ShardingContexts shardingContexts) {
+ regCenter.persist("/" + jobName + "/listener/every", "test");
+ }
+
+ @Override
+ public void afterJobExecuted(final ShardingContexts shardingContexts) {
+ }
+ }
+
+ private final class TestDistributeOnceElasticJobListener extends AbstractDistributeOnceElasticJobListener {
+
+ private TestDistributeOnceElasticJobListener() {
+ super(-1L, -1L);
+ }
+
+ @Override
+ public void doBeforeJobExecutedAtLastStarted(final ShardingContexts shardingContexts) {
+ regCenter.persist("/" + jobName + "/listener/once", "test");
+ }
+
+ @Override
+ public void doAfterJobExecutedAtLastCompleted(final ShardingContexts shardingContexts) {
+ }
+ }
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/DisabledJobIntegrateTest.java
similarity index 76%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/DisabledJobIntegrateTest.java
index a8208c8..c71982b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/DisabledJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/DisabledJobIntegrateTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,18 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.simple;
+package org.apache.shardingsphere.elasticjob.lite.integrate;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.simple.FooSimpleElasticJob;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-public final class DisabledJobTest extends AbstractBaseStdJobTest {
+public abstract class DisabledJobIntegrateTest extends BaseIntegrateTest {
- public DisabledJobTest() {
- super(FooSimpleElasticJob.class, true);
+ public DisabledJobIntegrateTest(final TestType type) {
+ super(type, new FooSimpleElasticJob());
}
@Before
@@ -36,8 +35,7 @@ public final class DisabledJobTest extends AbstractBaseStdJobTest {
}
@Test
- public void assertJobInit() {
- scheduleJob();
+ public final void assertJobRunning() {
assertRegCenterCommonInfoWithDisabled();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java
similarity index 67%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java
index e58aa5e..c3592e0 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/EnabledJobIntegrateTest.java
@@ -18,22 +18,16 @@
package org.apache.shardingsphere.elasticjob.lite.integrate;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.junit.Before;
-public abstract class AbstractBaseStdJobAutoInitTest extends AbstractBaseStdJobTest {
+public abstract class EnabledJobIntegrateTest extends BaseIntegrateTest {
- protected AbstractBaseStdJobAutoInitTest(final Class<? extends ElasticJob> elasticJobClass) {
- super(elasticJobClass, false);
- }
-
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
+ protected EnabledJobIntegrateTest(final TestType type, final ElasticJob elasticJob) {
+ super(type, elasticJob);
}
@Before
- public void autoJobInit() {
- setJobConfiguration(getJobConfiguration());
- scheduleJob();
+ public final void autoSchedule() {
assertRegCenterCommonInfoWithEnabled();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/WaitingUtils.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/disable/oneoff/OneOffDisabledJobIntegrateTest.java
similarity index 50%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/WaitingUtils.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/disable/oneoff/OneOffDisabledJobIntegrateTest.java
index f5a985f..ce650e1 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/WaitingUtils.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/disable/oneoff/OneOffDisabledJobIntegrateTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,26 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.disable.oneoff;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.integrate.DisabledJobIntegrateTest;
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class WaitingUtils {
+public final class OneOffDisabledJobIntegrateTest extends DisabledJobIntegrateTest {
- /**
- * Wait for a short time.
- */
- public static void waitingShortTime() {
- sleep(300L);
+ public OneOffDisabledJobIntegrateTest() {
+ super(TestType.ONE_OFF);
}
- private static void sleep(final long millis) {
- try {
- Thread.sleep(millis);
- } catch (final InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
+ @Override
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.SIMPLE, 3).shardingItemParameters("0=A,1=B,2=C").disabled(true).overwrite(true).build();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/disable/schedule/ScheduleDisabledJobIntegrateTest.java
similarity index 58%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/disable/schedule/ScheduleDisabledJobIntegrateTest.java
index e58aa5e..bb7433a 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobAutoInitTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/disable/schedule/ScheduleDisabledJobIntegrateTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,25 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.disable.schedule;
import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
-import org.junit.Before;
+import org.apache.shardingsphere.elasticjob.lite.integrate.DisabledJobIntegrateTest;
-public abstract class AbstractBaseStdJobAutoInitTest extends AbstractBaseStdJobTest {
-
- protected AbstractBaseStdJobAutoInitTest(final Class<? extends ElasticJob> elasticJobClass) {
- super(elasticJobClass, false);
- }
+public final class ScheduleDisabledJobIntegrateTest extends DisabledJobIntegrateTest {
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
+ public ScheduleDisabledJobIntegrateTest() {
+ super(TestType.SCHEDULE);
}
- @Before
- public void autoJobInit() {
- setJobConfiguration(getJobConfiguration());
- scheduleJob();
- assertRegCenterCommonInfoWithEnabled();
+ @Override
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.SIMPLE, 3).cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").disabled(true).overwrite(true).build();
}
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/OneOffDataflowElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/OneOffDataflowElasticJobTest.java
similarity index 62%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/OneOffDataflowElasticJobTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/OneOffDataflowElasticJobTest.java
index db78ed2..8b2858b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/OneOffDataflowElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/OneOffDataflowElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,24 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.OneOffDataflowElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class OneOffDataflowElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class OneOffDataflowElasticJobTest extends EnabledJobIntegrateTest {
public OneOffDataflowElasticJobTest() {
- super(OneOffDataflowElasticJob.class);
+ super(TestType.ONE_OFF, new OneOffDataflowElasticJob());
}
@Before
@@ -42,15 +43,15 @@ public final class OneOffDataflowElasticJobTest extends AbstractBaseStdJobAutoIn
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- ReflectionUtils.setFieldValue(jobConfig, "misfire", false);
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.FALSE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).shardingItemParameters("0=A,1=B,2=C").misfire(false).overwrite(true)
+ .setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.FALSE.toString()).build();
}
@Test
public void assertJobInit() {
while (!OneOffDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
similarity index 65%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
index facf3b1..95f9b26 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJobForExecuteFailure;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForExecuteFailureTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForExecuteFailureTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForExecuteFailureTest() {
- super(StreamingDataflowElasticJobForExecuteFailure.class);
+ super(TestType.ONE_OFF, new StreamingDataflowElasticJobForExecuteFailure());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobForExecuteFailureTest extends Abst
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3)
+ .shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJobForExecuteFailure.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
similarity index 65%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
index e75b142..9d0f3ef 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJobForExecuteThrowsException;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForExecuteThrowsExceptionTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForExecuteThrowsExceptionTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForExecuteThrowsExceptionTest() {
- super(StreamingDataflowElasticJobForExecuteThrowsException.class);
+ super(TestType.ONE_OFF, new StreamingDataflowElasticJobForExecuteThrowsException());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobForExecuteThrowsExceptionTest exte
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3)
+ .shardingItemParameters("0=A,1=B,2=C").jobErrorHandlerType("IGNORE").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJobForExecuteThrowsException.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
similarity index 65%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
index d943b6a..a4ed78d 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForMultipleThreadsTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForMultipleThreadsTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForMultipleThreadsTest() {
- super(StreamingDataflowElasticJob.class);
+ super(TestType.ONE_OFF, new StreamingDataflowElasticJob());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobForMultipleThreadsTest extends Abs
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3)
+ .shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
similarity index 64%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
index 1b4da28..dbb1448 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,24 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForNotMonitorTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForNotMonitorTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForNotMonitorTest() {
- super(StreamingDataflowElasticJob.class);
+ super(TestType.ONE_OFF, new StreamingDataflowElasticJob());
}
@Before
@@ -42,15 +43,16 @@ public final class StreamingDataflowElasticJobForNotMonitorTest extends Abstract
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- ReflectionUtils.setFieldValue(jobConfig, "monitorExecution", false);
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3)
+ .shardingItemParameters("0=A,1=B,2=C").monitorExecution(false).overwrite(true)
+ .setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobTest.java
similarity index 63%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobTest.java
index 8a842db..d27f329 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/dataflow/StreamingDataflowElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobTest() {
- super(StreamingDataflowElasticJob.class);
+ super(TestType.ONE_OFF, new StreamingDataflowElasticJob());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobTest extends AbstractBaseStdJobAut
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3)
+ .shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/script/ScriptElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java
similarity index 67%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/script/ScriptElasticJobTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java
index 1c77d82..f8a5f7f 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/script/ScriptElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/script/ScriptElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,15 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.script;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.script;
-import org.apache.shardingsphere.elasticjob.lite.api.script.ScriptJob;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.fixture.util.ScriptElasticJobUtil;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.apache.shardingsphere.elasticjob.lite.util.yaml.YamlEngine;
import org.junit.Test;
@@ -32,16 +33,22 @@ import java.io.IOException;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class ScriptElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class ScriptElasticJobTest extends EnabledJobIntegrateTest {
public ScriptElasticJobTest() {
- super(ScriptJob.class);
+ super(TestType.ONE_OFF, null);
+ }
+
+ @Override
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.SCRIPT, 3).shardingItemParameters("0=A,1=B,2=C").overwrite(true)
+ .setProperty(ScriptJobExecutor.SCRIPT_KEY, ScriptElasticJobTest.class.getResource("/script/test.sh").getPath()).build();
}
@Test
public void assertJobInit() throws IOException {
ScriptElasticJobUtil.buildScriptCommandLine();
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
String scriptCommandLine = getJobConfiguration().getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY);
JobConfiguration jobConfig = YamlEngine.unmarshal(getRegCenter().get("/" + getJobName() + "/config"), YamlJobConfiguration.class).toJobConfiguration();
assertThat(jobConfig.getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY), is(scriptCommandLine));
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/SimpleElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/simple/SimpleElasticJobTest.java
similarity index 60%
copy from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/SimpleElasticJobTest.java
copy to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/simple/SimpleElasticJobTest.java
index ed976fc..ff1a592 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/SimpleElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/oneoff/simple/SimpleElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,21 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.simple;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.oneoff.simple;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.simple.FooSimpleElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class SimpleElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class SimpleElasticJobTest extends EnabledJobIntegrateTest {
public SimpleElasticJobTest() {
- super(FooSimpleElasticJob.class);
+ super(TestType.ONE_OFF, new FooSimpleElasticJob());
}
@Before
@@ -38,10 +41,15 @@ public final class SimpleElasticJobTest extends AbstractBaseStdJobAutoInitTest {
FooSimpleElasticJob.reset();
}
+ @Override
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.SIMPLE, 3).shardingItemParameters("0=A,1=B,2=C").overwrite(true).build();
+ }
+
@Test
public void assertJobInit() {
while (!FooSimpleElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/OneOffDataflowElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/OneOffDataflowElasticJobTest.java
similarity index 62%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/OneOffDataflowElasticJobTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/OneOffDataflowElasticJobTest.java
index db78ed2..b1b807c 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/OneOffDataflowElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/OneOffDataflowElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,24 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.OneOffDataflowElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class OneOffDataflowElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class OneOffDataflowElasticJobTest extends EnabledJobIntegrateTest {
public OneOffDataflowElasticJobTest() {
- super(OneOffDataflowElasticJob.class);
+ super(TestType.SCHEDULE, new OneOffDataflowElasticJob());
}
@Before
@@ -42,15 +43,15 @@ public final class OneOffDataflowElasticJobTest extends AbstractBaseStdJobAutoIn
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- ReflectionUtils.setFieldValue(jobConfig, "misfire", false);
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.FALSE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").misfire(false).overwrite(true)
+ .setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.FALSE.toString()).build();
}
@Test
public void assertJobInit() {
while (!OneOffDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
similarity index 65%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
index facf3b1..e26096d 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForExecuteFailureTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJobForExecuteFailure;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForExecuteFailureTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForExecuteFailureTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForExecuteFailureTest() {
- super(StreamingDataflowElasticJobForExecuteFailure.class);
+ super(TestType.SCHEDULE, new StreamingDataflowElasticJobForExecuteFailure());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobForExecuteFailureTest extends Abst
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).cron("0/1 * * * * ?")
+ .shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJobForExecuteFailure.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
similarity index 64%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
index e75b142..1e0adbd 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForExecuteThrowsExceptionTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJobForExecuteThrowsException;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForExecuteThrowsExceptionTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForExecuteThrowsExceptionTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForExecuteThrowsExceptionTest() {
- super(StreamingDataflowElasticJobForExecuteThrowsException.class);
+ super(TestType.SCHEDULE, new StreamingDataflowElasticJobForExecuteThrowsException());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobForExecuteThrowsExceptionTest exte
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).cron("0/1 * * * * ?")
+ .shardingItemParameters("0=A,1=B,2=C").jobErrorHandlerType("IGNORE").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJobForExecuteThrowsException.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
similarity index 65%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
index d943b6a..61187a3 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForMultipleThreadsTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForMultipleThreadsTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForMultipleThreadsTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForMultipleThreadsTest() {
- super(StreamingDataflowElasticJob.class);
+ super(TestType.SCHEDULE, new StreamingDataflowElasticJob());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobForMultipleThreadsTest extends Abs
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).cron("0/1 * * * * ?")
+ .shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
similarity index 64%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
index 1b4da28..71f0653 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobForNotMonitorTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,24 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobForNotMonitorTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobForNotMonitorTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobForNotMonitorTest() {
- super(StreamingDataflowElasticJob.class);
+ super(TestType.SCHEDULE, new StreamingDataflowElasticJob());
}
@Before
@@ -42,15 +43,16 @@ public final class StreamingDataflowElasticJobForNotMonitorTest extends Abstract
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- ReflectionUtils.setFieldValue(jobConfig, "monitorExecution", false);
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).cron("0/1 * * * * ?")
+ .shardingItemParameters("0=A,1=B,2=C").monitorExecution(false).overwrite(true)
+ .setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobTest.java
similarity index 62%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobTest.java
index 8a842db..5f2c82b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/dataflow/StreamingDataflowElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/dataflow/StreamingDataflowElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,23 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.dataflow;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.dataflow;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.dataflow.StreamingDataflowElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class StreamingDataflowElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class StreamingDataflowElasticJobTest extends EnabledJobIntegrateTest {
public StreamingDataflowElasticJobTest() {
- super(StreamingDataflowElasticJob.class);
+ super(TestType.SCHEDULE, new StreamingDataflowElasticJob());
}
@Before
@@ -41,14 +43,15 @@ public final class StreamingDataflowElasticJobTest extends AbstractBaseStdJobAut
}
@Override
- protected void setJobConfiguration(final JobConfiguration jobConfig) {
- jobConfig.getProps().setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString());
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.DATAFLOW, 3).cron("0/1 * * * * ?")
+ .shardingItemParameters("0=A,1=B,2=C").overwrite(true).setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
}
@Test
public void assertJobInit() {
while (!StreamingDataflowElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/script/ScriptElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java
similarity index 66%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/script/ScriptElasticJobTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java
index 1c77d82..4ea39e3 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/script/ScriptElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/script/ScriptElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,15 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.script;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.script;
-import org.apache.shardingsphere.elasticjob.lite.api.script.ScriptJob;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.ScriptJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.fixture.util.ScriptElasticJobUtil;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.apache.shardingsphere.elasticjob.lite.util.yaml.YamlEngine;
import org.junit.Test;
@@ -32,16 +33,22 @@ import java.io.IOException;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class ScriptElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class ScriptElasticJobTest extends EnabledJobIntegrateTest {
public ScriptElasticJobTest() {
- super(ScriptJob.class);
+ super(TestType.SCHEDULE, null);
+ }
+
+ @Override
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.SCRIPT, 3).cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").overwrite(true)
+ .setProperty(ScriptJobExecutor.SCRIPT_KEY, ScriptElasticJobTest.class.getResource("/script/test.sh").getPath()).build();
}
@Test
public void assertJobInit() throws IOException {
ScriptElasticJobUtil.buildScriptCommandLine();
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
String scriptCommandLine = getJobConfiguration().getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY);
JobConfiguration jobConfig = YamlEngine.unmarshal(getRegCenter().get("/" + getJobName() + "/config"), YamlJobConfiguration.class).toJobConfiguration();
assertThat(jobConfig.getProps().getProperty(ScriptJobExecutor.SCRIPT_KEY), is(scriptCommandLine));
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/SimpleElasticJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/simple/SimpleElasticJobTest.java
similarity index 59%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/SimpleElasticJobTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/simple/SimpleElasticJobTest.java
index ed976fc..c9116d0 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/std/simple/SimpleElasticJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/assertion/enable/schedule/simple/SimpleElasticJobTest.java
@@ -7,7 +7,7 @@
* 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.
@@ -15,21 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.integrate.std.simple;
+package org.apache.shardingsphere.elasticjob.lite.integrate.assertion.enable.schedule.simple;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobAutoInitTest;
-import org.apache.shardingsphere.elasticjob.lite.integrate.WaitingUtils;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.integrate.EnabledJobIntegrateTest;
import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.simple.FooSimpleElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.util.concurrent.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-public final class SimpleElasticJobTest extends AbstractBaseStdJobAutoInitTest {
+public final class SimpleElasticJobTest extends EnabledJobIntegrateTest {
public SimpleElasticJobTest() {
- super(FooSimpleElasticJob.class);
+ super(TestType.SCHEDULE, new FooSimpleElasticJob());
}
@Before
@@ -38,10 +41,15 @@ public final class SimpleElasticJobTest extends AbstractBaseStdJobAutoInitTest {
FooSimpleElasticJob.reset();
}
+ @Override
+ protected JobConfiguration getJobConfiguration(final ElasticJob elasticJob, final String jobName) {
+ return JobConfiguration.newBuilder(jobName, JobType.SIMPLE, 3).cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").overwrite(true).build();
+ }
+
@Test
public void assertJobInit() {
while (!FooSimpleElasticJob.isCompleted()) {
- WaitingUtils.waitingShortTime();
+ BlockUtils.waitingShortTime();
}
assertTrue(getRegCenter().isExisted("/" + getJobName() + "/sharding"));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/BaseMonitorServiceTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/BaseMonitorServiceTest.java
new file mode 100644
index 0000000..f24be07
--- /dev/null
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/BaseMonitorServiceTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.shardingsphere.elasticjob.lite.internal.monitor;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.ScheduleJobBootstrap;
+import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.fixture.EmbedTestingServer;
+import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
+import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
+import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.reg.zookeeper.ZookeeperRegistryCenter;
+import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+public abstract class BaseMonitorServiceTest {
+
+ protected static final int MONITOR_PORT = 9000;
+
+ private static ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(EmbedTestingServer.getConnectionString(), "zkRegTestCenter");
+
+ private static CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(zkConfig);
+
+ @Getter(value = AccessLevel.PROTECTED)
+ private static MonitorService monitorService = new MonitorService(regCenter, MONITOR_PORT);
+
+ private final ScheduleJobBootstrap bootstrap;
+
+ @Getter(value = AccessLevel.PROTECTED)
+ private final String jobName = System.nanoTime() + "_test_job";
+
+ public BaseMonitorServiceTest(final ElasticJob elasticJob) {
+ bootstrap = new ScheduleJobBootstrap(regCenter, elasticJob, JobConfiguration.newBuilder(jobName, JobType.SIMPLE, 3).cron("0/1 * * * * ?").overwrite(true).build());
+ }
+
+ @BeforeClass
+ public static void init() {
+ EmbedTestingServer.start();
+ zkConfig.setConnectionTimeoutMilliseconds(30000);
+ regCenter.init();
+ }
+
+ @Before
+ public void setUp() {
+ regCenter.init();
+ }
+
+ @After
+ public void tearDown() {
+ bootstrap.shutdown();
+ ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null);
+ }
+
+ protected final void scheduleJob() {
+ bootstrap.schedule();
+ }
+}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceDisableTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceDisableTest.java
index 806920b..31037e1 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceDisableTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceDisableTest.java
@@ -17,16 +17,15 @@
package org.apache.shardingsphere.elasticjob.lite.internal.monitor;
-import org.apache.shardingsphere.elasticjob.lite.fixture.TestSimpleJob;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobTest;
+import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.simple.FooSimpleElasticJob;
import org.junit.Test;
import java.io.IOException;
-public final class MonitorServiceDisableTest extends AbstractBaseStdJobTest {
+public final class MonitorServiceDisableTest extends BaseMonitorServiceTest {
public MonitorServiceDisableTest() {
- super(TestSimpleJob.class);
+ super(new FooSimpleElasticJob());
}
@Test(expected = IOException.class)
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceEnableTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceEnableTest.java
index 42a6e90..142746b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceEnableTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/monitor/MonitorServiceEnableTest.java
@@ -17,8 +17,7 @@
package org.apache.shardingsphere.elasticjob.lite.internal.monitor;
-import org.apache.shardingsphere.elasticjob.lite.fixture.TestSimpleJob;
-import org.apache.shardingsphere.elasticjob.lite.integrate.AbstractBaseStdJobTest;
+import org.apache.shardingsphere.elasticjob.lite.integrate.fixture.simple.FooSimpleElasticJob;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -28,10 +27,10 @@ import java.io.IOException;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-public final class MonitorServiceEnableTest extends AbstractBaseStdJobTest {
+public final class MonitorServiceEnableTest extends BaseMonitorServiceTest {
public MonitorServiceEnableTest() {
- super(TestSimpleJob.class);
+ super(new FooSimpleElasticJob());
}
@Before