ctubbsii commented on a change in pull request #1851: URL: https://github.com/apache/accumulo/pull/1851#discussion_r552254975
########## 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: Thanks for including the description of how the test works. It helps a lot. I'm still unclear on the term "chain of updates", and a few other things though. "chain of updates" is mentioned in the "sanity checks", but is not explained. It looks like you have 16 threads, each writing 200 times. Is a group of 200 in a single thread considered a "chain of updates" or something else? What ensures each write in a chain is uniquely identifiable (within a chain, or across threads)? And how do updates in a "chain" relate to one another? Are there certain transitions that are valid to mutate, and others not valid? Also, what does countCounts actually store a mapping of? Both the key and the value are Integer, but it's not clear what the key is supposed to represent vs. the value. It's also a bit difficult to parse what `countCounts.merge(count, 1, Integer::sum)` is doing. Is this just tracking the frequency of occurrence for whatever the key in the map represents? Sorry for all the questions. I've been staring at this code for an hour, and while I get the general idea, I also know that in its current state, I don't think I'd be able to fix it if it were broken. Nit: While HTML5 isn't case-sensitive with regard to HTML tags, it's [good practice](https://stackoverflow.com/a/19808671) to use lowercase for tag and attribute names. It's also more consistent with (most of) the rest of our code. ---------------------------------------------------------------- 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