Skip to content

Commit

Permalink
Added count of flaky tests per team
Browse files Browse the repository at this point in the history
  • Loading branch information
stianst committed Oct 1, 2024
1 parent 1c328f7 commit 104ec1a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/keycloak/dashboard/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void createDashboard() throws IOException, TemplateException, ParseExcept
attributes.put("failedJobs", logFailedParser.getUnlinkedFailedJobs());
attributes.put("linkedFailedJobs", logFailedParser.getLinkedFailedJobs());
attributes.put("flakyTests", bugs.getFlakyTests());
attributes.put("flakyTestCountsByTeam", bugs.getFlakyTestCountsByTeam());
attributes.put("nextRelease", bugs.getNextRelease());
attributes.put("workflowWaitTimes", new WorkflowWaitTimes(data, teamMembers).getWorkFlowWaitPerMonthList());
attributes.put("configContents", Config.getConfigContents());
Expand Down
28 changes: 23 additions & 5 deletions src/main/java/org/keycloak/dashboard/beans/Bugs.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
import org.keycloak.dashboard.rep.Teams;
import org.keycloak.dashboard.util.DateUtil;

import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

public class Bugs {
Expand All @@ -26,6 +22,8 @@ public class Bugs {

private List<FlakyTest> flakyTests;

private Map<String, Integer> flakyTestCountsByTeam;

public Bugs(GitHubData data, Teams teams) {
issues = data.getIssues().stream().filter(i -> i.getLabels().contains("kind/bug")).collect(Collectors.toList());

Expand All @@ -36,11 +34,28 @@ public Bugs(GitHubData data, Teams teams) {
.sorted(Comparator.comparing(FlakyTest::getCount).reversed())
.collect(Collectors.toList());

flakyTestCountsByTeam = convertToTeamCount(flakyTests, teams);

stats = convertToBugStat(issues, data, teams);
areaStats = convertToAreaStats(issues);
teamStats = convertToTeamStats(issues, teams);
}

private Map<String, Integer> convertToTeamCount(List<FlakyTest> flakyTests, Teams teams) {
Map<String, Integer> counts = new TreeMap<>();
for (String team : teams.keySet()) {
if (!team.equals("no-team")) {
counts.put(team.substring("team/".length()), 0);
}
}
for (FlakyTest f : flakyTests) {
for (String t : f.getTeams()) {
counts.put(t, counts.get(t) + 1);
}
}
return counts;
}

private List<BugStat> convertToBugStat(List<GitHubIssue> issues, GitHubData data, Teams teams) {
List<BugStat> stats = new LinkedList<>();
FilteredIssues filteredIssues = FilteredIssues.create(issues);
Expand Down Expand Up @@ -163,4 +178,7 @@ public List<FlakyTest> getFlakyTests() {
return flakyTests;
}

public Map<String, Integer> getFlakyTestCountsByTeam() {
return flakyTestCountsByTeam;
}
}
7 changes: 0 additions & 7 deletions src/main/java/org/keycloak/dashboard/beans/FlakyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ public String getUpdatedAtClass() {
}
}

public int weight() {
int c = getCount();
long daysSinceUpdated = TimeUnit.DAYS.convert(System.currentTimeMillis() - getUpdatedAt().getTime(), TimeUnit.MILLISECONDS);
System.out.println(c + "\t" + daysSinceUpdated);
return 0;
}

public List<String> getLabels() {
return issue.getLabels().stream()
.filter(Predicate.isEqual("area/ci").negate())
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/module-tests-flaky-tests.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
Flaky tests
</div>
<div class="body">
<table>
<tr>
<#list flakyTestCountsByTeam?keys as team>
<th>${team}</th>
</#list>
</tr>
<tr>
<#list flakyTestCountsByTeam?values as count>
<td>${count}</td>
</#list>
</tr>
</table>

<table>
<tr>
<th>Package</th>
Expand Down

0 comments on commit 104ec1a

Please sign in to comment.