From 29173a5e7ec27236f197a1b7af9357740ec95900 Mon Sep 17 00:00:00 2001 From: Young Gyu Park Date: Tue, 14 Aug 2018 11:12:02 +0900 Subject: Updating job servlet because of entity change Test: go/vts-web-staging Bug: 111481322 Change-Id: Ia868197a428cdbb318690e5c75312f68110b2268 --- .../com/android/vts/job/VtsAlertJobServlet.java | 24 ++++++++++-------- .../vts/job/VtsCoverageAlertJobServlet.java | 2 +- .../android/vts/job/VtsInactivityJobServlet.java | 8 +++--- .../vts/job/VtsProfilingStatsJobServlet.java | 29 +++++++++++----------- 4 files changed, 33 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/main/java/com/android/vts/job/VtsAlertJobServlet.java b/src/main/java/com/android/vts/job/VtsAlertJobServlet.java index 511017f..7e66ac8 100644 --- a/src/main/java/com/android/vts/job/VtsAlertJobServlet.java +++ b/src/main/java/com/android/vts/job/VtsAlertJobServlet.java @@ -77,13 +77,13 @@ public class VtsAlertJobServlet extends HttpServlet { * @returns a map from test case name to the test case run ID for which the test case failed. */ private static Map getCurrentFailures(TestStatusEntity status) { - if (status.failingTestCases == null || status.failingTestCases.size() == 0) { + if (status.getFailingTestCases() == null || status.getFailingTestCases().size() == 0) { return new HashMap<>(); } DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Map failingTestcases = new HashMap<>(); Set gets = new HashSet<>(); - for (TestCaseReference testCaseRef : status.failingTestCases) { + for (TestCaseReference testCaseRef : status.getFailingTestCases()) { gets.add(KeyFactory.createKey(TestCaseRunEntity.KIND, testCaseRef.parentId)); } if (gets.size() == 0) { @@ -91,7 +91,7 @@ public class VtsAlertJobServlet extends HttpServlet { } Map testCaseMap = datastore.get(gets); - for (TestCaseReference testCaseRef : status.failingTestCases) { + for (TestCaseReference testCaseRef : status.getFailingTestCases()) { Key key = KeyFactory.createKey(TestCaseRunEntity.KIND, testCaseRef.parentId); if (!testCaseMap.containsKey(key)) { continue; @@ -119,7 +119,7 @@ public class VtsAlertJobServlet extends HttpServlet { List acks = new ArrayList<>(); Filter testFilter = new Query.FilterPredicate( - TestAcknowledgmentEntity.TEST_KEY, Query.FilterOperator.EQUAL, testKey); + TestAcknowledgmentEntity.TEST_KEY, Query.FilterOperator.EQUAL, testKey); Query q = new Query(TestAcknowledgmentEntity.KIND).setFilter(testFilter); for (Entity ackEntity : datastore.prepare(q).asIterable()) { @@ -133,7 +133,7 @@ public class VtsAlertJobServlet extends HttpServlet { /** * Get the test runs for the test in the specified time window. * - * If the start and end time delta is greater than one day, the query will be truncated. + *

If the start and end time delta is greater than one day, the query will be truncated. * * @param testKey The key to the test whose runs to query. * @param startTime The start time for the query. @@ -188,9 +188,9 @@ public class VtsAlertJobServlet extends HttpServlet { if (!isRelevant) { for (DeviceInfoEntity device : devices) { boolean deviceAcknowledged = - allDevices || ack.devices.contains(device.buildFlavor); + allDevices || ack.devices.contains(device.getBuildFlavor()); boolean branchAcknowledged = - allBranches || ack.branches.contains(device.branch); + allBranches || ack.branches.contains(device.getBranch()); if (deviceAcknowledged && branchAcknowledged) isRelevant = true; } } @@ -308,7 +308,7 @@ public class VtsAlertJobServlet extends HttpServlet { if (deviceEntity == null) { continue; } - buildIdList.add(deviceEntity.buildId); + buildIdList.add(deviceEntity.getBuildId()); devices.add(deviceEntity); } String footer = EmailHelper.getEmailFooter(mostRecentRun, devices, link); @@ -519,7 +519,7 @@ public class VtsAlertJobServlet extends HttpServlet { if (status == null) { status = new TestStatusEntity(testName); } - if (status.timestamp >= testRunKey.getId()) { + if (status.getUpdatedTimestamp() >= testRunKey.getId()) { // Another job has already updated the status first return; } @@ -535,7 +535,8 @@ public class VtsAlertJobServlet extends HttpServlet { List testAcks = getTestCaseAcknowledgments(testRunKey.getParent()); List testRuns = - getTestRuns(testRunKey.getParent(), status.timestamp, testRunKey.getId()); + getTestRuns( + testRunKey.getParent(), status.getUpdatedTimestamp(), testRunKey.getId()); if (testRuns.size() == 0) return; TestStatusEntity newStatus = @@ -554,7 +555,8 @@ public class VtsAlertJobServlet extends HttpServlet { } catch (EntityNotFoundException e) { // no status left } - if (status == null || status.timestamp >= newStatus.timestamp) { + if (status == null + || status.getUpdatedTimestamp() >= newStatus.getUpdatedTimestamp()) { txn.rollback(); } else { // This update is most recent. datastore.put(newStatus.toEntity()); diff --git a/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java b/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java index a112496..bb82749 100644 --- a/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java +++ b/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java @@ -134,7 +134,7 @@ public class VtsCoverageAlertJobServlet extends HttpServlet { continue; } devices.add(deviceEntity); - buildIdList.add(deviceEntity.buildId); + buildIdList.add(deviceEntity.getBuildId()); } String deviceBuild = StringUtils.join(buildIdList, ", "); String footer = EmailHelper.getEmailFooter(testRunEntity, devices, link); diff --git a/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java b/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java index 7e52987..ce2b77a 100644 --- a/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java +++ b/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java @@ -78,10 +78,10 @@ public class VtsInactivityJobServlet extends HttpServlet { // test is assumed to be deprecated). if (diff >= TimeUnit.DAYS.toMicros(1) && diff < TimeUnit.DAYS.toMicros(8)) { String uploadTimeString = TimeUtil.getDateTimeString(lastRunTime); - String subject = "Warning! Inactive test: " + test.testName; + String subject = "Warning! Inactive test: " + test.getTestName(); String body = "Hello,

Test \"" - + test.testName + + test.getTestName() + "\" is inactive. " + "No new data has been uploaded since " + uploadTimeString @@ -159,12 +159,12 @@ public class VtsInactivityJobServlet extends HttpServlet { if (status == null) { return; } - Key testKey = KeyFactory.createKey(TestEntity.KIND, status.testName); + Key testKey = KeyFactory.createKey(TestEntity.KIND, status.getTestName()); long lastRunTime = getLastRunTime(testKey); StringBuffer fullUrl = request.getRequestURL(); String baseUrl = fullUrl.substring(0, fullUrl.indexOf(request.getRequestURI())); - String link = baseUrl + "/show_tree?testName=" + status.testName; + String link = baseUrl + "/show_tree?testName=" + status.getTestName(); List messageQueue = new ArrayList<>(); List emails; diff --git a/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java b/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java index c118b09..96d635d 100644 --- a/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java +++ b/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java @@ -121,11 +121,11 @@ public class VtsProfilingStatsJobServlet extends HttpServlet { ProfilingPointEntity profilingPoint = new ProfilingPointEntity( testKey.getName(), - profilingPointRun.name, - profilingPointRun.type.getNumber(), - profilingPointRun.regressionMode.getNumber(), - profilingPointRun.xLabel, - profilingPointRun.yLabel); + profilingPointRun.getName(), + profilingPointRun.getType(), + profilingPointRun.getRegressionMode(), + profilingPointRun.getXLabel(), + profilingPointRun.getYLabel()); puts.add(profilingPoint.toEntity()); String option = PerformanceUtil.getOptionAlias(profilingPointRun, splitKeySet); @@ -137,8 +137,8 @@ public class VtsProfilingStatsJobServlet extends HttpServlet { deviceNames.add(ProfilingPointSummaryEntity.ALL); for (DeviceInfoEntity d : devices) { - branches.add(d.branch); - deviceNames.add(d.buildFlavor); + branches.add(d.getBranch()); + deviceNames.add(d.getBuildFlavor()); } List summaryGets = new ArrayList<>(); @@ -146,7 +146,7 @@ public class VtsProfilingStatsJobServlet extends HttpServlet { for (String device : deviceNames) { summaryGets.add( ProfilingPointSummaryEntity.createKey( - profilingPoint.key, branch, device, option, time)); + profilingPoint.getKey(), branch, device, option, time)); } } @@ -160,12 +160,12 @@ public class VtsProfilingStatsJobServlet extends HttpServlet { logger.log(Level.WARNING, "Invalid profiling point summary: " + e.getKey()); continue; } - if (!summaryMap.containsKey(profilingPointSummary.branch)) { - summaryMap.put(profilingPointSummary.branch, new HashMap<>()); + if (!summaryMap.containsKey(profilingPointSummary.getBranch())) { + summaryMap.put(profilingPointSummary.getBranch(), new HashMap<>()); } Map deviceMap = - summaryMap.get(profilingPointSummary.branch); - deviceMap.put(profilingPointSummary.buildFlavor, profilingPointSummary); + summaryMap.get(profilingPointSummary.getBranch()); + deviceMap.put(profilingPointSummary.getBuildFlavor(), profilingPointSummary); } Set modifiedEntities = new HashSet<>(); @@ -183,7 +183,7 @@ public class VtsProfilingStatsJobServlet extends HttpServlet { } else { summary = new ProfilingPointSummaryEntity( - profilingPoint.key, branch, device, option, time); + profilingPoint.getKey(), branch, device, option, time); deviceMap.put(device, summary); } summary.update(profilingPointRun); @@ -205,7 +205,8 @@ public class VtsProfilingStatsJobServlet extends HttpServlet { tx.rollback(); logger.log( Level.WARNING, - "Profiling stats job transaction still active: " + profilingPointRun.key); + "Profiling stats job transaction still active: " + + profilingPointRun.getKey()); return false; } } -- cgit v1.2.3