kirklund commented on a change in pull request #7116: URL: https://github.com/apache/geode/pull/7116#discussion_r758779814
########## File path: geode-core/src/distributedTest/java/org/apache/geode/security/SecurityManagerAvailabilityDUnitTest.java ########## @@ -0,0 +1,117 @@ +/* + * + * 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.geode.security; + + +import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT; +import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_LOG_LEVEL; +import static org.apache.geode.internal.security.SecurityServiceFactory.TEST_SECURITY_SERVICE_SYSTEM_PROPERTY; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.stream.IntStream; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientRegionShortcut; +import org.apache.geode.internal.cache.InternalCache; +import org.apache.geode.test.dunit.rules.ClientVM; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.dunit.rules.SerializableFunction; +import org.apache.geode.test.junit.categories.SecurityTest; +import org.apache.geode.test.junit.rules.ServerStarterRule; + +@Category({SecurityTest.class}) +public class SecurityManagerAvailabilityDUnitTest { + @Rule + public ClusterStartupRule clusterStartupRule = new ClusterStartupRule(); + + private MemberVM server1; + private MemberVM server2; + private ClientVM clientVM; + + @Before + public void setup() throws Exception { + MemberVM locatorVM = + clusterStartupRule.startLocatorVM(0, + l -> l.withSecurityManager(ExpirableSecurityManager.class) + .withProperty(SECURITY_LOG_LEVEL, "debug")); + int locatorPort = locatorVM.getPort(); + + SerializableFunction<ServerStarterRule> severStarterFunction = s -> s + .withSecurityManager(ExpirableSecurityManager.class) + .withProperty(SECURITY_LOG_LEVEL, "debug") + .withCredential("test", "test") + .withConnectionToLocator(locatorPort) + .withRegion(RegionShortcut.REPLICATE, "region") + .withSystemProperty(TEST_SECURITY_SERVICE_SYSTEM_PROPERTY, + TestIntegratedSecurityService.class.getName()); + + server1 = clusterStartupRule.startServerVM(1, severStarterFunction); + server2 = clusterStartupRule.startServerVM(2, severStarterFunction); + + int serverVM0Port = server1.getPort(); + int serverVM1Port = server2.getPort(); + clientVM = clusterStartupRule.startClientVM(3, + c -> c.withServerConnection(serverVM0Port, serverVM1Port) + .withPoolSubscription(true) + .withProperty(SECURITY_LOG_LEVEL, "debug") + .withProperty(SECURITY_CLIENT_AUTH_INIT, UpdatableUserAuthInitialize.class.getName())); + } + + @Test + public void confirmSecurityManagerAvailabilityExceptionDoesNotStopClientPutOperations() { + clientVM.invoke(() -> { + ClientCache clientCache = ClusterStartupRule.getClientCache(); + UpdatableUserAuthInitialize.setUser("data1"); + Region<Object, Object> region = + clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("region"); + + // even though we throw exceptions in the security service, the client will retry another + // server, so client wouldn't see any exceptions + IntStream.range(0, 1000).forEach(i -> region.put(i, "value" + i)); + }); + + Integer timeFailedOnServer1 = server1.invoke( Review comment: You should just use primitives (such as `int`) everywhere by default instead of wrapper classes like `Integer`. ########## File path: geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/MessageDispatcher.java ########## @@ -113,6 +113,8 @@ */ private volatile boolean _isStopped = true; + private volatile long wait_for_re_auth_start_time = -1; Review comment: Let's do two things here. One `re` is too abbreviated. Spell it out. Also please switch to camel case even if some of the surrounding code uses the wrong case. (Camel case just means `waitForSomethingAuthStartTime`) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
