dcapwell commented on code in PR #4556: URL: https://github.com/apache/cassandra/pull/4556#discussion_r2748585296
########## test/distributed/org/apache/cassandra/distributed/test/thresholds/AbstractWriteThresholdWarning.java: ########## @@ -0,0 +1,293 @@ +/* + * 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.cassandra.distributed.test.thresholds; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Random; + +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.SimpleStatement; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.distributed.Cluster; +import org.apache.cassandra.distributed.api.ConsistencyLevel; +import org.apache.cassandra.distributed.api.Feature; +import org.apache.cassandra.distributed.api.ICluster; +import org.apache.cassandra.distributed.api.IInvokableInstance; +import org.apache.cassandra.distributed.api.SimpleQueryResult; +import org.apache.cassandra.distributed.test.JavaDriverUtils; +import org.apache.cassandra.distributed.test.TestBaseImpl; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Base class for write threshold warning distributed tests. + * Tests coordinator-side warning aggregation from replica responses. + */ +public abstract class AbstractWriteThresholdWarning extends TestBaseImpl +{ + private static final Random RANDOM = new Random(0); Review Comment: this isn't safe, if a test fails it might not be able to reproduce; even though you control the seed. The reason is that junit is allowed to run tests in any order it wants, so it might fail in CI and pass locally; you have 2 different "random histories" `CQLTester.Fuzzed` solves this with the following ``` @Before public void resetSeed() { RANDOM.setSeed(SEED); } ``` it also comments asking not to follow this pattern as it limits the test. It came about to fix a large group of tests with this bug... rewrite all tests *or* document that this is bad and make it deterministic... Now, looking close at the usage, majority of the time is for the `value` and not the `partition`... and the test never looks at it... is there a reason we even need randomness? `new byte[512]` looks to solve the same expected behavior? It would be cheaper, deterministic, and less 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

