diff options
author | Young Gyu Park <younggyu@google.com> | 2018-04-16 16:15:28 +0900 |
---|---|---|
committer | Keun Soo Yim <yim@google.com> | 2018-04-16 20:52:21 +0000 |
commit | 3f37409611e999b88499b8c030dcda966750518e (patch) | |
tree | e953af6138032cfef025de234cbeb41a797be0d0 /src/main | |
parent | a0698d6c8f7e91e5067a82a1c16884fcc534e681 (diff) | |
download | dashboard-3f37409611e999b88499b8c030dcda966750518e.tar.gz |
Setting PST timezone for suite test job scheduler
Test: tested on local dev console.
Bug: 77990904
Change-Id: I7d28aaa0dde64438a7fca37fd5c9a493055d4283
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java | 112 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/jsp/show_suite_release.jsp | 3 |
2 files changed, 63 insertions, 52 deletions
diff --git a/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java b/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java index 60f5645..79f04a1 100644 --- a/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java +++ b/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java @@ -64,6 +64,7 @@ import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.Paths; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -136,61 +137,70 @@ public class VtsSuiteTestJobServlet extends HttpServlet { logger.log(Level.INFO, "Job Started!!!!!!!!!!!!!"); - Queue queue = QueueFactory.getQueue(QUEUE); - - List<TaskOptions> tasks = new ArrayList<>(); - - String fileSeparator = FileSystems.getDefault().getSeparator(); - Date today = new Date(); - String year = new SimpleDateFormat("yyyy").format(today); - String month = new SimpleDateFormat("MM").format(today); - String day = new SimpleDateFormat("dd").format(today); - - List<String> pathList = Arrays.asList(GCS_SUITE_TEST_FOLDER_NAME, year, month, day); - Path pathInfo = Paths.get(String.join(fileSeparator, pathList)); - - List<TestSuiteFileEntity> testSuiteFileEntityList = - ofy().load() - .type(TestSuiteFileEntity.class) - .filter("year", Integer.parseInt(year)) - .filter("month", Integer.parseInt(month)) - .filter("day", Integer.parseInt(day)) - .list(); - - List<String> filePathList = - testSuiteFileEntityList - .stream() - .map(testSuiteFile -> testSuiteFile.getFilePath()) - .collect(Collectors.toList()); - - Bucket vtsReportBucket = this.storage.get(GCS_BUCKET_NAME); - - Storage.BlobListOption[] listOptions = - new Storage.BlobListOption[] { - Storage.BlobListOption.prefix(pathInfo.toString() + fileSeparator) - }; - - Iterable<Blob> blobIterable = vtsReportBucket.list(listOptions).iterateAll(); - Iterator<Blob> blobIterator = blobIterable.iterator(); - while (blobIterator.hasNext()) { - Blob blob = blobIterator.next(); - if (blob.isDirectory()) { - logger.log(Level.INFO, blob.getName() + " directory will be skipped!"); - } else { - if (filePathList.contains(blob.getName())) { - logger.log(Level.INFO, "filePathList contain => " + blob.getName()); - } else if (blob.getName().endsWith(fileSeparator)) { - logger.log(Level.INFO, blob.getName() + " endswith slash!"); + long currentMicroSecond = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()); + String todayDateString = TimeUtil.getDateString(currentMicroSecond); + String[] dateArray = todayDateString.split("-"); + if (dateArray.length == 3) { + + Queue queue = QueueFactory.getQueue(QUEUE); + + List<TaskOptions> tasks = new ArrayList<>(); + + String fileSeparator = FileSystems.getDefault().getSeparator(); + + String year = dateArray[0]; + String month = dateArray[1]; + String day = dateArray[2]; + + List<String> pathList = Arrays.asList(GCS_SUITE_TEST_FOLDER_NAME, year, month, day); + Path pathInfo = Paths.get(String.join(fileSeparator, pathList)); + + List<TestSuiteFileEntity> testSuiteFileEntityList = + ofy().load() + .type(TestSuiteFileEntity.class) + .filter("year", Integer.parseInt(year)) + .filter("month", Integer.parseInt(month)) + .filter("day", Integer.parseInt(day)) + .list(); + + List<String> filePathList = + testSuiteFileEntityList + .stream() + .map(testSuiteFile -> testSuiteFile.getFilePath()) + .collect(Collectors.toList()); + + Bucket vtsReportBucket = this.storage.get(GCS_BUCKET_NAME); + + Storage.BlobListOption[] listOptions = + new Storage.BlobListOption[] { + Storage.BlobListOption.prefix(pathInfo.toString() + fileSeparator) + }; + + Iterable<Blob> blobIterable = vtsReportBucket.list(listOptions).iterateAll(); + Iterator<Blob> blobIterator = blobIterable.iterator(); + while (blobIterator.hasNext()) { + Blob blob = blobIterator.next(); + if (blob.isDirectory()) { + logger.log(Level.INFO, blob.getName() + " directory will be skipped!"); } else { - TaskOptions task = - TaskOptions.Builder.withUrl(SUITE_TEST_URL) - .param("filePath", blob.getName()) - .method(TaskOptions.Method.POST); - tasks.add(task); + if (filePathList.contains(blob.getName())) { + logger.log(Level.INFO, "filePathList contain => " + blob.getName()); + } else if (blob.getName().endsWith(fileSeparator)) { + logger.log(Level.INFO, blob.getName() + " endswith slash!"); + } else { + TaskOptions task = + TaskOptions.Builder.withUrl(SUITE_TEST_URL) + .param("filePath", blob.getName()) + .method(TaskOptions.Method.POST); + tasks.add(task); + } } } + TaskQueueHelper.addToQueue(queue, tasks); + } else { + throw new IllegalArgumentException( + todayDateString + " date string not in correct format"); } - TaskQueueHelper.addToQueue(queue, tasks); } @Override diff --git a/src/main/webapp/WEB-INF/jsp/show_suite_release.jsp b/src/main/webapp/WEB-INF/jsp/show_suite_release.jsp index 4600517..3b02d96 100644 --- a/src/main/webapp/WEB-INF/jsp/show_suite_release.jsp +++ b/src/main/webapp/WEB-INF/jsp/show_suite_release.jsp @@ -19,6 +19,7 @@ <%@ taglib prefix='fmt' uri='http://java.sun.com/jsp/jstl/fmt'%> <jsp:useBean id="startDateObject" class="java.util.Date"/> <jsp:useBean id="endDateObject" class="java.util.Date"/> +<c:set var="timeZone" value="America/Los_Angeles"/> <html> <%@ include file='header.jsp' %> @@ -52,7 +53,7 @@ <b>Modules: </b><c:out value="${testSuiteResultEntity.modulesDone}"></c:out>/<c:out value="${testSuiteResultEntity.modulesTotal}"></c:out><br> <jsp:setProperty name="startDateObject" property="time" value="${testSuiteResultEntity.startTime}"/> <jsp:setProperty name="endDateObject" property="time" value="${testSuiteResultEntity.endTime}"/> - <fmt:formatDate value="${startDateObject}" pattern="yyyy-MM-dd HH:mm:ss" /> - <fmt:formatDate value="${endDateObject}" pattern="yyyy-MM-dd HH:mm:ss z" /> + <fmt:formatDate value="${startDateObject}" pattern="yyyy-MM-dd HH:mm:ss" timeZone="${timeZone}" /> - <fmt:formatDate value="${endDateObject}" pattern="yyyy-MM-dd HH:mm:ss z" timeZone="${timeZone}" /> <c:set var="executionTime" scope="page" value="${(testSuiteResultEntity.endTime - testSuiteResultEntity.startTime) / 1000}"/> (<c:out value="${executionTime}"></c:out>s) </span> |