You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/05/28 22:31:20 UTC
[shardingsphere] branch master updated: Remove feature dependencies
from governance module (#10539)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 6b137a8 Remove feature dependencies from governance module (#10539)
6b137a8 is described below
commit 6b137a87997905336e6705b03739d1785441a74f
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat May 29 06:30:26 2021 +0800
Remove feature dependencies from governance module (#10539)
* Remove useless dependency
* Remove useless dependency
* Remove useless dependencies for governance module
* Remove useless dependencies for governance module
---
.../metadata/GovernanceMetaDataContextsTest.java | 11 +---
.../shardingsphere-governance-core/pom.xml | 25 --------
.../core/registry/RegistryCenterTest.java | 13 +++--
.../cache/ScalingRegistrySubscriberTest.java | 28 +++------
.../listener/impl/RuleChangedListenerTest.java | 67 +++++-----------------
.../config/impl/SchemaRuleRegistryServiceTest.java | 47 +++++++--------
.../resources/yaml/database-discovery-rule.yaml | 32 -----------
.../src/test/resources/yaml/encrypt-rule.yaml | 29 ----------
.../resources/yaml/readwrite-splitting-rule.yaml | 24 --------
.../yaml/{sharding-rule.yaml => rule.yaml} | 0
.../pom.xml | 2 +-
11 files changed, 51 insertions(+), 227 deletions(-)
diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java b/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
index b732a5c..4db2099 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
@@ -42,8 +42,6 @@ import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.rule.event.RuleChangedEvent;
-import org.apache.shardingsphere.readwritesplitting.common.rule.ReadwriteSplittingRule;
import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Before;
import org.junit.Test;
@@ -67,10 +65,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -87,9 +82,6 @@ public final class GovernanceMetaDataContextsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereMetaData metaData;
- @Mock
- private ReadwriteSplittingRule readwriteSplittingRule;
-
private GovernanceMetaDataContexts governanceMetaDataContexts;
@Mock
@@ -109,7 +101,7 @@ public final class GovernanceMetaDataContextsTest {
when(resource.getDatabaseType()).thenReturn(new MySQLDatabaseType());
when(metaData.getResource()).thenReturn(resource);
when(metaData.getSchema()).thenReturn(mock(ShardingSphereSchema.class));
- when(metaData.getRuleMetaData().getRules()).thenReturn(Collections.singletonList(readwriteSplittingRule));
+ when(metaData.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
return Collections.singletonMap("schema", metaData);
}
@@ -189,7 +181,6 @@ public final class GovernanceMetaDataContextsTest {
public void assertDisableStateChanged() {
DisabledStateChangedEvent event = new DisabledStateChangedEvent(new GovernanceSchema("schema.ds_0"), true);
governanceMetaDataContexts.renew(event);
- verify(readwriteSplittingRule, times(2)).updateRuleStatus(any(RuleChangedEvent.class));
}
@Test
diff --git a/shardingsphere-governance/shardingsphere-governance-core/pom.xml b/shardingsphere-governance/shardingsphere-governance-core/pom.xml
index 86e1e5d..739e0f7 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/pom.xml
+++ b/shardingsphere-governance/shardingsphere-governance-core/pom.xml
@@ -34,31 +34,6 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-sharding-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-readwrite-splitting-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-encrypt-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-shadow-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-db-discovery-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-authority-common</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
index 25ca96e..de4a4ee 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
@@ -53,7 +53,7 @@ import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public final class RegistryCenterTest {
- private static final String SHARDING_RULE_YAML = "yaml/regcenter/data-schema-rule.yaml";
+ private static final String SCHEMA_RULE_YAML = "yaml/regcenter/data-schema-rule.yaml";
private static final String GLOBAL_RULE_YAML = "yaml/regcenter/data-global-rule.yaml";
@@ -97,9 +97,9 @@ public final class RegistryCenterTest {
Collection<RuleConfiguration> globalRuleConfigs = createGlobalRuleConfigurations();
Properties props = createProperties();
registryCenter.persistConfigurations(
- Collections.singletonMap("sharding_db", dataSourceConfigs), Collections.singletonMap("sharding_db", schemaRuleConfigs), globalRuleConfigs, props, false);
- verify(dataSourceService).persist("sharding_db", dataSourceConfigs, false);
- verify(schemaRuleService).persist("sharding_db", schemaRuleConfigs, false);
+ Collections.singletonMap("foo_db", dataSourceConfigs), Collections.singletonMap("foo_db", schemaRuleConfigs), globalRuleConfigs, props, false);
+ verify(dataSourceService).persist("foo_db", dataSourceConfigs, false);
+ verify(schemaRuleService).persist("foo_db", schemaRuleConfigs, false);
verify(globalRuleService).persist(globalRuleConfigs, false);
verify(propsService).persist(props, false);
}
@@ -125,9 +125,10 @@ public final class RegistryCenterTest {
return result;
}
- @SuppressWarnings("unchecked")
private Collection<RuleConfiguration> createRuleConfigurations() {
- return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHARDING_RULE_YAML), Collection.class));
+ // TODO use RuleConfigurationFixture instead of ShardingRuleConfiguration for test case
+ return Collections.emptyList();
+// return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SCHEMA_RULE_YAML), Collection.class));
}
@SuppressWarnings("unchecked")
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/cache/ScalingRegistrySubscriberTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/cache/ScalingRegistrySubscriberTest.java
index c8ca2e5..276d412 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/cache/ScalingRegistrySubscriberTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/cache/ScalingRegistrySubscriberTest.java
@@ -17,8 +17,6 @@
package org.apache.shardingsphere.governance.core.registry.cache;
-import lombok.SneakyThrows;
-import org.apache.shardingsphere.governance.core.registry.listener.event.rule.SwitchRuleConfigurationEvent;
import org.apache.shardingsphere.governance.core.registry.service.config.impl.SchemaRuleRegistryService;
import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
import org.junit.Before;
@@ -27,16 +25,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import java.io.IOException;
import java.lang.reflect.Field;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.stream.Collectors;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public final class ScalingRegistrySubscriberTest {
@@ -62,9 +51,10 @@ public final class ScalingRegistrySubscriberTest {
Field field = ScalingRegistrySubscriber.class.getDeclaredField("registryCacheManager");
field.setAccessible(true);
field.set(scalingRegistrySubscriber, registryCacheManager);
- when(registryCacheManager.loadCache(anyString(), eq("testCacheId"))).thenReturn(readYAML());
- SwitchRuleConfigurationEvent event = new SwitchRuleConfigurationEvent("sharding_db", "testCacheId");
- scalingRegistrySubscriber.switchRuleConfiguration(event);
+ // Move to scaling module
+// when(registryCacheManager.loadCache(anyString(), eq("testCacheId"))).thenReturn(readYAML());
+// SwitchRuleConfigurationEvent event = new SwitchRuleConfigurationEvent("sharding_db", "testCacheId");
+// scalingRegistrySubscriber.switchRuleConfiguration(event);
// TODO finish verify
}
@@ -73,9 +63,9 @@ public final class ScalingRegistrySubscriberTest {
// TODO finish test case
}
- @SneakyThrows({IOException.class, URISyntaxException.class})
- private String readYAML() {
- return Files.readAllLines(Paths.get(ClassLoader.getSystemResource("yaml/regcenter/data-schema-rule.yaml").toURI()))
- .stream().filter(each -> !each.startsWith("#")).map(each -> each + System.lineSeparator()).collect(Collectors.joining());
- }
+// @SneakyThrows({IOException.class, URISyntaxException.class})
+// private String readYAML() {
+// return Files.readAllLines(Paths.get(ClassLoader.getSystemResource("yaml/regcenter/data-schema-rule.yaml").toURI()))
+// .stream().filter(each -> !each.startsWith("#")).map(each -> each + System.lineSeparator()).collect(Collectors.joining());
+// }
}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
index 578a310..a7a399f 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
@@ -17,95 +17,54 @@
package org.apache.shardingsphere.governance.core.registry.listener.impl;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
-import org.apache.shardingsphere.governance.core.registry.listener.event.rule.RuleConfigurationsChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.Type;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
@RunWith(MockitoJUnitRunner.class)
public final class RuleChangedListenerTest extends GovernanceListenerTest {
- private static final String SHARDING_RULE_FILE = "yaml/sharding-rule.yaml";
-
- private static final String READWRITE_SPLITTING_RULE_FILE = "yaml/readwrite-splitting-rule.yaml";
-
- private static final String ENCRYPT_RULE_FILE = "yaml/encrypt-rule.yaml";
+ private static final String RULE_FILE = "yaml/rule.yaml";
private RuleChangedListener ruleChangedListener;
@Before
public void setUp() {
- ruleChangedListener = new RuleChangedListener(getRegistryCenterRepository(), Arrays.asList("sharding_db", "replica_query_db", "encrypt_db"));
+ ruleChangedListener = new RuleChangedListener(getRegistryCenterRepository(), Arrays.asList("foo_db", "bar_db"));
}
@Test
public void assertCreateEventWithoutSchema() {
- DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata", readYAML(SHARDING_RULE_FILE), Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata", readYAML(RULE_FILE), Type.UPDATED);
Optional<GovernanceEvent> actual = ruleChangedListener.createEvent(dataChangedEvent);
assertFalse(actual.isPresent());
}
@Test
public void assertCreateEventWithEmptyValue() {
- DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata/sharding_db/rules", "", Type.UPDATED);
+ DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata/foo_db/rules", "", Type.UPDATED);
Optional<GovernanceEvent> actual = ruleChangedListener.createEvent(dataChangedEvent);
assertFalse(actual.isPresent());
}
@Test
- public void assertCreateEventWithShardingRule() {
- DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata/sharding_db/rules", readYAML(SHARDING_RULE_FILE), Type.UPDATED);
- Optional<GovernanceEvent> actual = ruleChangedListener.createEvent(dataChangedEvent);
- assertTrue(actual.isPresent());
- assertThat(((RuleConfigurationsChangedEvent) actual.get()).getSchemaName(), is("sharding_db"));
- Collection<RuleConfiguration> ruleConfigs = ((RuleConfigurationsChangedEvent) actual.get()).getRuleConfigurations();
- assertThat(ruleConfigs.size(), is(1));
- assertThat(((ShardingRuleConfiguration) ruleConfigs.iterator().next()).getTables().size(), is(1));
- }
-
- @Test
- public void assertCreateEventWithEncryptRule() {
- DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata/encrypt_db/rules", readYAML(ENCRYPT_RULE_FILE), Type.UPDATED);
- Optional<GovernanceEvent> actual = ruleChangedListener.createEvent(dataChangedEvent);
- assertTrue(actual.isPresent());
- RuleConfigurationsChangedEvent event = (RuleConfigurationsChangedEvent) actual.get();
- assertThat(event.getSchemaName(), is("encrypt_db"));
- assertThat(event.getRuleConfigurations().iterator().next(), instanceOf(EncryptRuleConfiguration.class));
- EncryptRuleConfiguration encryptRuleConfig = (EncryptRuleConfiguration) event.getRuleConfigurations().iterator().next();
- assertThat(encryptRuleConfig.getEncryptors().size(), is(1));
- ShardingSphereAlgorithmConfiguration encryptAlgorithmConfig = encryptRuleConfig.getEncryptors().get("order_encryptor");
- assertThat(encryptAlgorithmConfig.getType(), is("AES"));
- assertThat(encryptAlgorithmConfig.getProps().get("aes-key-value"), is(123456));
- }
-
- @Test
- public void assertCreateEventWithReadwriteSplittingRule() {
- DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata/readwrite_splitting_db/rules", readYAML(READWRITE_SPLITTING_RULE_FILE), Type.UPDATED);
- Optional<GovernanceEvent> actual = ruleChangedListener.createEvent(dataChangedEvent);
- assertTrue(actual.isPresent());
- RuleConfigurationsChangedEvent event = (RuleConfigurationsChangedEvent) actual.get();
- assertThat(event.getSchemaName(), is("readwrite_splitting_db"));
- assertThat(event.getRuleConfigurations().iterator().next(), instanceOf(ReadwriteSplittingRuleConfiguration.class));
- ReadwriteSplittingRuleConfiguration ruleConfig = (ReadwriteSplittingRuleConfiguration) event.getRuleConfigurations().iterator().next();
- assertThat(ruleConfig.getDataSources().iterator().next().getWriteDataSourceName(), is("write_ds"));
+ public void assertCreateEventWithRule() {
+ // TODO use RuleConfigurationFixture instead of ShardingRuleConfiguration for test case
+// DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata/foo_db/rules", readYAML(RULE_FILE), Type.UPDATED);
+// Optional<GovernanceEvent> actual = ruleChangedListener.createEvent(dataChangedEvent);
+// assertTrue(actual.isPresent());
+// assertThat(((RuleConfigurationsChangedEvent) actual.get()).getSchemaName(), is("foo_db"));
+// Collection<RuleConfiguration> ruleConfigs = ((RuleConfigurationsChangedEvent) actual.get()).getRuleConfigurations();
+// assertThat(ruleConfigs.size(), is(1));
+// assertThat(((ShardingRuleConfiguration) ruleConfigs.iterator().next()).getTables().size(), is(1));
}
}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java
index 395c986..c4174fe 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java
@@ -17,36 +17,23 @@
package org.apache.shardingsphere.governance.core.registry.service.config.impl;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.governance.core.registry.listener.event.rule.RuleConfigurationsAlteredEvent;
import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import java.io.IOException;
import java.lang.reflect.Field;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Collection;
import java.util.Collections;
-import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public final class SchemaRuleRegistryServiceTest {
- private static final String YAML_DATA = "yaml/regcenter/data-schema-rule.yaml";
-
@Mock
private RegistryCenterRepository registryCenterRepository;
@@ -61,25 +48,31 @@ public final class SchemaRuleRegistryServiceTest {
}
@Test
- public void assertLoad() {
- when(registryCenterRepository.get("/metadata/shardingsphere_db/rules")).thenReturn(readYAML(YAML_DATA));
- Collection<RuleConfiguration> actual = schemaRuleRegistryService.load("shardingsphere_db");
- assertThat(actual.size(), is(1));
- ShardingRuleConfiguration actualShardingRuleConfig = (ShardingRuleConfiguration) actual.iterator().next();
- assertThat(actualShardingRuleConfig.getTables().size(), is(1));
- assertThat(actualShardingRuleConfig.getTables().iterator().next().getLogicTable(), is("t_order"));
+ public void assertLoadWithoutExistedNode() {
+ assertTrue(schemaRuleRegistryService.load("foo_db").isEmpty());
}
- @SneakyThrows({IOException.class, URISyntaxException.class})
- private String readYAML(final String yamlFile) {
- return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI()))
- .stream().filter(each -> !each.startsWith("#")).map(each -> each + System.lineSeparator()).collect(Collectors.joining());
+ @Test
+ public void assertLoadWithExistedNode() {
+ // TODO use RuleConfigurationFixture instead of ShardingRuleConfiguration for test case
+// when(registryCenterRepository.get("/metadata/foo_db/rules")).thenReturn(readYAML());
+// Collection<RuleConfiguration> actual = schemaRuleRegistryService.load("foo_db");
+// assertThat(actual.size(), is(1));
+// ShardingRuleConfiguration actualShardingRuleConfig = (ShardingRuleConfiguration) actual.iterator().next();
+// assertThat(actualShardingRuleConfig.getTables().size(), is(1));
+// assertThat(actualShardingRuleConfig.getTables().iterator().next().getLogicTable(), is("t_order"));
}
+// @SneakyThrows({IOException.class, URISyntaxException.class})
+// private String readYAML() {
+// return Files.readAllLines(Paths.get(ClassLoader.getSystemResource("yaml/regcenter/data-schema-rule.yaml").toURI()))
+// .stream().filter(each -> !each.startsWith("#")).map(each -> each + System.lineSeparator()).collect(Collectors.joining());
+// }
+
@Test
public void assertUpdate() {
- RuleConfigurationsAlteredEvent event = new RuleConfigurationsAlteredEvent("sharding_db", Collections.emptyList());
+ RuleConfigurationsAlteredEvent event = new RuleConfigurationsAlteredEvent("foo_db", Collections.emptyList());
schemaRuleRegistryService.update(event);
- verify(registryCenterRepository).persist("/metadata/sharding_db/rules", "!!map []\n");
+ verify(registryCenterRepository).persist("/metadata/foo_db/rules", "!!map []\n");
}
}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.yaml
deleted file mode 100644
index 5a3d284..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/database-discovery-rule.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.
-#
-
-- !DB_DISCOVERY
- dataSources:
- pr_ds:
- dataSourceNames:
- - ds_0
- - ds_1
- - ds_2
- discoveryTypeName: mgr
- discoveryTypes:
- mgr:
- type: MGR
- props:
- groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
- zkServerLists: 'localhost:2181'
- keepAliveCron: '0/5 * * * * ?'
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml
deleted file mode 100644
index 10dc2ef..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/encrypt-rule.yaml
+++ /dev/null
@@ -1,29 +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.
-#
-
-- !ENCRYPT
- tables:
- t_order:
- columns:
- order_id:
- cipherColumn: order_id
- encryptorName: order_encryptor
- encryptors:
- order_encryptor:
- type: AES
- props:
- aes-key-value: 123456
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml
deleted file mode 100644
index e20f352..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/readwrite-splitting-rule.yaml
+++ /dev/null
@@ -1,24 +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.
-#
-
-- !READWRITE_SPLITTING
- dataSources:
- pr_ds:
- writeDataSourceName: write_ds
- readDataSourceNames:
- - read_ds_0
- - read_ds_1
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/sharding-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/rule.yaml
similarity index 100%
rename from shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/sharding-rule.yaml
rename to shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/rule.yaml
diff --git a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-api/pom.xml b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-api/pom.xml
index 2827387..5ea5f01 100644
--- a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-api/pom.xml
+++ b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-api/pom.xml
@@ -29,7 +29,7 @@
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-sharding-api</artifactId>
+ <artifactId>shardingsphere-infra-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>