kfaraz commented on code in PR #13074: URL: https://github.com/apache/druid/pull/13074#discussion_r972570643
########## server/src/test/java/org/apache/druid/server/coordinator/simulate/CoordinatorSimulationBaseTest.java: ########## @@ -0,0 +1,299 @@ +/* + * 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.druid.server.coordinator.simulate; + +import org.apache.druid.client.DruidServer; +import org.apache.druid.java.util.common.granularity.Granularities; +import org.apache.druid.java.util.emitter.core.Event; +import org.apache.druid.server.coordination.ServerType; +import org.apache.druid.server.coordinator.CoordinatorDynamicConfig; +import org.apache.druid.server.coordinator.CreateDataSegments; +import org.apache.druid.server.coordinator.rules.ForeverLoadRule; +import org.apache.druid.server.coordinator.rules.Rule; +import org.apache.druid.timeline.DataSegment; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Base test for coordinator simulations. + * <p> + * Each test must call {@link #startSimulation(CoordinatorSimulation)} to start + * the simulation. {@link CoordinatorSimulation#stop()} should not be called as + * the simulation is stopped when cleaning up after the test in {@link #tearDown()}. + * <p> + * Tests that verify balancing behaviour should set + * {@link CoordinatorDynamicConfig#useBatchedSegmentSampler()} to true. + * Otherwise, the segment sampling is random and can produce repeated values + * leading to flakiness in the tests. The simulation sets this field to true by + * default. + */ +public abstract class CoordinatorSimulationBaseTest Review Comment: I did start off with the fixture pattern but later decided to have a base test as it helps avoid every statement beginning with `fixture.`, which begins to feel redundant if every lines has it. The tests that have already been added shouldn't be likely to implement other interfaces. New tests that have conflicting inheritances could always treat the same base test as a fixture, I guess. -- 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]
