ctubbsii commented on code in PR #5582:
URL: https://github.com/apache/accumulo/pull/5582#discussion_r2109988185
##########
server/base/src/test/java/org/apache/accumulo/server/conf/SystemConfigurationTest.java:
##########
@@ -79,6 +79,8 @@ public void initMocks() {
new VersionedProperties(1, Instant.now(), Map.of(GC_PORT.getKey(),
"1234",
TSERV_SCAN_MAX_OPENFILES.getKey(), "19",
TABLE_BLOOM_ENABLED.getKey(), "true"));
expect(propStore.get(eq(sysPropKey))).andReturn(sysProps).times(2);
+ propStore.invalidate(sysPropKey);
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java:
##########
@@ -81,6 +81,8 @@ public void setUp() {
Map.of(Property.INSTANCE_SECRET.getKey(), "sekrit"))).anyTimes();
propStore.registerAsListener(eq(nsPropStoreKey), anyObject());
expectLastCall().anyTimes();
+ propStore.invalidate(nsPropStoreKey);
+ expectLastCall().anyTimes();
Review Comment:
I've found that `atLeastOnce()` is usually what we want when we use
`anyTimes()`
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java:
##########
@@ -159,6 +163,8 @@ public void testGet_InParent() {
.anyTimes();
expect(propStore.get(eq(TablePropKey.of(instanceId, TID))))
.andReturn(new VersionedProperties(Map.of())).anyTimes();
+ propStore.invalidate(NamespacePropKey.of(instanceId, NID));
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java:
##########
@@ -101,6 +101,8 @@ public void initMocks() {
VersionedProperties tableProps =
new VersionedProperties(3, Instant.now(),
Map.of(TABLE_BLOOM_ENABLED.getKey(), "true"));
expect(propStore.get(eq(tablePropKey))).andReturn(tableProps).once();
+ propStore.invalidate(tablePropKey);
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java:
##########
@@ -138,6 +140,8 @@ public void testGet_InZK() {
expect(propStore.get(eq(propKey)))
.andReturn(new VersionedProperties(37, Instant.now(),
Map.of(p.getKey(), "sekrit")))
.anyTimes();
+ propStore.invalidate(propKey);
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java:
##########
@@ -221,6 +231,10 @@ public void testGetFilteredProperties() {
expect(propStore.get(eq(TablePropKey.of(instanceId, TID)))).andReturn(new
VersionedProperties(4,
Instant.now(), Map.of("filter", "not_returned_by_table", "foo", "bar",
"tick", "tock")))
.anyTimes();
+ propStore.invalidate(TablePropKey.of(instanceId, TID));
+ expectLastCall().anyTimes();
+ propStore.invalidate(NamespacePropKey.of(instanceId, NID));
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
propStore.invalidate(TablePropKey.of(instanceId, TID));
expectLastCall().atLeastOnce();
propStore.invalidate(NamespacePropKey.of(instanceId, NID));
expectLastCall().atLeastOnce();
```
##########
test/src/main/java/org/apache/accumulo/test/functional/AccumuloConfigurationIT.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.test.functional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.time.Duration;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.harness.MiniClusterConfigurationCallback;
+import org.apache.accumulo.harness.SharedMiniClusterBase;
+import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.hadoop.conf.Configuration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+public class AccumuloConfigurationIT extends SharedMiniClusterBase {
+
+ private static final String fakeProperty = "general.custom.fake.property";
+
+ private static class ConfigurationCallback implements
MiniClusterConfigurationCallback {
+
+ @Override
+ public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration
coreSite) {
+ cfg.setProperty(fakeProperty, "1");
+ }
+
+ }
+
+ @BeforeAll
+ public static void beforeTests() throws Exception {
+ SharedMiniClusterBase.startMiniClusterWithConfig(new
ConfigurationCallback());
+ }
+
+ @AfterAll
+ public static void afterTests() {
+ SharedMiniClusterBase.stopMiniCluster();
+ }
+
+ @Test
+ public void testInvalidation() throws Exception {
+
+ final ServerContext ctx = getCluster().getServerContext();
+ String initialThreads = ctx.getConfiguration().get(fakeProperty);
+
+ long startTime = 0;
+ try (AccumuloClient c =
Accumulo.newClient().from(getClientProps()).build()) {
+ startTime = System.nanoTime();
+ c.instanceOperations().setProperty(fakeProperty, "4");
+ }
+
+ ctx.getConfiguration().invalidateCache();
+
+ int oldValueReturned = 0;
+ while (ctx.getConfiguration().get(fakeProperty).equals(initialThreads)) {
+ oldValueReturned++;
+ Thread.sleep(25);
+ }
+ long stopTime = System.nanoTime();
+ System.out.println("Configuration returned old value " + oldValueReturned
+ " times and took "
+ + Duration.ofNanos(stopTime - startTime).toMillis() + "ms");
Review Comment:
I believe we have a time duration stopwatch like utility for this kind of
thing.
##########
server/base/src/test/java/org/apache/accumulo/server/conf/SystemConfigurationTest.java:
##########
@@ -117,6 +119,8 @@ public void testFromFixed() {
Map.of(GC_PORT.getKey(), "3456", TSERV_SCAN_MAX_OPENFILES.getKey(),
"27",
TABLE_BLOOM_ENABLED.getKey(), "false", TABLE_BLOOM_SIZE.getKey(),
"2048"));
expect(propStore.get(eq(sysPropKey))).andReturn(sysUpdateProps).anyTimes();
+ propStore.invalidate(sysPropKey);
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/util/PropSnapshotTest.java:
##########
@@ -70,6 +70,8 @@ public void getTest() {
// after update
expect(propStore.get(eq(SystemPropKey.of(instanceId))))
.andReturn(new VersionedProperties(124, Instant.now(), Map.of("k3",
"v3"))).once();
+ propStore.invalidate(SystemPropKey.of(instanceId));
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java:
##########
@@ -257,6 +271,8 @@ public void testInvalidateCache() {
.once();
expect(propStore.get(eq(propKey)))
.andReturn(new VersionedProperties(39, Instant.now(),
Map.of(p.getKey(), "sekrit"))).once();
+ propStore.invalidate(propKey);
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java:
##########
@@ -184,6 +190,10 @@ public void testGetProperties() {
expect(propStore.get(eq(TablePropKey.of(instanceId, TID))))
.andReturn(new VersionedProperties(4, Instant.now(), Map.of("foo",
"bar", "tick", "tock")))
.anyTimes();
+ propStore.invalidate(TablePropKey.of(instanceId, TID));
+ expectLastCall().anyTimes();
+ propStore.invalidate(NamespacePropKey.of(instanceId, NID));
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
propStore.invalidate(TablePropKey.of(instanceId, TID));
expectLastCall().atLeastOnce();
propStore.invalidate(NamespacePropKey.of(instanceId, NID));
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/util/PropSnapshotTest.java:
##########
@@ -97,6 +99,8 @@ public void eventChangeTest() {
expect(propStore.get(eq(sysPropKey))).andReturn(
new VersionedProperties(100, Instant.now(),
Map.of(TABLE_BLOOM_ENABLED.getKey(), "false")))
.once();
+ propStore.invalidate(SystemPropKey.of(instanceId));
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
##########
server/base/src/test/java/org/apache/accumulo/server/conf/util/PropSnapshotTest.java:
##########
@@ -120,6 +124,8 @@ public void deleteEventTest() {
expect(propStore.get(eq(sysPropKey))).andThrow(new
IllegalStateException("Fake node delete"))
.once();
+ propStore.invalidate(sysPropKey);
+ expectLastCall().anyTimes();
Review Comment:
```suggestion
expectLastCall().atLeastOnce();
```
--
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]