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 2022/06/30 03:24:11 UTC

[GitHub] [shardingsphere] tain198127 opened a new pull request, #18719: Fix issues 18689

tain198127 opened a new pull request, #18719:
URL: https://github.com/apache/shardingsphere/pull/18719

   Fixes #18689.
   
   Changes proposed in this pull request:
   - Add test case for OptimizerContext.dropTable
   
   ![image](https://user-images.githubusercontent.com/1415402/176586110-7efb083a-cfad-4cf9-8e67-bc4548c92129.png)
   
   


-- 
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] tain198127 commented on a diff in pull request #18719: Fix issues 18689

Posted by GitBox <gi...@apache.org>.
tain198127 commented on code in PR #18719:
URL: https://github.com/apache/shardingsphere/pull/18719#discussion_r911187624


##########
shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/OptimizerContextTest.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.infra.federation.optimizer.context;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+
+public final class OptimizerContextTest {
+
+    private final String databaseName = "sharding_db";
+
+    private final String schemaName = "federate_jdbc";
+
+    private final String tableName = "t_order_federate";
+
+    @Test
+    public void assertDropTable() {
+        Map<String, ShardingSphereTable> tables = new HashMap<>(2, 1);
+        tables.put(tableName, mock(ShardingSphereTable.class, RETURNS_DEEP_STUBS));
+        ShardingSphereDatabase database = new ShardingSphereDatabase(databaseName, new H2DatabaseType(), mock(ShardingSphereResource.class), null,
+                Collections.singletonMap(schemaName, new ShardingSphereSchema(tables)));
+        OptimizerContext optimizerContext = OptimizerContextFactory.create(Collections.singletonMap(databaseName, database), mock(ShardingSphereRuleMetaData.class));
+        int converterHashCodeBefore = optimizerContext.getPlannerContexts().get(databaseName).getConverters().get(schemaName).hashCode();
+        int validatorHashCodeBefore = optimizerContext.getPlannerContexts().get(databaseName).getValidators().get(schemaName).hashCode();
+        optimizerContext.dropTable(databaseName, schemaName, tableName);
+        int converterHashCodeAfter = optimizerContext.getPlannerContexts().get(databaseName).getConverters().get(schemaName).hashCode();
+        int validatorHashCodeAfter = optimizerContext.getPlannerContexts().get(databaseName).getValidators().get(schemaName).hashCode();
+        assertNotEquals(converterHashCodeBefore, converterHashCodeAfter);

Review Comment:
   Has been replace with assertThat



-- 
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] terrymanu merged pull request #18719: Fix issues 18689

Posted by GitBox <gi...@apache.org>.
terrymanu merged PR #18719:
URL: https://github.com/apache/shardingsphere/pull/18719


-- 
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] terrymanu commented on a diff in pull request #18719: Fix issues 18689

Posted by GitBox <gi...@apache.org>.
terrymanu commented on code in PR #18719:
URL: https://github.com/apache/shardingsphere/pull/18719#discussion_r910651841


##########
shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/OptimizerContextTest.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.infra.federation.optimizer.context;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+
+public final class OptimizerContextTest {
+
+    private final String databaseName = "sharding_db";
+
+    private final String schemaName = "federate_jdbc";
+
+    private final String tableName = "t_order_federate";
+
+    @Test
+    public void assertDropTable() {
+        Map<String, ShardingSphereTable> tables = new HashMap<>(2, 1);
+        tables.put(tableName, mock(ShardingSphereTable.class, RETURNS_DEEP_STUBS));
+        ShardingSphereDatabase database = new ShardingSphereDatabase(databaseName, new H2DatabaseType(), mock(ShardingSphereResource.class), null,
+                Collections.singletonMap(schemaName, new ShardingSphereSchema(tables)));
+        OptimizerContext optimizerContext = OptimizerContextFactory.create(Collections.singletonMap(databaseName, database), mock(ShardingSphereRuleMetaData.class));
+        int converterHashCodeBefore = optimizerContext.getPlannerContexts().get(databaseName).getConverters().get(schemaName).hashCode();
+        int validatorHashCodeBefore = optimizerContext.getPlannerContexts().get(databaseName).getValidators().get(schemaName).hashCode();
+        optimizerContext.dropTable(databaseName, schemaName, tableName);
+        int converterHashCodeAfter = optimizerContext.getPlannerContexts().get(databaseName).getConverters().get(schemaName).hashCode();
+        int validatorHashCodeAfter = optimizerContext.getPlannerContexts().get(databaseName).getValidators().get(schemaName).hashCode();
+        assertNotEquals(converterHashCodeBefore, converterHashCodeAfter);

Review Comment:
   Please use assertThat for binary assertion



-- 
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 #18719: Fix issues 18689

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18719:
URL: https://github.com/apache/shardingsphere/pull/18719#issuecomment-1170775897

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18719?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 [#18719](https://codecov.io/gh/apache/shardingsphere/pull/18719?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (870b2ef) into [master](https://codecov.io/gh/apache/shardingsphere/commit/b40c8e111b4342a0c20a791a375a4cb2d5fa111d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b40c8e1) will **decrease** coverage by `0.21%`.
   > The diff coverage is `68.18%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18719      +/-   ##
   ============================================
   - Coverage     59.35%   59.14%   -0.22%     
   + Complexity     2262     2257       -5     
   ============================================
     Files          3743     3734       -9     
     Lines         54899    54250     -649     
     Branches       9343     9144     -199     
   ============================================
   - Hits          32586    32085     -501     
   + Misses        19565    19468      -97     
   + Partials       2748     2697      -51     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/18719?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...e/sharding/checker/audit/ShardingAuditChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvY2hlY2tlci9hdWRpdC9TaGFyZGluZ0F1ZGl0Q2hlY2tlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...e/model/privilege/DatabasePermittedPrivileges.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWF1dGhvcml0eS9zaGFyZGluZ3NwaGVyZS1hdXRob3JpdHktY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYXV0aG9yaXR5L3Byb3ZpZGVyL2RhdGFiYXNlL21vZGVsL3ByaXZpbGVnZS9EYXRhYmFzZVBlcm1pdHRlZFByaXZpbGVnZXMuamF2YQ==) | `25.00% <ø> (ø)` | |
   | [.../sql/common/statement/ddl/NotifyStmtStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvY29tbW9uL3N0YXRlbWVudC9kZGwvTm90aWZ5U3RtdFN0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [.../postgresql/ddl/PostgreSQLNotifyStmtStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvcG9zdGdyZXNxbC9kZGwvUG9zdGdyZVNRTE5vdGlmeVN0bXRTdGF0ZW1lbnQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ized/asserts/statement/ddl/DDLStatementAssert.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvYXNzZXJ0cy9zdGF0ZW1lbnQvZGRsL0RETFN0YXRlbWVudEFzc2VydC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [.../statement/ddl/impl/NotifyStmtStatementAssert.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvYXNzZXJ0cy9zdGF0ZW1lbnQvZGRsL2ltcGwvTm90aWZ5U3RtdFN0YXRlbWVudEFzc2VydC5qYXZh) | `0.00% <ø> (ø)` | |
   | [...che/shardingsphere/sharding/rule/ShardingRule.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9TaGFyZGluZ1J1bGUuamF2YQ==) | `81.61% <71.42%> (-0.12%)` | :arrow_down: |
   | [...hema/loader/dialect/MySQLSchemaMetaDataLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9kYXRhYmFzZS9zY2hlbWEvbG9hZGVyL2RpYWxlY3QvTXlTUUxTY2hlbWFNZXRhRGF0YUxvYWRlci5qYXZh) | `76.19% <100.00%> (+0.58%)` | :arrow_up: |
   | [...atement/impl/PostgreSQLDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1wb3N0Z3Jlc3FsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zcWwvcGFyc2VyL3Bvc3RncmVzcWwvdmlzaXRvci9zdGF0ZW1lbnQvaW1wbC9Qb3N0Z3JlU1FMRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `83.71% <100.00%> (+0.04%)` | :arrow_up: |
   | [...l/parser/core/database/visitor/SQLVisitorRule.java](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9jb3JlL2RhdGFiYXNlL3Zpc2l0b3IvU1FMVmlzaXRvclJ1bGUuamF2YQ==) | `100.00% <100.00%> (ø)` | |
   | ... and [5 more](https://codecov.io/gh/apache/shardingsphere/pull/18719/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18719?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18719?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [c38adb0...870b2ef](https://codecov.io/gh/apache/shardingsphere/pull/18719?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?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