Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/132260.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 132260
summary: FIx Driver creating status with a live list of operators
area: ES|QL
type: bug
issues:
- 131564
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ private void updateStatus(long extraCpuNanos, int extraIterations, DriverStatus.
prev.cpuNanos() + extraCpuNanos,
prev.iterations() + extraIterations,
status,
statusOfCompletedOperators,
List.copyOf(statusOfCompletedOperators),
activeOperators.stream().map(op -> new OperatorStatus(op.toString(), op.status())).toList(),
sleeps
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

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 {
/**
Expand Down Expand Up @@ -204,6 +206,47 @@ public void testProfileAndStatusInterval() {
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 = createDriver(startEpoch, startNanos, driverContext, inPages, outPages, 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));
}
}

private static Driver createDriver(
long startEpoch,
long startNanos,
Expand Down
Loading