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);
}
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());
}
}
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());
}
}
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());
}
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());
}
}
Aggregations