Search in sources :

Example 1 with TaskQueueModifyTaskLeaseRequest

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testExtendTaskLeaseInvalidTaskName.

@Test
public void testExtendTaskLeaseInvalidTaskName() throws Exception {
    TaskQueueModifyTaskLeaseRequest extendRequest = TaskQueueModifyTaskLeaseRequest.newBuilder().setQueueName(ByteString.copyFromUtf8("pull-queue")).setTaskName(ByteString.copyFromUtf8("****invalid*****")).setEtaUsec(0).setLeaseSeconds(30).build();
    ApiProxy.ApplicationException e = assertThrows(ApiProxy.ApplicationException.class, () -> localService.modifyTaskLease(new Status(), extendRequest));
    assertThat(e.getApplicationError()).isEqualTo(ErrorCode.INVALID_TASK_NAME_VALUE);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) ApiProxy(com.google.apphosting.api.ApiProxy) TaskQueueModifyTaskLeaseRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest) Test(org.junit.Test)

Example 2 with TaskQueueModifyTaskLeaseRequest

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest in project appengine-java-standard by GoogleCloudPlatform.

the class DevPullQueueTest method testExtendTaskLeaseUnknownTaskName.

public void testExtendTaskLeaseUnknownTaskName() {
    TaskQueueAddRequest.Builder addRequest = newAddRequest(0);
    queue.add(addRequest);
    clock.setTimeMillis(10000);
    List<TaskQueueAddRequest.Builder> response = queue.queryAndOwnTasks(30, 1, false, null);
    clock.setTimeMillis(15000);
    TaskQueueModifyTaskLeaseRequest request = TaskQueueModifyTaskLeaseRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(PULL_QUEUE_NAME)).setTaskName(ByteString.copyFromUtf8("unknowntask")).setEtaUsec(response.get(0).getEtaUsec()).setLeaseSeconds(60).build();
    try {
        queue.modifyTaskLease(request);
        fail();
    } catch (ApiProxy.ApplicationException exception) {
        // expected.
        assertEquals(ErrorCode.UNKNOWN_TASK_VALUE, exception.getApplicationError());
    }
}
Also used : TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) ApiProxy(com.google.apphosting.api.ApiProxy) TaskQueueModifyTaskLeaseRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)

Example 3 with TaskQueueModifyTaskLeaseRequest

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest in project appengine-java-standard by GoogleCloudPlatform.

the class DevPullQueueTest method testExtendTaskLeaseLeaseExpiredByReLease.

public void testExtendTaskLeaseLeaseExpiredByReLease() {
    TaskQueueAddRequest.Builder addRequest = newAddRequest(0);
    queue.add(addRequest);
    clock.setTimeMillis(10000);
    List<TaskQueueAddRequest.Builder> response = queue.queryAndOwnTasks(30, 1, false, null);
    clock.setTimeMillis(15000);
    TaskQueueModifyTaskLeaseRequest request = TaskQueueModifyTaskLeaseRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(PULL_QUEUE_NAME)).setTaskName(response.get(0).getTaskName()).setEtaUsec(response.get(0).getEtaUsec() - 1).setLeaseSeconds(60).build();
    try {
        queue.modifyTaskLease(request);
        fail();
    } catch (ApiProxy.ApplicationException exception) {
        // expected.
        assertEquals(ErrorCode.TASK_LEASE_EXPIRED_VALUE, exception.getApplicationError());
    }
}
Also used : TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) ApiProxy(com.google.apphosting.api.ApiProxy) TaskQueueModifyTaskLeaseRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)

Example 4 with TaskQueueModifyTaskLeaseRequest

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest in project appengine-java-standard by GoogleCloudPlatform.

the class DevPullQueueTest method testExtendTaskLease.

public void testExtendTaskLease() {
    TaskQueueAddRequest.Builder addRequest = newAddRequest(0);
    queue.add(addRequest);
    clock.setTimeMillis(10000);
    List<TaskQueueAddRequest.Builder> response = queue.queryAndOwnTasks(30, 1, false, null);
    clock.setTimeMillis(15000);
    TaskQueueModifyTaskLeaseRequest request = TaskQueueModifyTaskLeaseRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(PULL_QUEUE_NAME)).setTaskName(response.get(0).getTaskName()).setEtaUsec(response.get(0).getEtaUsec()).setLeaseSeconds(60).build();
    long expectedEtaUsec = (long) (75 * 1e6);
    assertEquals(expectedEtaUsec, queue.modifyTaskLease(request).getUpdatedEtaUsec());
}
Also used : TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) TaskQueueModifyTaskLeaseRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)

Example 5 with TaskQueueModifyTaskLeaseRequest

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest in project appengine-java-standard by GoogleCloudPlatform.

the class DevPullQueueTest method testExtendTaskLeaseLeaseExpiredByClock.

public void testExtendTaskLeaseLeaseExpiredByClock() {
    TaskQueueAddRequest.Builder addRequest = newAddRequest(0);
    queue.add(addRequest);
    clock.setTimeMillis(10000);
    List<TaskQueueAddRequest.Builder> response = queue.queryAndOwnTasks(30, 1, false, null);
    clock.setTimeMillis(60000);
    TaskQueueModifyTaskLeaseRequest request = TaskQueueModifyTaskLeaseRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(PULL_QUEUE_NAME)).setTaskName(response.get(0).getTaskName()).setEtaUsec(response.get(0).getEtaUsec()).setLeaseSeconds(60).build();
    try {
        queue.modifyTaskLease(request);
        fail();
    } catch (ApiProxy.ApplicationException exception) {
        // expected.
        assertEquals(ErrorCode.TASK_LEASE_EXPIRED_VALUE, exception.getApplicationError());
    }
}
Also used : TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) ApiProxy(com.google.apphosting.api.ApiProxy) TaskQueueModifyTaskLeaseRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)

Aggregations

TaskQueueModifyTaskLeaseRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)8 ApiProxy (com.google.apphosting.api.ApiProxy)6 TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)4 Status (com.google.appengine.tools.development.LocalRpcService.Status)4 Test (org.junit.Test)4 TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)1 TaskQueueModifyTaskLeaseResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseResponse)1 TaskQueueQueryAndOwnTasksRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksRequest)1 TaskQueueQueryAndOwnTasksResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksResponse)1 Clock (com.google.appengine.tools.development.Clock)1