summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorYoung Gyu Park <younggyu@google.com>2018-09-11 14:45:47 +0900
committerYoungGyu Park <younggyu@google.com>2018-09-15 02:32:15 +0000
commit6a5c29003acbe60f560b8b19936e2a0af5654d84 (patch)
tree5acba1f402b2b97a232e211e7d704b4a67c6f911 /src/main
parent897892f30f38904e001eaa74760af215d346e6d4 (diff)
downloaddashboard-6a5c29003acbe60f560b8b19936e2a0af5654d84.tar.gz
Adding base servlet class for job servlet class
Test: go/vts-web-staging Bug: 113356010 Change-Id: Ib257f657113b6a9fdb8263f86302a2193175a9a3
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/android/vts/job/BaseJobServlet.java56
-rw-r--r--src/main/java/com/android/vts/job/VtsAlertJobServlet.java3
-rw-r--r--src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java21
-rw-r--r--src/main/java/com/android/vts/job/VtsInactivityJobServlet.java2
-rw-r--r--src/main/java/com/android/vts/job/VtsPerformanceJobServlet.java2
-rw-r--r--src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java2
-rw-r--r--src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java2
7 files changed, 74 insertions, 14 deletions
diff --git a/src/main/java/com/android/vts/job/BaseJobServlet.java b/src/main/java/com/android/vts/job/BaseJobServlet.java
new file mode 100644
index 0000000..3d6232b
--- /dev/null
+++ b/src/main/java/com/android/vts/job/BaseJobServlet.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you
+ * may not use this file except in compliance with the License. You may
+ * obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.vts.job;
+
+import com.android.vts.servlet.BaseServlet;
+import com.android.vts.util.EmailHelper;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * An abstract class to be subclassed to create Job Servlet
+ */
+public abstract class BaseJobServlet extends HttpServlet {
+
+ /**
+ * System Configuration Property class
+ */
+ protected static Properties systemConfigProp = new Properties();
+
+ @Override
+ public void init(ServletConfig cfg) throws ServletException {
+ super.init(cfg);
+
+ try {
+ InputStream defaultInputStream =
+ BaseServlet.class.getClassLoader().getResourceAsStream("config.properties");
+ systemConfigProp.load(defaultInputStream);
+
+ EmailHelper.setPropertyValues(systemConfigProp);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/android/vts/job/VtsAlertJobServlet.java b/src/main/java/com/android/vts/job/VtsAlertJobServlet.java
index 7e66ac8..3336c85 100644
--- a/src/main/java/com/android/vts/job/VtsAlertJobServlet.java
+++ b/src/main/java/com/android/vts/job/VtsAlertJobServlet.java
@@ -59,13 +59,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.Message;
import javax.mail.MessagingException;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
/** Represents the notifications service which is automatically called on a fixed schedule. */
-public class VtsAlertJobServlet extends HttpServlet {
+public class VtsAlertJobServlet extends BaseJobServlet {
private static final String ALERT_JOB_URL = "/task/vts_alert_job";
protected static final Logger logger = Logger.getLogger(VtsAlertJobServlet.class.getName());
protected static final int MAX_RUN_COUNT = 1000; // maximum number of runs to query for
diff --git a/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java b/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java
index bb82749..b0348dd 100644
--- a/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java
+++ b/src/main/java/com/android/vts/job/VtsCoverageAlertJobServlet.java
@@ -18,6 +18,7 @@ package com.android.vts.job;
import static com.googlecode.objectify.ObjectifyService.ofy;
+import com.android.vts.entity.CodeCoverageEntity;
import com.android.vts.entity.DeviceInfoEntity;
import com.android.vts.entity.TestCoverageStatusEntity;
import com.android.vts.entity.TestRunEntity;
@@ -57,7 +58,7 @@ import org.apache.commons.lang.StringUtils;
/**
* Coverage notification job.
*/
-public class VtsCoverageAlertJobServlet extends HttpServlet {
+public class VtsCoverageAlertJobServlet extends BaseJobServlet {
private static final String COVERAGE_ALERT_URL = "/task/vts_coverage_job";
protected static final Logger logger =
@@ -115,14 +116,18 @@ public class VtsCoverageAlertJobServlet extends HttpServlet {
}
TestRunEntity testRunEntity = TestRunEntity.fromEntity(testRun);
- if (testRunEntity == null || !testRunEntity.isHasCoverage()) {
+ if (testRunEntity == null || !testRunEntity.hasCodeCoverage()) {
return null;
}
- if (testRunEntity.getTotalLineCount() <= 0 || testRunEntity.getCoveredLineCount() < 0) {
- coveragePct = 0;
+ CodeCoverageEntity codeCoverageEntity = testRunEntity.getCodeCoverageEntity();
+
+ if (codeCoverageEntity.getTotalLineCount() <= 0
+ || codeCoverageEntity.getCoveredLineCount() < 0) {
+ coveragePct = 0;
} else {
- coveragePct =
- ((double) testRunEntity.getCoveredLineCount()) / testRunEntity.getTotalLineCount();
+ coveragePct =
+ ((double) codeCoverageEntity.getCoveredLineCount())
+ / codeCoverageEntity.getTotalLineCount();
}
Set<String> buildIdList = new HashSet<>();
@@ -265,8 +270,8 @@ public class VtsCoverageAlertJobServlet extends HttpServlet {
return new TestCoverageStatusEntity(
testName,
testRunEntity.getStartTimestamp(),
- testRunEntity.getCoveredLineCount(),
- testRunEntity.getTotalLineCount());
+ codeCoverageEntity.getCoveredLineCount(),
+ codeCoverageEntity.getTotalLineCount());
}
/**
diff --git a/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java b/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java
index c4a9825..031cdbb 100644
--- a/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java
+++ b/src/main/java/com/android/vts/job/VtsInactivityJobServlet.java
@@ -50,7 +50,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** Test inactivity notification job. */
-public class VtsInactivityJobServlet extends HttpServlet {
+public class VtsInactivityJobServlet extends BaseJobServlet {
private static final String INACTIVITY_ALERT_URL = "/cron/vts_inactivity_job";
protected static final Logger logger =
Logger.getLogger(VtsInactivityJobServlet.class.getName());
diff --git a/src/main/java/com/android/vts/job/VtsPerformanceJobServlet.java b/src/main/java/com/android/vts/job/VtsPerformanceJobServlet.java
index 964c688..ebd5294 100644
--- a/src/main/java/com/android/vts/job/VtsPerformanceJobServlet.java
+++ b/src/main/java/com/android/vts/job/VtsPerformanceJobServlet.java
@@ -45,7 +45,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** Represents the notifications service which is automatically called on a fixed schedule. */
-public class VtsPerformanceJobServlet extends HttpServlet {
+public class VtsPerformanceJobServlet extends BaseJobServlet {
protected static final Logger logger =
Logger.getLogger(VtsPerformanceJobServlet.class.getName());
diff --git a/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java b/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java
index 96d635d..50f72e1 100644
--- a/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java
+++ b/src/main/java/com/android/vts/job/VtsProfilingStatsJobServlet.java
@@ -56,7 +56,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** Represents the notifications service which is automatically called on a fixed schedule. */
-public class VtsProfilingStatsJobServlet extends HttpServlet {
+public class VtsProfilingStatsJobServlet extends BaseJobServlet {
protected static final Logger logger =
Logger.getLogger(VtsProfilingStatsJobServlet.class.getName());
private static final String HIDL_HAL_OPTION = "hidl_hal_mode";
diff --git a/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java b/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java
index c0189b3..26e6cad 100644
--- a/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java
+++ b/src/main/java/com/android/vts/job/VtsSuiteTestJobServlet.java
@@ -60,7 +60,7 @@ import java.util.stream.Collectors;
import static com.googlecode.objectify.ObjectifyService.ofy;
/** Suite Test result file processing job. */
-public class VtsSuiteTestJobServlet extends HttpServlet {
+public class VtsSuiteTestJobServlet extends BaseJobServlet {
private static final String SUITE_TEST_URL = "/cron/test_suite_report_gcs_monitor";