[
https://issues.apache.org/jira/browse/IGNITE-9645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16641529#comment-16641529
]
ASF GitHub Bot commented on IGNITE-9645:
----------------------------------------
SomeFire commented on a change in pull request #25: IGNITE-9645 [TC Bot] Add
comparison of failed tests lists in two date intervals
URL: https://github.com/apache/ignite-teamcity-bot/pull/25#discussion_r223274311
##########
File path:
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/hist/BuildsHistory.java
##########
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.ignite.ci.web.model.hist;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletContext;
+import org.apache.ignite.ci.IAnalyticsEnabledTeamcity;
+import org.apache.ignite.ci.ITcHelper;
+import org.apache.ignite.ci.tcbot.chain.BuildChainProcessor;
+import org.apache.ignite.ci.tcmodel.result.Build;
+import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrence;
+import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrences;
+import org.apache.ignite.ci.user.ICredentialsProv;
+import org.apache.ignite.ci.web.CtxListener;
+import org.apache.ignite.ci.web.model.current.BuildStatisticsSummary;
+import org.apache.ignite.ci.web.rest.exception.ServiceUnauthorizedException;
+import org.apache.ignite.ci.web.rest.parms.FullQueryParams;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+import static
org.apache.ignite.ci.web.rest.build.GetBuildTestFailures.BUILDS_STATISTICS_SUMMARY_CACHE_NAME;
+
+/**
+ * Builds History: includes statistic for every build and merged failed
unmuted tests in specified time interval.
+ */
+
+public class BuildsHistory {
+ /** */
+ private String srvId;
+
+ /** */
+ private String projectId;
+
+ /** */
+ private String buildTypeId;
+
+ /** */
+ private String branchName;
+
+ /** */
+ private Date sinceDateFilter;
+
+ /** */
+ private Date untilDateFilter;
+
+ /** */
+ private ObjectMapper objectMapper = new ObjectMapper();
+
+ /** */
+ private Map<String, Set<String>> mergedTestsBySuites = new HashMap<>();
+
+ /** */
+ public List<BuildStatisticsSummary> buildsStatistics = new ArrayList<>();
+
+ /** */
+ public String mergedTestsJson;
+
+ /** */
+ public void initialize(ICredentialsProv prov, ServletContext context) {
+ if (!prov.hasAccess(srvId))
+ throw ServiceUnauthorizedException.noCreds(srvId);
+
+ ITcHelper tcHelper = CtxListener.getTcHelper(context);
+
+ IAnalyticsEnabledTeamcity teamcity = tcHelper.server(srvId, prov);
+
+ int[] finishedBuildsIds =
teamcity.getBuildNumbersFromHistory(buildTypeId, branchName,
+ sinceDateFilter, untilDateFilter);
+
+ initBuildsStatistics(teamcity, prov, context, finishedBuildsIds);
+
+ initBuildsMergedFailedTests(teamcity, finishedBuildsIds);
+ }
+
+ /** */
+ private void initBuildsStatistics(IAnalyticsEnabledTeamcity teamcity,
ICredentialsProv prov,
+ ServletContext context, int[] buildIds) {
+ for (int buildId : buildIds) {
+ FullQueryParams buildParams = new FullQueryParams();
+
+ buildParams.setBuildId(buildId);
+ buildParams.setBranch(branchName);
+ buildParams.setServerId(srvId);
+
+ BuildStatisticsSummary buildsStatistic =
CtxListener.getBackgroundUpdater(context).get(
+ BUILDS_STATISTICS_SUMMARY_CACHE_NAME, prov, buildParams,
+ (k) -> {
+ BuildStatisticsSummary stat = new
BuildStatisticsSummary(buildId);
+
+ stat.initialize(teamcity);
+
+ return stat;
+ }, false);
+
+ if (buildsStatistic != null && !buildsStatistic.isFakeStub)
+ buildsStatistics.add(buildsStatistic);
+ }
+ }
+
+ /** */
+ private void initBuildsMergedFailedTests(IAnalyticsEnabledTeamcity
teamcity, int[] buildIds) {
+ for (int buildId : buildIds) {
+ Build build =
teamcity.getBuild(teamcity.getBuildHrefById(buildId));
+
+ TestOccurrences testOccurrences =
teamcity.getFailedUnmutedTests(build.testOccurrences.href,
+ build.testOccurrences.failed,
BuildChainProcessor.normalizeBranch(build.branchName));
+
+ for (TestOccurrence testOccurrence : testOccurrences.getTests()) {
+ String testName = testOccurrence.getName();
+
+ build =
teamcity.getBuild(teamcity.getBuildHrefById(testOccurrence.getBuildId()));
+
+ Set<String> tests =
mergedTestsBySuites.computeIfAbsent(build.buildTypeId,
+ k -> new HashSet<>());
+
+ if (!tests.add(testName))
+ continue;
+
+ FullQueryParams key = new FullQueryParams();
+
+ key.setServerId(srvId);
+
+ key.setProjectId(projectId);
+
+ key.setTestName(testOccurrence.getName());
+
+ key.setSuiteId(build.buildTypeId);
+
+ teamcity.getTestRef(key);
+ }
+ }
+
+ try {
+ mergedTestsJson =
objectMapper.writeValueAsString(mergedTestsBySuites);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** */
+ public BuildsHistory(Builder builder) {
+ this.srvId = builder.srvId;
+
Review comment:
Redundant empty lines in the method, because all lines here are the same
semantic units.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [TC Bot] Add comparison of failed tests lists in two date intervals
> -------------------------------------------------------------------
>
> Key: IGNITE-9645
> URL: https://issues.apache.org/jira/browse/IGNITE-9645
> Project: Ignite
> Issue Type: Task
> Reporter: PetrovMikhail
> Assignee: PetrovMikhail
> Priority: Major
>
> Based on [IGNITE-9541|https://issues.apache.org/jira/browse/IGNITE-9541] It's
> needed to add comparison of failed tests lists in two date intervals
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)