use of io.airlift.units.Duration in project presto by prestodb.
the class TestQueryStateMachine method testFinished.
@Test
public void testFinished() throws InterruptedException {
QueryStateMachine stateMachine = createQueryStateMachine();
assertTrue(stateMachine.transitionToFinishing());
stateMachine.waitForStateChange(FINISHING, new Duration(2, TimeUnit.SECONDS));
assertFinalState(stateMachine, FINISHED);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestQueryStateMachine method testRunning.
@Test
public void testRunning() throws InterruptedException {
QueryStateMachine stateMachine = createQueryStateMachine();
assertTrue(stateMachine.transitionToRunning());
assertState(stateMachine, RUNNING);
assertFalse(stateMachine.transitionToPlanning());
assertState(stateMachine, RUNNING);
assertFalse(stateMachine.transitionToStarting());
assertState(stateMachine, RUNNING);
assertFalse(stateMachine.transitionToRunning());
assertState(stateMachine, RUNNING);
assertTrue(stateMachine.transitionToFinishing());
stateMachine.waitForStateChange(FINISHING, new Duration(2, TimeUnit.SECONDS));
assertState(stateMachine, FINISHED);
stateMachine = createQueryStateMachine();
stateMachine.transitionToRunning();
assertTrue(stateMachine.transitionToFailed(FAILED_CAUSE));
assertState(stateMachine, FAILED, FAILED_CAUSE);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestQueryStateMachine method testBasicStateChanges.
@Test
public void testBasicStateChanges() throws InterruptedException {
QueryStateMachine stateMachine = createQueryStateMachine();
assertState(stateMachine, QUEUED);
assertTrue(stateMachine.transitionToPlanning());
assertState(stateMachine, PLANNING);
assertTrue(stateMachine.transitionToStarting());
assertState(stateMachine, STARTING);
assertTrue(stateMachine.transitionToRunning());
assertState(stateMachine, RUNNING);
assertTrue(stateMachine.transitionToFinishing());
stateMachine.waitForStateChange(FINISHING, new Duration(2, TimeUnit.SECONDS));
assertState(stateMachine, FINISHED);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestQueryStateMachine method testQueued.
@Test
public void testQueued() throws InterruptedException {
QueryStateMachine stateMachine = createQueryStateMachine();
assertState(stateMachine, QUEUED);
assertTrue(stateMachine.transitionToPlanning());
assertState(stateMachine, PLANNING);
stateMachine = createQueryStateMachine();
assertTrue(stateMachine.transitionToStarting());
assertState(stateMachine, STARTING);
stateMachine = createQueryStateMachine();
assertTrue(stateMachine.transitionToRunning());
assertState(stateMachine, RUNNING);
stateMachine = createQueryStateMachine();
assertTrue(stateMachine.transitionToFinishing());
stateMachine.waitForStateChange(FINISHING, new Duration(2, TimeUnit.SECONDS));
assertState(stateMachine, FINISHED);
stateMachine = createQueryStateMachine();
assertTrue(stateMachine.transitionToFailed(FAILED_CAUSE));
assertState(stateMachine, FAILED, FAILED_CAUSE);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestSplitConcurrencyController method testRampup.
@Test
public void testRampup() {
SplitConcurrencyController controller = new SplitConcurrencyController(1, new Duration(1, SECONDS));
for (int i = 0; i < 10; i++) {
controller.update(SECONDS.toNanos(2), 0, i + 1);
assertEquals(controller.getTargetConcurrency(), i + 2);
}
}
Aggregations