ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] SomeFire commented on a change in pull request #25: IGNITE-9645 [TC Bot] Add comparison of failed tests lists in two date intervals
Date Wed, 03 Oct 2018 13:40:51 GMT
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_r222279867
 
 

 ##########
 File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/build/GetBuildTestFailures.java
 ##########
 @@ -159,75 +156,59 @@ public TestFailuresSummary getBuildTestFails(
     }
 
     @GET
-    @Path("history")
-    public List<BuildStatisticsSummary> getBuildsHistory(
-        @Nullable @QueryParam("server") String srv,
-        @Nullable @QueryParam("buildType") String buildType,
-        @Nullable @QueryParam("branch") String branch,
-        @Nullable @QueryParam("sinceDate") String sinceDate,
-        @Nullable @QueryParam("untilDate") String untilDate)
-        throws ServiceUnauthorizedException {
-        String srvId = isNullOrEmpty(srv) ? "apache" : srv;
-        String buildTypeId = isNullOrEmpty(buildType) ? "IgniteTests24Java8_RunAll" : buildType;
-        String branchName = isNullOrEmpty(branch) ? "refs/heads/master" : branch;
-        Date sinceDateFilter = isNullOrEmpty(sinceDate) ? null : dateParse(sinceDate);
-        Date untilDateFilter = isNullOrEmpty(untilDate) ? null : dateParse(untilDate);
-
-        final BackgroundUpdater updater = CtxListener.getBackgroundUpdater(ctx);
-
-        final ITcHelper tcHelper = CtxListener.getTcHelper(ctx);
+    @Produces(MediaType.TEXT_PLAIN)
+    @Path("testRef")
+    public String getTestRef(
+        @NotNull @QueryParam("testName") String name,
+        @Nullable @QueryParam("server") String server,
+        @Nullable @QueryParam("projectId") String projectId)
+        throws InterruptedException, ExecutionException {
+        final ITcHelper helper = CtxListener.getTcHelper(ctx);
 
         final ICredentialsProv prov = ICredentialsProv.get(req);
 
-        IAnalyticsEnabledTeamcity teamcity = tcHelper.server(srvId, prov);
-
-        int[] finishedBuilds = teamcity.getBuildNumbersFromHistory(buildTypeId, branchName,
sinceDateFilter, untilDateFilter);
+        String project = projectId == null ? "IgniteTests24Java8" : projectId;
 
-        List<BuildStatisticsSummary> buildsStatistics = new ArrayList<>();
+        String serverId = server == null ? "apache" : server;
 
-        for (int i = 0; i < finishedBuilds.length; i++) {
-            int buildId = finishedBuilds[i];
+        IAnalyticsEnabledTeamcity teamcity = helper.server(serverId, prov);
 
-            FullQueryParams param = new FullQueryParams();
-            param.setBuildId(buildId);
-            param.setBranch(branchName);
-            param.setServerId(srvId);
+        FullQueryParams key = new FullQueryParams();
 
-            BuildStatisticsSummary buildsStatistic = updater.get(
-                BUILDS_STATISTICS_SUMMARY_CACHE_NAME, prov, param,
-                (k) -> getBuildStatisticsSummaryNoCache(srvId, buildId), false);
+        key.setTestName(name);
 
-            if (!buildsStatistic.isFakeStub)
-                buildsStatistics.add(buildsStatistic);
-        }
+        key.setProjectId(project);
 
-        return buildsStatistics;
-    }
+        key.setServerId(serverId);
 
-    private Date dateParse(String date){
-        DateFormat dateFormat = new SimpleDateFormat("ddMMyyyyHHmmss");
+        CompletableFuture<TestRef> ref = teamcity.getTestRef(key);
 
-        try {
-            return dateFormat.parse(date);
-        }
-        catch (ParseException e) {
-            return null;
-        }
+        return ref.isDone() ? teamcity.host() + "project.html?"
+            + "projectId=" + project
+            + "&testNameId=" + ref.get().id
+            + "&tab=testDetails" : null;
     }
 
-    private BuildStatisticsSummary getBuildStatisticsSummaryNoCache(String server, int buildId)
{
-        String srvId = isNullOrEmpty(server) ? "apache" : server;
-
-        final ITcHelper tcHelper = CtxListener.getTcHelper(ctx);
-
-        final ICredentialsProv creds = ICredentialsProv.get(req);
-
-        IAnalyticsEnabledTeamcity teamcity = tcHelper.server(srvId, creds);
+    @GET
+    @Path("history")
+    public BuildsHistory getBuildsHistory(
+        @Nullable @QueryParam("server") String server,
+        @Nullable @QueryParam("buildType") String buildType,
+        @Nullable @QueryParam("branch") String branch,
+        @Nullable @QueryParam("sinceDate") String sinceDate,
+        @Nullable @QueryParam("untilDate") String untilDate)  throws ParseException {
+        BuildsHistory buildsHistory = new BuildsHistory.Builder()
+            .branch(branch)
+            .server(server)
+            .buildType(buildType)
+            .sinceDate(sinceDate)
+            .untilDate(untilDate)
+            .build();
 
-        BuildStatisticsSummary stat = new BuildStatisticsSummary(buildId);
+        System.out.println("History request handled");
 
 Review comment:
   Use logger instead of `sout`. Do we really need this in the log?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message