Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10529

TestTrendChart Dashboard does not display number of tests correctly

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The current implementation calculates the trend graph in this way:

      Time ----|--------|--------|--------|---------|---->
          FirstDate  Build1   Build2   Build3     Today
                     2 tests  3 tests  4 tests
      
      Current graph would be like this:
      9                 |---------------------------| 
      5        |--------|
      2--------|
      
      Instead it should be like this:
      9                          |------------------| 
      5                 |--------|
      2        |--------|
      

      Looking at the source code this is much clear.

      Run run = job.getFirstBuild();
      
            if (run != null) { // execute only if job has builds
              LocalDate lastRunDay = new LocalDate(run.getTimestamp());
              if (dateRange > 0 && firstDay.isAfter(lastRunDay)) {
                lastRunDay = new LocalDate().minusDays(dateRange);
              }
      
              while (run != null) {
                Run nextRun = run.getNextBuild();
                LocalDate runDay = new LocalDate(run.getTimestamp());
      
                  if (nextRun != null) {
                    if (runDay.isAfter(firstDay)) { // skip run before firstDay
                      // if next run is the next day, use this test to summarize
                      if (new LocalDate(nextRun.getTimestamp()).isAfter(runDay)) {
      // mambu: we compute the tests of runDay from lastRunDay to runDay
      // so in the past instead of computing from runDay to nextRunDay!
                        summarize(summaries, run, lastRunDay, runDay);
                        lastRunDay = runDay.plusDays(1);
                      }
                    }
                  } else {
                    // use this run's test result from last run to today
                    summarize(summaries, run, lastRunDay, today);
                  }
      
                run = nextRun;
              }
            }
      

        Attachments

          Activity

          Hide
          mambu Marco Ambu added a comment -

          This is the code change I propose:
          TestTrendChart.java @ line 83:

          			Run run = job.getFirstBuild();
          
                if (run != null) { // execute only if job has builds
                  LocalDate runDay = new LocalDate(run.getTimestamp());
                  LocalDate firstDay = (dateRange != 0) ? new LocalDate().minusDays(dateRange) : runDay;
          
                  while (run != null) {
                    runDay = new LocalDate(run.getTimestamp());
                    Run nextRun = run.getNextBuild();
          
                    if (nextRun != null) {
                      if (!runDay.isBefore(firstDay)) { // skip run before firstDay
                        // if next run is not the same day, use this test to summarize
                        LocalDate nextRunDay = new LocalDate(nextRun.getTimestamp());
                        if (nextRunDay.isAfter(runDay)) {
                          summarize(summaries, run, runDay, nextRunDay.minusDays(1));
                        }
                      }
                    } else {
                      // use this run's test result from last run to today
                      summarize(summaries, run, runDay, today);
                    }
          
                    run = nextRun;
                  }
                }
              }
          

          In this way the tests of run R1 of day X contribute to day X, X+1, ..., Y-1
          and tests of run R2 of day Y contribute to day Y, Y+1, ...

          If somebody could check this code it would be great, as more eyes are better than two.

          I tested on my installation and it works fine.

          Show
          mambu Marco Ambu added a comment - This is the code change I propose: TestTrendChart.java @ line 83: Run run = job.getFirstBuild(); if (run != null ) { // execute only if job has builds LocalDate runDay = new LocalDate(run.getTimestamp()); LocalDate firstDay = (dateRange != 0) ? new LocalDate().minusDays(dateRange) : runDay; while (run != null ) { runDay = new LocalDate(run.getTimestamp()); Run nextRun = run.getNextBuild(); if (nextRun != null ) { if (!runDay.isBefore(firstDay)) { // skip run before firstDay // if next run is not the same day, use this test to summarize LocalDate nextRunDay = new LocalDate(nextRun.getTimestamp()); if (nextRunDay.isAfter(runDay)) { summarize(summaries, run, runDay, nextRunDay.minusDays(1)); } } } else { // use this run's test result from last run to today summarize(summaries, run, runDay, today); } run = nextRun; } } } In this way the tests of run R1 of day X contribute to day X, X+1, ..., Y-1 and tests of run R2 of day Y contribute to day Y, Y+1, ... If somebody could check this code it would be great, as more eyes are better than two. I tested on my installation and it works fine.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Marco Ambu
          Path:
          src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java
          http://jenkins-ci.org/commit/dashboard-view-plugin/7de5883470f8a7eeccc9fc9ea158ac866ef7a5cf
          Log:
          TestTrendChart was reporting tests contribution in the past; modified to contribute to the future [FIXED JENKINS-10529]

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marco Ambu Path: src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java http://jenkins-ci.org/commit/dashboard-view-plugin/7de5883470f8a7eeccc9fc9ea158ac866ef7a5cf Log: TestTrendChart was reporting tests contribution in the past; modified to contribute to the future [FIXED JENKINS-10529]
          Hide
          dogfood dogfood added a comment -

          Integrated in plugins_dashboard-view #29
          TestTrendChart was reporting tests contribution in the past; modified to contribute to the future [FIXED JENKINS-10529]

          Marco Ambu :
          Files :

          • src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java
          Show
          dogfood dogfood added a comment - Integrated in plugins_dashboard-view #29 TestTrendChart was reporting tests contribution in the past; modified to contribute to the future [FIXED JENKINS-10529] Marco Ambu : Files : src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java
          Hide
          mambu Marco Ambu added a comment -

          Closed by mistake.

          Show
          mambu Marco Ambu added a comment - Closed by mistake.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Marco Ambu
          Path:
          src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java
          http://jenkins-ci.org/commit/dashboard-view-plugin/04adf38c6c8fc9ab70e529692cfe15bf8c79b718
          Log:
          JENKINS-10529 Fixed visualization when a date range is provided (broken by previous commit).

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marco Ambu Path: src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java http://jenkins-ci.org/commit/dashboard-view-plugin/04adf38c6c8fc9ab70e529692cfe15bf8c79b718 Log: JENKINS-10529 Fixed visualization when a date range is provided (broken by previous commit).
          Hide
          dogfood dogfood added a comment -

          Integrated in plugins_dashboard-view #30
          JENKINS-10529 Fixed visualization when a date range is provided (broken by previous commit).

          Marco Ambu :
          Files :

          • src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java
          Show
          dogfood dogfood added a comment - Integrated in plugins_dashboard-view #30 JENKINS-10529 Fixed visualization when a date range is provided (broken by previous commit). Marco Ambu : Files : src/main/java/hudson/plugins/view/dashboard/test/TestTrendChart.java

            People

            • Assignee:
              mambu Marco Ambu
              Reporter:
              mambu Marco Ambu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: