use of com.google.apphosting.api.logservice.LogServicePb.RequestLog in project appengine-java-standard by GoogleCloudPlatform.
the class LocalLogServiceTest method testSetEndTime.
@Test
public void testSetEndTime() throws Exception {
List<RequestLog> allLogs = getTestData(defaultStartTime, defaultVersion, defaultAppLogsDesired, completeLogsRequested);
writeTestData(allLogs, completeLogsRequested);
long endTime = 4;
// Logs are stored reverse-chronologically
List<Long> expectedLogStartTimes = new ArrayList<>();
for (RequestLog record : Lists.reverse(allLogs)) {
if (record.getEndTime() < endTime) {
expectedLogStartTimes.add(record.getStartTime());
}
}
LogQuery query = LogQuery.Builder.withEndTimeUsec(endTime);
List<Long> actualLogStartTimes = new ArrayList<>();
for (RequestLogs record : logService.fetch(query)) {
actualLogStartTimes.add(record.getStartTimeUsec());
}
String expected = joinLogStartTimes(expectedLogStartTimes);
String actual = joinLogStartTimes(actualLogStartTimes);
assertThat(actual).isEqualTo(expected);
}
use of com.google.apphosting.api.logservice.LogServicePb.RequestLog in project appengine-java-standard by GoogleCloudPlatform.
the class LogServiceImplTest method getAllLogsForAppVersions.
private void getAllLogsForAppVersions(LogQuery query, List<Version> moduleVersions) throws Exception {
List<RequestLog> expectedData = getTestData(LogService.DEFAULT_ITEMS_PER_FETCH);
Long startTime = null;
Long endTime = null;
Integer batchSize = null;
LogReadRequest request = createLogReadRequest(startTime, endTime, batchSize, moduleVersions);
LogReadResponse response = createLogReadResponse(expectedData);
setupExpectations(request, response);
List<RequestLogs> actualData = new ArrayList<>();
for (RequestLogs record : new LogServiceImpl().fetch(query)) {
actualData.add(record);
}
String expectedLogs = getJustCombinedRequestFields(expectedData);
String actualLogs = getJustCombinedFields(actualData);
assertThat(actualLogs).isEqualTo(expectedLogs);
}
use of com.google.apphosting.api.logservice.LogServicePb.RequestLog in project appengine-java-standard by GoogleCloudPlatform.
the class LogServiceImplTest method testGetLogsForTwoDaysAgoMillis.
@Test
public void testGetLogsForTwoDaysAgoMillis() throws Exception {
List<RequestLog> expectedData = getTestData(LogService.DEFAULT_ITEMS_PER_FETCH);
// Use millisecond-aligned microsecond timestamps.
Long endTimeUsec = getTimeForNDaysAgo(1, null) / 1000 * 1000;
Long startTimeUsec = getTimeForNDaysAgo(1, endTimeUsec) / 1000 * 1000;
Long endTimeMillis = endTimeUsec / 1000;
Long startTimeMillis = startTimeUsec / 1000;
Integer batchSize = null;
LogReadRequest request = createLogReadRequest(startTimeMillis * 1000, endTimeMillis * 1000, batchSize, null);
LogReadResponse response = createLogReadResponse(expectedData);
setupExpectations(request, response);
LogQuery query = LogQuery.Builder.withStartTimeMillis(startTimeMillis).endTimeMillis(endTimeMillis);
List<RequestLogs> actualData = new ArrayList<>();
for (RequestLogs record : new LogServiceImpl().fetch(query)) {
actualData.add(record);
}
String expectedLogs = getJustCombinedRequestFields(expectedData);
String actualLogs = getJustCombinedFields(actualData);
assertThat(actualLogs).isEqualTo(expectedLogs);
// Test the Usec/Millis variants.
assertThat(startTimeUsec).isEqualTo(query.getStartTimeUsec());
assertThat(endTimeUsec).isEqualTo(query.getEndTimeUsec());
assertThat(startTimeMillis).isEqualTo(query.getStartTimeMillis());
assertThat(endTimeMillis).isEqualTo(query.getEndTimeMillis());
query = LogQuery.Builder.withEndTimeMillis(endTimeMillis).startTimeMillis(startTimeMillis);
assertThat(startTimeUsec).isEqualTo(query.getStartTimeUsec());
assertThat(endTimeUsec).isEqualTo(query.getEndTimeUsec());
assertThat(startTimeMillis).isEqualTo(query.getStartTimeMillis());
assertThat(endTimeMillis).isEqualTo(query.getEndTimeMillis());
query = LogQuery.Builder.withDefaults();
assertThat(query.getStartTimeUsec()).isNull();
assertThat(query.getEndTimeUsec()).isNull();
assertThat(query.getStartTimeMillis()).isNull();
assertThat(query.getEndTimeMillis()).isNull();
}
Aggregations