-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve gradleCheckFlakyTestDetector library
Signed-off-by: Prudhvi Godithi <[email protected]>
- Loading branch information
1 parent
910cb54
commit 996725e
Showing
15 changed files
with
430 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package gradlecheck | ||
|
||
class MarkdownComparator { | ||
|
||
ArrayList<String> testReportMarkDownTable | ||
ArrayList<String> gitHubMarkDownTable | ||
|
||
MarkdownComparator(ArrayList<String> testReportMarkDownTable, ArrayList<String> gitHubMarkDownTable) { | ||
this.testReportMarkDownTable = testReportMarkDownTable | ||
this.gitHubMarkDownTable = gitHubMarkDownTable | ||
} | ||
|
||
def markdownComparison() { | ||
def differences = testReportMarkDownTable.findAll { ghRow -> | ||
!gitHubMarkDownTable.any { compRow -> | ||
ghRow['Git Reference'] == compRow['Git Reference'] && | ||
ghRow['Merged Pull Request'] == compRow['Merged Pull Request'] && | ||
ghRow['Build Details'] == compRow['Build Details'] && | ||
ghRow['Test Name'] == compRow['Test Name'] | ||
} | ||
} | ||
return differences | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package gradlecheck | ||
|
||
class ParseMarkDownTable { | ||
String markdown | ||
|
||
ParseMarkDownTable(String markdown) { | ||
this.markdown = markdown | ||
} | ||
|
||
def parseMarkdownTableRows() { | ||
def rows = markdown.split("\\|\\s*\\n") | ||
rows = rows[2..-2] // Skipping headers and footer | ||
return rows.collect { row -> | ||
def cells = row.split("\\|\\s*") | ||
return [ | ||
'Git Reference': cells[1].trim(), | ||
'Merged Pull Request': cells[2].trim(), | ||
'Build Details': cells[3].trim(), | ||
'Test Name': cells[4].trim() | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package gradlecheck; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
class MarkdownComparatorTest { | ||
|
||
@Test | ||
public void testMarkdownComparisonWithDifferences() { | ||
List<Map<String, String>> testReportMarkdown = new ArrayList<>(); | ||
testReportMarkdown.add(createRow("abc123", "PR1", "Build1", "Test1")); | ||
testReportMarkdown.add(createRow("def456", "PR2", "Build2", "Test2")); | ||
List<Map<String, String>> gitHubMarkdown = new ArrayList<>(); | ||
gitHubMarkdown.add(createRow("abc123", "PR1", "Build1", "Test1")); | ||
MarkdownComparator comparator = new MarkdownComparator(testReportMarkdown, gitHubMarkdown); | ||
List<Map<String, String>> differences = comparator.markdownComparison(); | ||
Assert.assertEquals(1, differences.size()); | ||
Assert.assertEquals("def456", differences.get(0).get("Git Reference")); | ||
Assert.assertEquals("PR2", differences.get(0).get("Merged Pull Request")); | ||
Assert.assertEquals("Build2", differences.get(0).get("Build Details")); | ||
Assert.assertEquals("Test2", differences.get(0).get("Test Name")); | ||
} | ||
|
||
@Test | ||
public void testMarkdownComparisonWithoutDifferences() { | ||
List<Map<String, String>> testReportMarkdown = new ArrayList<>(); | ||
testReportMarkdown.add(createRow("abc123", "PR1", "Build1", "Test1")); | ||
List<Map<String, String>> gitHubMarkdown = new ArrayList<>(); | ||
gitHubMarkdown.add(createRow("abc123", "PR1", "Build1", "Test1")); | ||
MarkdownComparator comparator = new MarkdownComparator(testReportMarkdown, gitHubMarkdown); | ||
List<Map<String, String>> differences = comparator.markdownComparison(); | ||
Assert.assertEquals(0, differences.size()); | ||
} | ||
|
||
private Map<String, String> createRow(String gitReference, String mergedPR, String buildDetails, String testName) { | ||
Map<String, String> row = new HashMap<>(); | ||
row.put("Git Reference", gitReference); | ||
row.put("Merged Pull Request", mergedPR); | ||
row.put("Build Details", buildDetails); | ||
row.put("Test Name", testName); | ||
return row; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package gradlecheck | ||
|
||
import org.junit.Test | ||
import static org.junit.Assert.assertEquals | ||
|
||
class ParseMarkDownTableTest { | ||
|
||
@Test | ||
void testParseMarkdownTableRows() { | ||
def markdown = """ | ||
## Flaky Test Report for `PitMultiNodeIT` | ||
Noticed the `PitMultiNodeIT` has some flaky, failing tests that failed during **post-merge actions**. | ||
### Details | ||
| Git Reference | Merged Pull Request | Build Details | Test Name | | ||
|---------------|----------------------|---------------|-----------| | ||
| 708c37120bea33f258d1656132b9b05642c92720 | [14502](https://github.com/opensearch-project/OpenSearch/pull/14502) | [41571](https://build.ci.opensearch.org/job/gradle-check/41571/testReport/) | `org.opensearch.search.pit.PitMultiNodeIT.testCreatePitWhileNodeDropWithAllowPartialCreationFalse {p0={"search.concurrent_segment_search.enabled":"false"}}` | | ||
The other pull requests, besides those involved in post-merge actions, that contain failing tests with the `PitMultiNodeIT` class are: | ||
- [13801](https://github.com/opensearch-project/OpenSearch/pull/13801) | ||
- [14362](https://github.com/opensearch-project/OpenSearch/pull/14362) | ||
For more details on the failed tests refer to [OpenSearch Gradle Check Metrics](https://metrics.opensearch.org/_dashboards/app/dashboards#/view/e5e64d40-ed31-11ee-be99-69d1dbc75083) dashboard. | ||
""" | ||
ParseMarkDownTable parser = new ParseMarkDownTable(markdown) | ||
def result = parser.parseMarkdownTableRows() | ||
assertEquals("Expected 1 row in the result", 1, result.size()) | ||
assertEquals("708c37120bea33f258d1656132b9b05642c92720", result[0]['Git Reference']) | ||
assertEquals("[14502](https://github.com/opensearch-project/OpenSearch/pull/14502)", result[0]['Merged Pull Request']) | ||
assertEquals("[41571](https://build.ci.opensearch.org/job/gradle-check/41571/testReport/)", result[0]['Build Details']) | ||
assertEquals("`org.opensearch.search.pit.PitMultiNodeIT.testCreatePitWhileNodeDropWithAllowPartialCreationFalse {p0={\"search.concurrent_segment_search.enabled\":\"false\"}}`", result[0]['Test Name']) | ||
} | ||
} |
Oops, something went wrong.