summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYoung Gyu Park <younggyu@google.com>2018-05-08 11:45:53 +0900
committerYoung Gyu Park <younggyu@google.com>2018-05-16 13:57:01 +0900
commit3b8326d5bd720dc18a9ac3e50847f858df062b61 (patch)
tree8ec8641800e4898ea51d97d68745dfa034524375 /src
parent318e1e50229cbea128d19f956e6d2691cde27c72 (diff)
downloaddashboard-3b8326d5bd720dc18a9ac3e50847f858df062b61.tar.gz
Fix parameter bug for multiple type categories
Test: go/vts-web-staging/show_plan_release?plan=vts&type=suite&page=1 Bug: 78661101 Change-Id: Ie87ac09608b460e1a7db1a72d8daaae4c1f0305e
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/android/vts/entity/TestSuiteResultEntity.java72
-rw-r--r--src/main/java/com/android/vts/servlet/ShowPlanReleaseServlet.java30
-rw-r--r--src/main/java/com/android/vts/util/Pagination.java7
-rw-r--r--src/main/webapp/WEB-INF/datastore-indexes.xml18
-rw-r--r--src/main/webapp/WEB-INF/jsp/show_suite_release.jsp6
5 files changed, 122 insertions, 11 deletions
diff --git a/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java b/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
index 1063141..934f2ea 100644
--- a/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
+++ b/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
@@ -16,10 +16,12 @@
package com.android.vts.entity;
+import com.google.appengine.api.datastore.Query;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
+import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.Parent;
import lombok.EqualsAndHashCode;
@@ -53,10 +55,68 @@ import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import java.util.stream.Stream;
import static com.googlecode.objectify.ObjectifyService.ofy;
+/** Embeded TestType Class for determining testType and search function */
+@Index
+@NoArgsConstructor
+class TestTypeIndex {
+
+ /** Embeded TOT field, search field name "testTypeIndex.TOT" */
+ private Boolean TOT;
+
+ /** Embeded OTA field, search field name "testTypeIndex.OTA" */
+ private Boolean OTA;
+
+ /** Embeded SIGNED field, search field name "testTypeIndex.SIGNED" */
+ private Boolean SIGNED;
+
+ /** Maximum bit size */
+ @Ignore private int bitSize = 6;
+
+ @Ignore
+ private List<Integer> totTypeList = this.getTypeList(TestSuiteResultEntity.TestType.TOT.value);
+
+ @Ignore
+ private List<Integer> otaTypeList = this.getTypeList(TestSuiteResultEntity.TestType.OTA.value);
+
+ @Ignore
+ private List<Integer> signedTypeList =
+ this.getTypeList(TestSuiteResultEntity.TestType.SIGNED.value);
+
+ /** Retrieving the list of integers for each category type */
+ private List<Integer> getTypeList(int typeNum) {
+ return IntStream.range(0, (1 << (bitSize - 1)))
+ .filter(i -> (i & typeNum) > 0)
+ .boxed()
+ .collect(Collectors.toList());
+ }
+
+ public TestTypeIndex(int testType) {
+ if (totTypeList.contains(testType)) {
+ this.TOT = true;
+ } else {
+ this.TOT = false;
+ }
+
+ if (otaTypeList.contains(testType)) {
+ this.OTA = true;
+ } else {
+ this.OTA = false;
+ }
+
+ if (signedTypeList.contains(testType)) {
+ this.SIGNED = true;
+ } else {
+ this.SIGNED = false;
+ }
+ }
+}
+
/** Entity Class for saving Test Log Summary */
@Cache
@Entity
@@ -125,7 +185,10 @@ public class TestSuiteResultEntity {
@Getter @Setter Long endTime;
/** Test Suite test type field */
- @Index @Getter @Setter int testType;
+ @Getter @Setter int testType;
+
+ /** Embeded test type field */
+ @Index @Getter @Setter TestTypeIndex testTypeIndex;
/** Test Suite bootup error field */
@Getter @Setter Boolean bootSuccess;
@@ -243,6 +306,7 @@ public class TestSuiteResultEntity {
}
this.testType = this.getSuiteResultTestType(testType);
+ this.testTypeIndex = new TestTypeIndex(this.testType);
}
/** Saving function for the instance of this class */
@@ -319,7 +383,7 @@ public class TestSuiteResultEntity {
.getResourceAsStream(
"bug_tracking_system/" + bugTrackingSystem + "/" + templateName);
- String templateDescription = IOUtils.toString(inputStream, "UTF-8");
+ String templateDescription = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
Map<String, String> valuesMap = new HashMap<>();
valuesMap.put("suiteBuildNumber", suiteBuildNumber);
@@ -351,7 +415,7 @@ public class TestSuiteResultEntity {
.getResourceAsStream(
"bug_tracking_system/" + bugTrackingSystem + "/" + templateName);
- String templateDescription = IOUtils.toString(inputStream, "UTF-8");
+ String templateDescription = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
Map<String, String> valuesMap = new HashMap<>();
valuesMap.put("suiteBuildNumber", suiteBuildNumber);
@@ -407,7 +471,7 @@ public class TestSuiteResultEntity {
this.bugTrackingSystemProp.getProperty(bugTrackingSystem + ".uri.host"),
-1,
this.bugTrackingSystemProp.getProperty(bugTrackingSystem + ".uri.path"),
- URLEncodedUtils.format(qparams, "UTF-8"),
+ URLEncodedUtils.format(qparams, StandardCharsets.UTF_8.name()),
null);
return uri.toString();
}
diff --git a/src/main/java/com/android/vts/servlet/ShowPlanReleaseServlet.java b/src/main/java/com/android/vts/servlet/ShowPlanReleaseServlet.java
index cd1dd41..11383bf 100644
--- a/src/main/java/com/android/vts/servlet/ShowPlanReleaseServlet.java
+++ b/src/main/java/com/android/vts/servlet/ShowPlanReleaseServlet.java
@@ -17,6 +17,7 @@
package com.android.vts.servlet;
import com.android.vts.entity.DeviceInfoEntity;
+import com.android.vts.entity.ProfilingPointSummaryEntity;
import com.android.vts.entity.TestPlanEntity;
import com.android.vts.entity.TestPlanRunEntity;
import com.android.vts.entity.TestSuiteResultEntity;
@@ -39,6 +40,7 @@ import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import static com.googlecode.objectify.ObjectifyService.ofy;
@@ -64,7 +66,11 @@ public class ShowPlanReleaseServlet extends BaseServlet {
links.add(new Page(PageType.PLAN_RELEASE, planName, "?plan=" + planName));
} else {
links.add(new Page(PageType.RELEASE, "TEST SUITES", "?type=" + testType, true));
- links.add(new Page(PageType.PLAN_RELEASE, planName, "?plan=" + planName + "&type=" + testType));
+ links.add(
+ new Page(
+ PageType.PLAN_RELEASE,
+ planName,
+ "?plan=" + planName + "&type=" + testType));
}
return links;
}
@@ -302,7 +308,7 @@ public class ShowPlanReleaseServlet extends BaseServlet {
ofy().load()
.type(TestSuiteResultEntity.class)
.filter("suitePlan", testPlan)
- .filter("testType", Integer.parseInt(testCategoryType))
+ .filter(this.getTestTypeFieldName(testCategoryType), true)
.orderKey(true);
Pagination<TestSuiteResultEntity> testSuiteResultEntityPagination =
@@ -342,4 +348,24 @@ public class ShowPlanReleaseServlet extends BaseServlet {
RequestDispatcher dispatcher = request.getRequestDispatcher(PLAN_RELEASE_JSP);
return dispatcher;
}
+
+
+ private String getTestTypeFieldName(String testCategoryType) {
+ String fieldName;
+ switch (testCategoryType) {
+ case "1": // TOT
+ fieldName = "testTypeIndex.TOT";
+ break;
+ case "2": // OTA
+ fieldName = "testTypeIndex.OTA";
+ break;
+ case "4": // SIGNED
+ fieldName = "testTypeIndex.SIGNED";
+ break;
+ default:
+ fieldName = "testTypeIndex.TOT";
+ break;
+ }
+ return fieldName;
+ }
}
diff --git a/src/main/java/com/android/vts/util/Pagination.java b/src/main/java/com/android/vts/util/Pagination.java
index ddf4d38..fc4d3f7 100644
--- a/src/main/java/com/android/vts/util/Pagination.java
+++ b/src/main/java/com/android/vts/util/Pagination.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
/** Helper class for pagination. */
@@ -81,7 +82,7 @@ public class Pagination<T> implements Iterable<T> {
List<String> pageCountTokenList =
this.pageCountTokenSet.stream().collect(Collectors.toList());
- if (pageCountTokenList.size() > 1) {
+ if (pageCountTokenList.size() > 0) {
int foundIndex = pageCountTokenList.indexOf(startPageToken);
if (foundIndex <= 0) {
this.previousPageCountToken = "";
@@ -111,7 +112,9 @@ public class Pagination<T> implements Iterable<T> {
this.list.add(resultIterator.next());
else resultIterator.next();
if (iteratorIndex == DEFAULT_PAGE_WINDOW * this.pageSize) {
- this.nextPageCountToken = resultIterator.getCursor().toWebSafeString();
+ if ( Objects.nonNull(resultIterator) && Objects.nonNull(resultIterator.getCursor()) ) {
+ this.nextPageCountToken = resultIterator.getCursor().toWebSafeString();
+ }
}
iteratorIndex++;
}
diff --git a/src/main/webapp/WEB-INF/datastore-indexes.xml b/src/main/webapp/WEB-INF/datastore-indexes.xml
index 0f9caf1..4b1c6cc 100644
--- a/src/main/webapp/WEB-INF/datastore-indexes.xml
+++ b/src/main/webapp/WEB-INF/datastore-indexes.xml
@@ -115,6 +115,24 @@
<datastore-index kind="TestSuiteResultEntity" ancestor="false" source="manual">
<property name="suitePlan" direction="asc"/>
+ <property name="testTypeIndex.TOT" direction="asc"/>
+ <property name="__key__" direction="desc"/>
+ </datastore-index>
+
+ <datastore-index kind="TestSuiteResultEntity" ancestor="false" source="manual">
+ <property name="suitePlan" direction="asc"/>
+ <property name="testTypeIndex.OTA" direction="asc"/>
+ <property name="__key__" direction="desc"/>
+ </datastore-index>
+
+ <datastore-index kind="TestSuiteResultEntity" ancestor="false" source="manual">
+ <property name="suitePlan" direction="asc"/>
+ <property name="testTypeIndex.SIGNED" direction="asc"/>
+ <property name="__key__" direction="desc"/>
+ </datastore-index>
+
+ <datastore-index kind="TestSuiteResultEntity" ancestor="false" source="manual">
+ <property name="suitePlan" direction="asc"/>
<property name="branch" direction="asc"/>
<property name="target" direction="asc"/>
</datastore-index>
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 4b8b9e8..da9d8da 100644
--- a/src/main/webapp/WEB-INF/jsp/show_suite_release.jsp
+++ b/src/main/webapp/WEB-INF/jsp/show_suite_release.jsp
@@ -231,7 +231,7 @@
<c:choose>
<c:when test="${testSuiteResultEntityPagination.minPageRange gt testSuiteResultEntityPagination.pageSize}">
<li class="waves-effect">
- <a href="${requestScope['javax.servlet.forward.servlet_path']}?plan=${plan}&type=${testType}&groupType=${groupType}&page=${testSuiteResultEntityPagination.minPageRange - 1}&nextPageToken=${testSuiteResultEntityPagination.previousPageCountToken}">
+ <a href="${requestScope['javax.servlet.forward.servlet_path']}?plan=${plan}&type=${testType}&testCategoryType=${testCategoryType}&page=${testSuiteResultEntityPagination.minPageRange - 1}&nextPageToken=${testSuiteResultEntityPagination.previousPageCountToken}">
<i class="material-icons">chevron_left</i>
</a>
</li>
@@ -242,7 +242,7 @@
</c:choose>
<c:forEach var="pageLoop" begin="${testSuiteResultEntityPagination.minPageRange}" end="${testSuiteResultEntityPagination.maxPageRange}">
<li class="waves-effect<c:if test="${pageLoop eq page}"> active</c:if>">
- <a href="${requestScope['javax.servlet.forward.servlet_path']}?plan=${plan}&type=${testType}&groupType=${groupType}&page=${pageLoop}<c:if test="${testSuiteResultEntityPagination.currentPageCountToken ne ''}">&nextPageToken=${testSuiteResultEntityPagination.currentPageCountToken}</c:if>">
+ <a href="${requestScope['javax.servlet.forward.servlet_path']}?plan=${plan}&type=${testType}&testCategoryType=${testCategoryType}&page=${pageLoop}<c:if test="${testSuiteResultEntityPagination.currentPageCountToken ne ''}">&nextPageToken=${testSuiteResultEntityPagination.currentPageCountToken}</c:if>">
<c:out value="${pageLoop}" />
</a>
</li>
@@ -250,7 +250,7 @@
<c:choose>
<c:when test="${testSuiteResultEntityPagination.maxPages gt testSuiteResultEntityPagination.pageSize}">
<li class="waves-effect">
- <a href="${requestScope['javax.servlet.forward.servlet_path']}?plan=${plan}&type=${testType}&groupType=${groupType}&page=${testSuiteResultEntityPagination.maxPageRange + 1}&nextPageToken=${testSuiteResultEntityPagination.nextPageCountToken}">
+ <a href="${requestScope['javax.servlet.forward.servlet_path']}?plan=${plan}&type=${testType}&testCategoryType=${testCategoryType}&page=${testSuiteResultEntityPagination.maxPageRange + 1}&nextPageToken=${testSuiteResultEntityPagination.nextPageCountToken}">
<i class="material-icons">chevron_right</i>
</a>
</li>