You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2023/01/05 00:14:14 UTC
[GitHub] [shardingsphere] Qianyi951015 opened a new pull request, #23332: Add unit test for `ReadwriteSplittingRuleConfigurationImportChecker`
Qianyi951015 opened a new pull request, #23332:
URL: https://github.com/apache/shardingsphere/pull/23332
Changes proposed in this pull request:
- add `ReadwriteSplittingRuleConfigurationImportCheckerTest`
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [ ] I have added corresponding unit tests for my changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang merged pull request #23332: Add unit test for `ReadwriteSplittingRuleConfigurationImportChecker`
Posted by GitBox <gi...@apache.org>.
RaigorJiang merged PR #23332:
URL: https://github.com/apache/shardingsphere/pull/23332
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #23332: Add unit test for `ReadwriteSplittingRuleConfigurationImportChecker`
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on code in PR #23332:
URL: https://github.com/apache/shardingsphere/pull/23332#discussion_r1062050175
##########
proxy/backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportCheckerTest.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.proxy.backend.handler.distsql.ral.common.checker;
+
+import org.apache.shardingsphere.distsql.handler.exception.algorithm.InvalidAlgorithmConfigurationException;
+import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.strategy.DynamicReadwriteSplittingStrategyConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.strategy.StaticReadwriteSplittingStrategyConfiguration;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ReadwriteSplittingRuleConfigurationImportCheckerTest {
+
+ private final ReadwriteSplittingRuleConfigurationImportChecker readwriteRuleConfigurationImportChecker = new ReadwriteSplittingRuleConfigurationImportChecker();
+
+ @Test(expected = MissingRequiredStorageUnitsException.class)
+ public void assertCheckDataSources() {
+ ShardingSphereDatabase database = mockDatabaseWithDataSource();
+ ReadwriteSplittingRuleConfiguration currentRuleConfig = getNotExistedResourcesRuleConfig();
+ readwriteRuleConfigurationImportChecker.check(database, currentRuleConfig);
+ }
+
+ @Test(expected = InvalidAlgorithmConfigurationException.class)
+ public void assertCheckLoadBalancers() {
+ ShardingSphereDatabase database = mockDatabase();
+ ReadwriteSplittingRuleConfiguration currentRuleConfig = createInvalidLoadBalancerRuleConfig();
+ readwriteRuleConfigurationImportChecker.check(database, currentRuleConfig);
+ }
+
+ private ShardingSphereDatabase mockDatabaseWithDataSource() {
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+ Collection<String> dataSources = new LinkedList<>();
+ dataSources.add("su_1");
+ when(database.getResourceMetaData().getNotExistedResources(any())).thenReturn(dataSources);
+ when(database.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+ return database;
+ }
+
+ private ReadwriteSplittingRuleConfiguration getNotExistedResourcesRuleConfig() {
Review Comment:
ResourcesRuleConfig is not a good name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter commented on pull request #23332: Add unit test for `ReadwriteSplittingRuleConfigurationImportChecker`
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #23332:
URL: https://github.com/apache/shardingsphere/pull/23332#issuecomment-1371601411
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/23332?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#23332](https://codecov.io/gh/apache/shardingsphere/pull/23332?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a108496) into [master](https://codecov.io/gh/apache/shardingsphere/commit/57efe035f551386611530ac7ab8484494052872e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (57efe03) will **increase** coverage by `0.02%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #23332 +/- ##
============================================
+ Coverage 49.68% 49.71% +0.02%
Complexity 2458 2458
============================================
Files 4040 4040
Lines 58145 58145
Branches 9244 9244
============================================
+ Hits 28891 28906 +15
+ Misses 26704 26683 -21
- Partials 2550 2556 +6
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/23332?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/23332?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2hpbnQvZW51bXMvSGludFNvdXJjZVR5cGUuamF2YQ==) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
| [...dwriteSplittingRuleConfigurationImportChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/23332?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2NvbW1vbi9jaGVja2VyL1JlYWR3cml0ZVNwbGl0dGluZ1J1bGVDb25maWd1cmF0aW9uSW1wb3J0Q2hlY2tlci5qYXZh) | `63.33% <0.00%> (+60.00%)` | :arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org