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 2022/04/16 04:11:36 UTC
[shardingsphere] branch master updated: Add more unit test of scaling (#16854)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 51c51aefa70 Add more unit test of scaling (#16854)
51c51aefa70 is described below
commit 51c51aefa701bdf14d245f9b6aa6af9755b85077
Author: azexcy <10...@users.noreply.github.com>
AuthorDate: Sat Apr 16 12:11:22 2022 +0800
Add more unit test of scaling (#16854)
* Add ShardingRuleAlteredDetectorTest unit test
* Add more unit test for RuleAlteredJobPreparerTest and RuleAlteredJobWorkerTest
---
.../core/metadata/node/PipelineMetaDataNode.java | 50 +++++++++++++++
.../data/pipeline/core/util/ReflectionUtil.java | 5 +-
.../rulealtered/RuleAlteredJobPreparerTest.java | 22 +++++++
.../rulealtered/RuleAlteredJobWorkerTest.java | 62 ++++++++++++++++--
.../sharding/ShardingRuleAlteredDetectorTest.java | 61 +++++++++---------
.../scaling/detector/datasource_config.yaml | 32 ----------
.../scaling/detector/source_rule_config.yaml | 67 --------------------
.../scaling/detector/target_rule_config.yaml | 73 ----------------------
.../scaling/rule_alter/scaling_job_config.yaml | 26 ++++++++
9 files changed, 187 insertions(+), 211 deletions(-)
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNode.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNode.java
new file mode 100644
index 00000000000..d2be0ff20a7
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNode.java
@@ -0,0 +1,50 @@
+/*
+ * 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.data.pipeline.core.metadata.node;
+
+import com.google.common.base.Joiner;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Scaling meta data node.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PipelineMetaDataNode {
+
+ public static final String ROOT_NODE = "scaling";
+
+ /**
+ * Get job config path.
+ *
+ * @param jobId job id.
+ * @return job config path.
+ */
+ public static String getJobConfigPath(final String jobId) {
+ return Joiner.on("/").join(getScalingRootPath(), jobId, "config");
+ }
+
+ /**
+ * Get scaling root path.
+ *
+ * @return root path
+ */
+ public static String getScalingRootPath() {
+ return "/" + ROOT_NODE;
+ }
+}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
index a05d39b289b..53dd7274aa3 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
@@ -119,14 +119,15 @@ public final class ReflectionUtil {
* @param methodName method name
* @param parameterTypes parameter types
* @param parameterValues parameter values
+ * @return invoke method result.
* @throws NoSuchMethodException no such field exception
* @throws InvocationTargetException invocation target exception
* @throws IllegalAccessException illegal access exception
*/
- public static void invokeMethod(final Object target, final String methodName, final Class<?>[] parameterTypes, final Object[] parameterValues)
+ public static Object invokeMethod(final Object target, final String methodName, final Class<?>[] parameterTypes, final Object[] parameterValues)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Method method = target.getClass().getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
- method.invoke(target, parameterValues);
+ return method.invoke(target, parameterValues);
}
}
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobPreparerTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobPreparerTest.java
new file mode 100644
index 00000000000..a95ea0952ae
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobPreparerTest.java
@@ -0,0 +1,22 @@
+/*
+ * 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.data.pipeline.scenario.rulealtered;
+
+public final class RuleAlteredJobPreparerTest {
+ //TODO simple unit test can't cover prepare() method, it's a combination method
+}
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorkerTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorkerTest.java
index c05a476e8dd..c22f4bb6ffb 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorkerTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorkerTest.java
@@ -18,15 +18,35 @@
package org.apache.shardingsphere.data.pipeline.scenario.rulealtered;
import com.google.common.collect.ImmutableMap;
+import org.apache.commons.io.FileUtils;
import org.apache.shardingsphere.data.pipeline.api.config.rulealtered.JobConfiguration;
import org.apache.shardingsphere.data.pipeline.api.config.rulealtered.WorkflowConfiguration;
+import org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.ShardingSpherePipelineDataSourceConfiguration;
+import org.apache.shardingsphere.data.pipeline.api.job.JobStatus;
+import org.apache.shardingsphere.data.pipeline.core.api.GovernanceRepositoryAPI;
+import org.apache.shardingsphere.data.pipeline.core.api.PipelineAPIFactory;
import org.apache.shardingsphere.data.pipeline.core.exception.PipelineJobCreationException;
+import org.apache.shardingsphere.data.pipeline.core.metadata.node.PipelineMetaDataNode;
+import org.apache.shardingsphere.data.pipeline.core.util.ConfigurationFileUtil;
import org.apache.shardingsphere.data.pipeline.core.util.JobConfigurationBuilder;
import org.apache.shardingsphere.data.pipeline.core.util.PipelineContextUtil;
-import org.junit.Assert;
+import org.apache.shardingsphere.data.pipeline.core.util.ReflectionUtil;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.cache.event.StartScalingEvent;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Optional;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public final class RuleAlteredJobWorkerTest {
@BeforeClass
@@ -43,8 +63,42 @@ public final class RuleAlteredJobWorkerTest {
@Test
public void assertCreateRuleAlteredContextSuccess() {
- JobConfiguration jobConfig = JobConfigurationBuilder.createJobConfiguration();
- final RuleAlteredContext ruleAlteredContext = RuleAlteredJobWorker.createRuleAlteredContext(jobConfig);
- Assert.assertNotNull(ruleAlteredContext.getOnRuleAlteredActionConfig());
+ assertNotNull(RuleAlteredJobWorker.createRuleAlteredContext(JobConfigurationBuilder.createJobConfiguration()).getOnRuleAlteredActionConfig());
+ }
+
+ @Test
+ public void assertRuleAlteredActionEnabled() {
+ ShardingRuleConfiguration ruleConfiguration = new ShardingRuleConfiguration();
+ ruleConfiguration.setScalingName("default_scaling");
+ assertTrue(RuleAlteredJobWorker.isOnRuleAlteredActionEnabled(ruleConfiguration));
+ }
+
+ @Test
+ public void assertRuleAlteredActionDisabled() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ ShardingSpherePipelineDataSourceConfiguration pipelineDataSourceConfig = new ShardingSpherePipelineDataSourceConfiguration(
+ ConfigurationFileUtil.readFile("config_sharding_sphere_jdbc_source.yaml"));
+ ShardingSpherePipelineDataSourceConfiguration pipelineDataTargetConfig = new ShardingSpherePipelineDataSourceConfiguration(
+ ConfigurationFileUtil.readFile("config_sharding_sphere_jdbc_target.yaml"));
+ StartScalingEvent startScalingEvent = new StartScalingEvent("logic_db", YamlEngine.marshal(pipelineDataSourceConfig.getRootConfig().getDataSources()),
+ YamlEngine.marshal(pipelineDataSourceConfig.getRootConfig().getRules()), YamlEngine.marshal(pipelineDataTargetConfig.getRootConfig().getDataSources()),
+ YamlEngine.marshal(pipelineDataTargetConfig.getRootConfig().getRules()), 0, 1);
+ RuleAlteredJobWorker ruleAlteredJobWorker = new RuleAlteredJobWorker();
+ Object result = ReflectionUtil.invokeMethod(ruleAlteredJobWorker, "createJobConfig", new Class[]{StartScalingEvent.class}, new Object[]{startScalingEvent});
+ assertTrue(((Optional<?>) result).isPresent());
+ }
+
+ @Test
+ public void assertHasUncompletedJob() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException {
+ final JobConfiguration jobConfiguration = JobConfigurationBuilder.createJobConfiguration();
+ RuleAlteredJobContext jobContext = new RuleAlteredJobContext(jobConfiguration);
+ jobContext.setStatus(JobStatus.PREPARING);
+ GovernanceRepositoryAPI repositoryAPI = PipelineAPIFactory.getGovernanceRepositoryAPI();
+ repositoryAPI.persistJobProgress(jobContext);
+ URL jobConfigUrl = getClass().getClassLoader().getResource("scaling/rule_alter/scaling_job_config.yaml");
+ assertNotNull(jobConfigUrl);
+ repositoryAPI.persist(PipelineMetaDataNode.getJobConfigPath(jobContext.getJobId()), FileUtils.readFileToString(new File(jobConfigUrl.getFile())));
+ Object result = ReflectionUtil.invokeMethod(new RuleAlteredJobWorker(), "isUncompletedJobOfSameSchemaInJobList", new Class[]{String.class},
+ new String[]{jobConfiguration.getWorkflowConfig().getSchemaName()});
+ assertFalse((Boolean) result);
}
}
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/sharding/ShardingRuleAlteredDetectorTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/sharding/ShardingRuleAlteredDetectorTest.java
index 66f99288421..126605b1171 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/sharding/ShardingRuleAlteredDetectorTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/sharding/ShardingRuleAlteredDetectorTest.java
@@ -17,24 +17,22 @@
package org.apache.shardingsphere.sharding;
+import org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.ShardingSpherePipelineDataSourceConfiguration;
+import org.apache.shardingsphere.data.pipeline.core.util.ConfigurationFileUtil;
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.schedule.ShardingRuleAlteredDetector;
-import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
import org.hamcrest.Matchers;
import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
+import java.util.Collection;
import java.util.List;
-import java.util.Map;
+import java.util.Optional;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class ShardingRuleAlteredDetectorTest {
@@ -44,39 +42,36 @@ public final class ShardingRuleAlteredDetectorTest {
}
@Test
- public void assertFindRuleAlteredLogicTablesSucceed() throws IOException {
- URL sourceUrl = getClass().getClassLoader().getResource("scaling/detector/source_rule_config.yaml");
- assertNotNull(sourceUrl);
- YamlRuleConfiguration sourceRuleConfig = YamlEngine.unmarshal(new File(sourceUrl.getFile()), YamlShardingRuleConfiguration.class);
- URL targetUrl = getClass().getClassLoader().getResource("scaling/detector/target_rule_config.yaml");
- assertNotNull(targetUrl);
- YamlRuleConfiguration targetRuleConfig = YamlEngine.unmarshal(new File(targetUrl.getFile()), YamlShardingRuleConfiguration.class);
- Map<String, Map<String, Object>> sameDataSources = new HashMap<>(5, 1);
- for (int i = 0; i < 5; i++) {
- Map<String, Object> props = new HashMap<>(2, 1);
- props.put("dataSourceClassName", "org.apache.shardingsphere.test.mock.MockedDataSource");
- props.put("jdbcUrl", "jdbc:h2:mem:test_ds_" + i + ";DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
- sameDataSources.put("ds_" + i, props);
- }
- List<String> ruleAlteredLogicTables = new ShardingRuleAlteredDetector().findRuleAlteredLogicTables(sourceRuleConfig, targetRuleConfig, sameDataSources, sameDataSources);
+ public void assertFindRuleAlteredLogicTablesSucceed() {
+ ShardingSpherePipelineDataSourceConfiguration pipelineDataSourceConfig = new ShardingSpherePipelineDataSourceConfiguration(
+ ConfigurationFileUtil.readFile("config_sharding_sphere_jdbc_source.yaml"));
+ ShardingSpherePipelineDataSourceConfiguration pipelineDataTargetConfig = new ShardingSpherePipelineDataSourceConfiguration(
+ ConfigurationFileUtil.readFile("config_sharding_sphere_jdbc_target.yaml"));
+ Collection<YamlRuleConfiguration> sourceRules = pipelineDataSourceConfig.getRootConfig().getRules();
+ Collection<YamlRuleConfiguration> targetRules = pipelineDataTargetConfig.getRootConfig().getRules();
+ assertThat(targetRules.size(), is(1));
+ List<String> ruleAlteredLogicTables = new ShardingRuleAlteredDetector().findRuleAlteredLogicTables(sourceRules.stream().findFirst().get(), targetRules.stream().findFirst().get(),
+ pipelineDataSourceConfig.getRootConfig().getDataSources(), pipelineDataSourceConfig.getRootConfig().getDataSources());
assertThat(ruleAlteredLogicTables.get(0), Matchers.is("t_order"));
}
@Test
- public void assertNoFindRuleAlteredLogicTables() throws IOException {
- URL sourceUrl = getClass().getClassLoader().getResource("scaling/detector/source_rule_config.yaml");
- assertNotNull(sourceUrl);
- YamlRuleConfiguration sourceRuleConfig = YamlEngine.unmarshal(new File(sourceUrl.getFile()), YamlShardingRuleConfiguration.class);
- List<String> ruleAlteredLogicTables = new ShardingRuleAlteredDetector().findRuleAlteredLogicTables(sourceRuleConfig, sourceRuleConfig, null, null);
+ public void assertNoFindRuleAlteredLogicTables() {
+ ShardingSpherePipelineDataSourceConfiguration pipelineDataSourceConfig = new ShardingSpherePipelineDataSourceConfiguration(
+ ConfigurationFileUtil.readFile("config_sharding_sphere_jdbc_source.yaml"));
+ Optional<YamlRuleConfiguration> firstRule = pipelineDataSourceConfig.getRootConfig().getRules().stream().findFirst();
+ assertTrue(firstRule.isPresent());
+ List<String> ruleAlteredLogicTables = new ShardingRuleAlteredDetector().findRuleAlteredLogicTables(firstRule.get(), firstRule.get(), null, null);
assertThat("not table rule alter", ruleAlteredLogicTables.size(), Matchers.is(0));
}
@Test
- public void assertExtractAllLogicTables() throws IOException {
- URL sourceUrl = getClass().getClassLoader().getResource("scaling/detector/source_rule_config.yaml");
- assertNotNull(sourceUrl);
- YamlRuleConfiguration sourceRuleConfig = YamlEngine.unmarshal(new File(sourceUrl.getFile()), YamlShardingRuleConfiguration.class);
- List<String> ruleAlteredLogicTables = new ShardingRuleAlteredDetector().findRuleAlteredLogicTables(sourceRuleConfig, null, null, null);
+ public void assertExtractAllLogicTables() {
+ ShardingSpherePipelineDataSourceConfiguration pipelineDataSourceConfig = new ShardingSpherePipelineDataSourceConfiguration(
+ ConfigurationFileUtil.readFile("config_sharding_sphere_jdbc_source.yaml"));
+ Optional<YamlRuleConfiguration> firstRule = pipelineDataSourceConfig.getRootConfig().getRules().stream().findFirst();
+ assertTrue(firstRule.isPresent());
+ List<String> ruleAlteredLogicTables = new ShardingRuleAlteredDetector().findRuleAlteredLogicTables(firstRule.get(), null, null, null);
assertThat(ruleAlteredLogicTables.get(0), Matchers.is("t_order"));
}
}
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/datasource_config.yaml b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/datasource_config.yaml
deleted file mode 100644
index 844a0d2ff2f..00000000000
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/datasource_config.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# 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.
-#
-
-ds_0:
- dataSourceClassName: org.apache.shardingsphere.test.mock.MockedDataSource
- jdbcUrl: jdbc:h2:mem:test_ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
-ds_1:
- dataSourceClassName: org.apache.shardingsphere.test.mock.MockedDataSource
- jdbcUrl: jdbc:h2:mem:test_ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
-ds_2:
- dataSourceClassName: org.apache.shardingsphere.test.mock.MockedDataSource
- jdbcUrl: jdbc:h2:mem:test_ds_2;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
-ds_3:
- dataSourceClassName: org.apache.shardingsphere.test.mock.MockedDataSource
- jdbcUrl: jdbc:h2:mem:test_ds_3;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
-ds_4:
- dataSourceClassName: org.apache.shardingsphere.test.mock.MockedDataSource
- jdbcUrl: jdbc:h2:mem:test_ds_4;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/source_rule_config.yaml b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/source_rule_config.yaml
deleted file mode 100644
index cc404644034..00000000000
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/source_rule_config.yaml
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# 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.
-#
-
-defaultDatabaseStrategy:
- standard:
- shardingAlgorithmName: database_inline
- shardingColumn: user_id
-defaultTableStrategy:
- none: ''
-keyGenerators:
- snowflake:
- type: SNOWFLAKE
-scaling:
- default_scaling:
- completionDetector:
- props:
- incremental-task-idle-minute-threshold: 30
- type: IDLE
- dataConsistencyChecker:
- props:
- chunk-size: 1000
- type: DATA_MATCH
- input:
- batchSize: 1000
- workerThread: 40
- output:
- batchSize: 1000
- workerThread: 40
- streamChannel:
- props:
- block-queue-size: 10000
- type: MEMORY
-scalingName: default_scaling
-shardingAlgorithms:
- database_inline:
- props:
- algorithm-expression: ds_${user_id % 2}
- type: INLINE
- t_order_inline:
- props:
- algorithm-expression: t_order_${order_id % 2}
- type: INLINE
-tables:
- t_order:
- actualDataNodes: ds_${0..1}.t_order_${0..1}
- keyGenerateStrategy:
- column: order_id
- keyGeneratorName: snowflake
- logicTable: t_order
- tableStrategy:
- standard:
- shardingAlgorithmName: t_order_inline
- shardingColumn: order_id
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/target_rule_config.yaml b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/target_rule_config.yaml
deleted file mode 100644
index db5bad3c943..00000000000
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/detector/target_rule_config.yaml
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# 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.
-#
-
-autoTables:
- t_order:
- actualDataSources: ds_2,ds_3,ds_4
- keyGenerateStrategy:
- column: order_id
- keyGeneratorName: t_order_snowflake
- logicTable: t_order
- shardingStrategy:
- standard:
- shardingAlgorithmName: t_order_hash_mod
- shardingColumn: order_id
-defaultDatabaseStrategy:
- standard:
- shardingAlgorithmName: database_inline
- shardingColumn: user_id
-defaultTableStrategy:
- none: ''
-keyGenerators:
- snowflake:
- type: SNOWFLAKE
- t_order_snowflake:
- type: snowflake
-scaling:
- default_scaling:
- completionDetector:
- props:
- incremental-task-idle-minute-threshold: 30
- type: IDLE
- dataConsistencyChecker:
- props:
- chunk-size: 1000
- type: DATA_MATCH
- input:
- batchSize: 1000
- workerThread: 4
- output:
- batchSize: 1000
- workerThread: 4
- streamChannel:
- props:
- block-queue-size: 10000
- type: MEMORY
-scalingName: default_scaling
-shardingAlgorithms:
- database_inline:
- props:
- algorithm-expression: ds_${user_id % 2}
- type: INLINE
- t_order_inline:
- props:
- algorithm-expression: t_order_${order_id % 2}
- type: INLINE
- t_order_hash_mod:
- props:
- sharding-count: '6'
- type: hash_mod
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/rule_alter/scaling_job_config.yaml b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/rule_alter/scaling_job_config.yaml
new file mode 100644
index 00000000000..de275d3f7ab
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/resources/scaling/rule_alter/scaling_job_config.yaml
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+jobName: 0130317c30317c3054317c6c6f6769635f6462
+jobParameter: |
+ handleConfig:
+ jobId: 0130317c30317c3054317c6c6f6769635f6462
+ jobShardingDataNodes:
+ - t_order:ds_0.t_order_0,ds_0.t_order_1
+ workflowConfig:
+ schemaName: logic_db
+shardingTotalCount: 1