keith-turner commented on a change in pull request #1851: URL: https://github.com/apache/accumulo/pull/1851#discussion_r552316426
########## File path: test/src/main/java/org/apache/accumulo/test/functional/ZooMutatorIT.java ########## @@ -0,0 +1,150 @@ +/* + * 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.accumulo.test.functional; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.apache.accumulo.core.client.Accumulo; +import org.apache.accumulo.core.clientImpl.ClientContext; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.fate.zookeeper.ZooReaderWriter; +import org.apache.accumulo.harness.AccumuloClusterHarness; +import org.apache.accumulo.test.categories.MiniClusterOnlyTests; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import com.google.common.io.BaseEncoding; + +@Category(MiniClusterOnlyTests.class) +public class ZooMutatorIT extends AccumuloClusterHarness { + /** + * This test uses multiple threads to update the data in a single zookeeper node using + * {@link ZooReaderWriter#mutateOrCreate(String, byte[], org.apache.accumulo.fate.zookeeper.ZooReaderWriter.Mutator)} + * and tries to detect errors and race conditions in that code. Each thread uses + * {@link #nextValue(String)} to compute a new value for the ZK node based on the current value, + * producing a new unique value. The test has sanity checks for the following conditions: + * + * <UL> + * <LI>All updates in the chain of updates were made, none were skipped. + * <LI>No update in the chain of updates is made twice. For example if two threads wrote the exact + * same value to the node this should be detected by the test. + * <LI>The updates in the chain of updates were made in the proper order. + * </UL> Review comment: I updated the test description and I dropped the term "chain of updates". Let me know if the updates are helpful. > It's also a bit difficult to parse what countCounts.merge(count, 1, Integer::sum) is doing. The goal of this is to detect duplicate or missing updates to zookeeper. Each update increments a counter in the data, all the counter values updated are recorded in the map and each counter value should be seen once. The chain of hashes could detect missing and out of order updates, but not duplicate updates. That is why the stronger check was added for duplicate updates using the map. There is weak ordering check on the counts using an assertion, I think the chain of hashes provided a much stronger ordering check. ---------------------------------------------------------------- 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: us...@infra.apache.org