|
@@ -49,6 +49,8 @@ import java.util.function.LongSupplier;
|
|
|
|
|
|
import static org.hamcrest.Matchers.either;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
+import static org.hamcrest.Matchers.not;
|
|
|
+import static org.hamcrest.Matchers.sameInstance;
|
|
|
|
|
|
public class DriverTests extends ESTestCase {
|
|
|
/**
|
|
@@ -252,6 +254,59 @@ public class DriverTests extends ESTestCase {
|
|
|
assertThat(driver.profile().iterations(), equalTo((long) inPages.size()));
|
|
|
}
|
|
|
|
|
|
+ public void testUnchangedStatus() {
|
|
|
+ DriverContext driverContext = driverContext();
|
|
|
+ List<Page> inPages = randomList(2, 100, DriverTests::randomPage);
|
|
|
+ List<Page> outPages = new ArrayList<>();
|
|
|
+
|
|
|
+ long startEpoch = randomNonNegativeLong();
|
|
|
+ long startNanos = randomLong();
|
|
|
+ long waitTime = randomLongBetween(10000, 100000);
|
|
|
+ long tickTime = randomLongBetween(10000, 100000);
|
|
|
+ long statusInterval = randomLongBetween(1, 10);
|
|
|
+
|
|
|
+ Driver driver = new Driver(
|
|
|
+ "unset",
|
|
|
+ "test",
|
|
|
+ startEpoch,
|
|
|
+ startNanos,
|
|
|
+ driverContext,
|
|
|
+ () -> "unset",
|
|
|
+ new CannedSourceOperator(inPages.iterator()),
|
|
|
+ List.of(),
|
|
|
+ new TestResultPageSinkOperator(outPages::add),
|
|
|
+ TimeValue.timeValueNanos(statusInterval),
|
|
|
+ () -> {}
|
|
|
+ );
|
|
|
+
|
|
|
+ NowSupplier nowSupplier = new NowSupplier(startNanos, waitTime, tickTime);
|
|
|
+
|
|
|
+ int iterationsPerTick = randomIntBetween(1, 10);
|
|
|
+
|
|
|
+ for (int i = 0; i < inPages.size(); i += iterationsPerTick) {
|
|
|
+ DriverStatus initialStatus = driver.status();
|
|
|
+ long completedOperatorsHash = initialStatus.completedOperators().hashCode();
|
|
|
+ long activeOperatorsHash = initialStatus.activeOperators().hashCode();
|
|
|
+ long sleepsHash = initialStatus.sleeps().hashCode();
|
|
|
+
|
|
|
+ driver.run(TimeValue.timeValueDays(10), iterationsPerTick, nowSupplier);
|
|
|
+
|
|
|
+ DriverStatus newStatus = driver.status();
|
|
|
+ assertThat(newStatus, not(sameInstance(initialStatus)));
|
|
|
+ assertThat(
|
|
|
+ newStatus.completedOperators() != initialStatus.completedOperators()
|
|
|
+ || newStatus.completedOperators().hashCode() == completedOperatorsHash,
|
|
|
+ equalTo(true)
|
|
|
+ );
|
|
|
+ assertThat(
|
|
|
+ newStatus.activeOperators() != initialStatus.activeOperators()
|
|
|
+ || newStatus.activeOperators().hashCode() == activeOperatorsHash,
|
|
|
+ equalTo(true)
|
|
|
+ );
|
|
|
+ assertThat(newStatus.sleeps() != initialStatus.sleeps() || newStatus.sleeps().hashCode() == sleepsHash, equalTo(true));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
class NowSupplier implements LongSupplier {
|
|
|
private final long startNanos;
|
|
|
private final long waitTime;
|