Skip to content

Commit

Permalink
Move annotation e2e test cases to e2e module (#2339)
Browse files Browse the repository at this point in the history
* Move annotation e2e test cases to e2e module

* Refactor JobAnnotationBuilderTest

* Move SnapshotService e2e test to e2e module
  • Loading branch information
terrymanu authored Oct 30, 2023
1 parent cb2c0db commit 621cf95
Show file tree
Hide file tree
Showing 25 changed files with 109 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.shardingsphere.elasticjob.kernel.internal.annotation;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.fixture.job.AnnotationSimpleJob;
import org.apache.shardingsphere.elasticjob.kernel.internal.annotation.fixture.AnnotationJobFixture;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
Expand All @@ -31,7 +31,7 @@ class JobAnnotationBuilderTest {

@Test
void assertGenerateJobConfiguration() {
JobConfiguration jobConfig = JobAnnotationBuilder.generateJobConfiguration(AnnotationSimpleJob.class);
JobConfiguration jobConfig = JobAnnotationBuilder.generateJobConfiguration(AnnotationJobFixture.class);
assertThat(jobConfig.getJobName(), is("AnnotationSimpleJob"));
assertThat(jobConfig.getShardingTotalCount(), is(3));
assertThat(jobConfig.getShardingItemParameters(), is("0=a,1=b,2=c"));
Expand All @@ -50,5 +50,4 @@ void assertGenerateJobConfiguration() {
assertFalse(jobConfig.isDisabled());
assertFalse(jobConfig.isOverwrite());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.kernel.internal.annotation.fixture;

import lombok.Getter;
import org.apache.shardingsphere.elasticjob.annotation.ElasticJobConfiguration;
import org.apache.shardingsphere.elasticjob.annotation.ElasticJobProp;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;

@ElasticJobConfiguration(
jobName = "AnnotationSimpleJob",
description = "desc",
shardingTotalCount = 3,
shardingItemParameters = "0=a,1=b,2=c",
cron = "*/10 * * * * ?",
props = {
@ElasticJobProp(key = "print.title", value = "test title"),
@ElasticJobProp(key = "print.content", value = "test content")
})
@Getter
public class AnnotationJobFixture implements SimpleJob {

private volatile boolean completed;

@Override
public void execute(final ShardingContext shardingContext) {
completed = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.internal.annotation.integrate;
package org.apache.shardingsphere.elasticjob.test.e2e.annotation;

import lombok.AccessLevel;
import lombok.Getter;
Expand All @@ -37,7 +37,7 @@
import org.junit.jupiter.api.BeforeEach;

@Getter(AccessLevel.PROTECTED)
public abstract class BaseAnnotationTest {
public abstract class BaseAnnotationE2ETest {

private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(7181);

Expand All @@ -56,7 +56,7 @@ public abstract class BaseAnnotationTest {

private final String jobName;

protected BaseAnnotationTest(final TestType type, final ElasticJob elasticJob) {
protected BaseAnnotationE2ETest(final TestType type, final ElasticJob elasticJob) {
this.elasticJob = elasticJob;
jobConfiguration = JobAnnotationBuilder.generateJobConfiguration(elasticJob.getClass());
jobName = jobConfiguration.getJobName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.internal.annotation.integrate;
package org.apache.shardingsphere.elasticjob.test.e2e.annotation;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.infra.env.IpUtils;
import org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO;
import org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine;
import org.apache.shardingsphere.elasticjob.kernel.fixture.job.AnnotationUnShardingJob;
import org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO;
import org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.kernel.internal.server.ServerStatus;
import org.apache.shardingsphere.elasticjob.test.e2e.annotation.fixture.AnnotationUnShardingJob;
import org.awaitility.Awaitility;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -35,9 +36,9 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

class OneOffEnabledJobTest extends BaseAnnotationTest {
class OneOffEnabledJobE2ETest extends BaseAnnotationE2ETest {

OneOffEnabledJobTest() {
OneOffEnabledJobE2ETest() {
super(TestType.ONE_OFF, new AnnotationUnShardingJob());
}

Expand All @@ -57,7 +58,7 @@ void assertEnabledRegCenterInfo() {

@Test
void assertJobInit() {
Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(((AnnotationUnShardingJob) getElasticJob()).isCompleted(), is(true)));
Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> MatcherAssert.assertThat(((AnnotationUnShardingJob) getElasticJob()).isCompleted(), is(true)));
assertTrue(getREGISTRY_CENTER().isExisted("/" + getJobName() + "/sharding"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.internal.annotation.integrate;
package org.apache.shardingsphere.elasticjob.test.e2e.annotation;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.infra.env.IpUtils;
import org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO;
import org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine;
import org.apache.shardingsphere.elasticjob.kernel.fixture.job.AnnotationSimpleJob;
import org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO;
import org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.kernel.internal.server.ServerStatus;
import org.apache.shardingsphere.elasticjob.test.e2e.annotation.fixture.AnnotationSimpleJob;
import org.awaitility.Awaitility;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -35,9 +36,9 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

class ScheduleEnabledJobTest extends BaseAnnotationTest {
class ScheduleEnabledJobE2ETest extends BaseAnnotationE2ETest {

ScheduleEnabledJobTest() {
ScheduleEnabledJobE2ETest() {
super(TestType.SCHEDULE, new AnnotationSimpleJob());
}

Expand All @@ -59,7 +60,7 @@ void assertEnabledRegCenterInfo() {

@Test
void assertJobInit() {
Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> assertThat(((AnnotationSimpleJob) getElasticJob()).isCompleted(), is(true)));
Awaitility.await().atMost(1L, TimeUnit.MINUTES).untilAsserted(() -> MatcherAssert.assertThat(((AnnotationSimpleJob) getElasticJob()).isCompleted(), is(true)));
assertTrue(getREGISTRY_CENTER().isExisted("/" + getJobName() + "/sharding"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.fixture.job;
package org.apache.shardingsphere.elasticjob.test.e2e.annotation.fixture;

import lombok.Getter;
import org.apache.shardingsphere.elasticjob.annotation.ElasticJobConfiguration;
import org.apache.shardingsphere.elasticjob.annotation.ElasticJobProp;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;

@Getter
@ElasticJobConfiguration(
jobName = "AnnotationSimpleJob",
description = "desc",
Expand All @@ -34,6 +33,7 @@
@ElasticJobProp(key = "print.title", value = "test title"),
@ElasticJobProp(key = "print.content", value = "test content")
})
@Getter
public class AnnotationSimpleJob implements SimpleJob {

private volatile boolean completed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.kernel.fixture.job;
package org.apache.shardingsphere.elasticjob.test.e2e.annotation.fixture;

import lombok.Getter;
import org.apache.shardingsphere.elasticjob.annotation.ElasticJobConfiguration;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;

@ElasticJobConfiguration(jobName = "AnnotationUnShardingJob", description = "desc", shardingTotalCount = 1)
@Getter
@ElasticJobConfiguration(
jobName = "AnnotationUnShardingJob",
description = "desc",
shardingTotalCount = 1)
public final class AnnotationUnShardingJob implements SimpleJob {

private volatile boolean completed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e;
package org.apache.shardingsphere.elasticjob.test.e2e.raw;

import lombok.AccessLevel;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.disable;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.disable;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.infra.env.IpUtils;
Expand All @@ -24,8 +24,8 @@
import org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO;
import org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.kernel.internal.server.ServerStatus;
import org.apache.shardingsphere.elasticjob.test.e2e.BaseE2ETest;
import org.apache.shardingsphere.elasticjob.test.e2e.fixture.job.E2EFixtureJobImpl;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.BaseE2ETest;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job.E2EFixtureJobImpl;
import org.awaitility.Awaitility;
import org.hamcrest.core.IsNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.disable;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.disable;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.disable;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.disable;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.kernel.internal.server.ServerStatus;
import org.apache.shardingsphere.elasticjob.test.e2e.fixture.job.E2EFixtureJobImpl;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job.E2EFixtureJobImpl;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.enable;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.enable;

import org.apache.shardingsphere.elasticjob.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.infra.env.IpUtils;
import org.apache.shardingsphere.elasticjob.kernel.internal.config.JobConfigurationPOJO;
import org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine;
import org.apache.shardingsphere.elasticjob.kernel.api.bootstrap.impl.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.test.e2e.BaseE2ETest;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.BaseE2ETest;
import org.apache.shardingsphere.elasticjob.kernel.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.kernel.internal.server.ServerStatus;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.enable;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.enable;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.test.e2e.fixture.job.E2EFixtureJobImpl;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job.E2EFixtureJobImpl;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.enable;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.enable;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.test.e2e.fixture.job.E2EFixtureJobImpl;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job.E2EFixtureJobImpl;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.fixture.executor;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.executor;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.spi.param.JobRuntimeService;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;
import org.apache.shardingsphere.elasticjob.spi.type.ClassedJobItemExecutor;
import org.apache.shardingsphere.elasticjob.test.e2e.fixture.job.E2EFixtureJob;
import org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job.E2EFixtureJob;

public final class E2EFixtureJobExecutor implements ClassedJobItemExecutor<E2EFixtureJob> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.fixture.job;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job;

import org.apache.shardingsphere.elasticjob.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.fixture.job;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.job;

import lombok.Getter;
import org.apache.shardingsphere.elasticjob.spi.param.ShardingContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.fixture.listener;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.listener;

import org.apache.shardingsphere.elasticjob.infra.listener.ShardingContexts;
import org.apache.shardingsphere.elasticjob.kernel.api.listener.AbstractDistributeOnceElasticJobListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.elasticjob.test.e2e.fixture.listener;
package org.apache.shardingsphere.elasticjob.test.e2e.raw.fixture.listener;

import org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener;
import org.apache.shardingsphere.elasticjob.infra.listener.ShardingContexts;
Expand Down
Loading

0 comments on commit 621cf95

Please sign in to comment.