You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/05/27 03:52:31 UTC

[GitHub] [ignite] antonovsergey93 opened a new pull request #7853: IGNITE-13071 Improve test coverage of cluster read-only mode.

antonovsergey93 opened a new pull request #7853:
URL: https://github.com/apache/ignite/pull/7853


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-12407: Add Cluster API support to Java thin client`
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] zstan commented on a change in pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
zstan commented on a change in pull request #7853:
URL: https://github.com/apache/ignite/pull/7853#discussion_r435288030



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
##########
@@ -960,6 +962,21 @@ private boolean processStartNewCacheRequest(
         DynamicCacheChangeRequest req,
         String cacheName
     ) {
+        CacheConfiguration<?, ?> ccfg = req.startCacheConfiguration();
+
+        if (ctx.cache().context().readOnlyMode()) {

Review comment:
       code copy-paste is always evil )




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] antonovsergey93 commented on a change in pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
antonovsergey93 commented on a change in pull request #7853:
URL: https://github.com/apache/ignite/pull/7853#discussion_r435380354



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
##########
@@ -960,6 +962,21 @@ private boolean processStartNewCacheRequest(
         DynamicCacheChangeRequest req,
         String cacheName
     ) {
+        CacheConfiguration<?, ?> ccfg = req.startCacheConfiguration();
+
+        if (ctx.cache().context().readOnlyMode()) {

Review comment:
       Fixed




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] asfgit closed pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #7853:
URL: https://github.com/apache/ignite/pull/7853


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] zstan commented on a change in pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
zstan commented on a change in pull request #7853:
URL: https://github.com/apache/ignite/pull/7853#discussion_r435292960



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
##########
@@ -4759,6 +4763,8 @@ private boolean clearLocally0(K key, boolean readers) {
 
         ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
 
+        ctx.shared().cache().checkReadOnlyState("clear", ctx.config());

Review comment:
       I suppose no neet to check mvcc and security permissions in already readonly cluster ? may be we need to move it upper ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] zstan commented on a change in pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
zstan commented on a change in pull request #7853:
URL: https://github.com/apache/ignite/pull/7853#discussion_r435332313



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheCreateDestroyClusterReadOnlyModeTest.java
##########
@@ -0,0 +1,186 @@
+/*
+ * 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.ignite.internal.processors.cache;
+
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.junit.Test;
+
+import static java.util.Arrays.asList;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.cacheConfigurations;
+import static org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.cacheNames;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests that {@link Ignite#createCache(CacheConfiguration)}/{@link Ignite#destroyCache(String)}/{@link IgniteCache#clear()}
+ * denied if cluster in a {@link ClusterState#ACTIVE_READ_ONLY} state.
+ */
+public class CacheCreateDestroyClusterReadOnlyModeTest extends CacheCreateDestroyClusterReadOnlyModeAbstractTest {
+    /** */
+    @Test
+    public void testCacheCreateDenied() {
+        grid(0).cluster().state(ACTIVE_READ_ONLY);
+
+        G.allGrids().forEach(n -> assertEquals(n.name(), ACTIVE_READ_ONLY, n.cluster().state()));
+
+        for (CacheConfiguration cfg : cacheConfigurations()) {
+            for (Ignite node : G.allGrids()) {
+                executeAndCheckException(() -> node.createCache(cfg), cfg.getName());
+                executeAndCheckException(() -> node.createCache(cfg.getName()), cfg.getName());
+            }
+        }
+    }
+
+    /** */
+    @Test
+    public void testGetOrCreateNotExistedCacheDenied() {

Review comment:
       copy paste of testCacheCreateDenied or i miss something ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] zstan commented on a change in pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
zstan commented on a change in pull request #7853:
URL: https://github.com/apache/ignite/pull/7853#discussion_r435332313



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheCreateDestroyClusterReadOnlyModeTest.java
##########
@@ -0,0 +1,186 @@
+/*
+ * 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.ignite.internal.processors.cache;
+
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.junit.Test;
+
+import static java.util.Arrays.asList;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY;
+import static org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.cacheConfigurations;
+import static org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTestUtils.cacheNames;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/**
+ * Tests that {@link Ignite#createCache(CacheConfiguration)}/{@link Ignite#destroyCache(String)}/{@link IgniteCache#clear()}
+ * denied if cluster in a {@link ClusterState#ACTIVE_READ_ONLY} state.
+ */
+public class CacheCreateDestroyClusterReadOnlyModeTest extends CacheCreateDestroyClusterReadOnlyModeAbstractTest {
+    /** */
+    @Test
+    public void testCacheCreateDenied() {
+        grid(0).cluster().state(ACTIVE_READ_ONLY);
+
+        G.allGrids().forEach(n -> assertEquals(n.name(), ACTIVE_READ_ONLY, n.cluster().state()));
+
+        for (CacheConfiguration cfg : cacheConfigurations()) {
+            for (Ignite node : G.allGrids()) {
+                executeAndCheckException(() -> node.createCache(cfg), cfg.getName());
+                executeAndCheckException(() -> node.createCache(cfg.getName()), cfg.getName());
+            }
+        }
+    }
+
+    /** */
+    @Test
+    public void testGetOrCreateNotExistedCacheDenied() {

Review comment:
       copy paste of testCacheCreateDenied or i miss something ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] antonovsergey93 commented on a change in pull request #7853: IGNITE-13071: Improve test coverage of cluster read-only mode.

Posted by GitBox <gi...@apache.org>.
antonovsergey93 commented on a change in pull request #7853:
URL: https://github.com/apache/ignite/pull/7853#discussion_r435380808



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
##########
@@ -4759,6 +4763,8 @@ private boolean clearLocally0(K key, boolean readers) {
 
         ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
 
+        ctx.shared().cache().checkReadOnlyState("clear", ctx.config());

Review comment:
       Nice catch! Fixed




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org