Search in sources :

Example 91 with Duration

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);
}
Also used : Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Example 92 with Duration

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);
}
Also used : Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Example 93 with Duration

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);
}
Also used : Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Example 94 with Duration

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);
}
Also used : Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Example 95 with Duration

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);
    }
}
Also used : Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (io.airlift.units.Duration)124 Test (org.testng.annotations.Test)66 DataSize (io.airlift.units.DataSize)35 URI (java.net.URI)12 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)11 Session (com.facebook.presto.Session)9 DateTime (org.joda.time.DateTime)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 ImmutableSet (com.google.common.collect.ImmutableSet)8 TestingTicker (io.airlift.testing.TestingTicker)8 List (java.util.List)8 PrestoException (com.facebook.presto.spi.PrestoException)7 ImmutableList (com.google.common.collect.ImmutableList)7 File (java.io.File)6 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 CyclicBarrier (java.util.concurrent.CyclicBarrier)5 Produces (javax.ws.rs.Produces)5 Type (com.facebook.presto.spi.type.Type)4 IOException (java.io.IOException)4