Skip to content
Permalink
Browse files
958: Add test cases for known corner cases for synclabel bot
Reviewed-by: erikj
  • Loading branch information
rwestberg committed Apr 8, 2021
1 parent 4ca65de commit f12ee73c16968f493222088d661b7992a9dcd113
Showing 3 changed files with 308 additions and 8 deletions.
@@ -243,7 +243,7 @@ void testIgnore(TestInfo testInfo) throws IOException {
var syncLabelBot = testBotBuilder(issueProject, storageFolder).create("synclabel", JSON.object());

var issue1 = credentials.createIssue(issueProject, "Issue 1");
issue1.setProperty("fixVersions", JSON.array().add(JSON.of("8u41")));
issue1.setProperty("fixVersions", JSON.array().add(JSON.of("8u81")));
issue1.setProperty("issuetype", JSON.of("Bug"));
issue1.setState(RESOLVED);
TestBotRunner.runPeriodicItems(syncLabelBot);
@@ -278,7 +278,7 @@ void testIgnore(TestInfo testInfo) throws IOException {
assertEquals(List.of(), issue4.labelNames());

// Now try it with a configured ignore - issue 3 should lose its label
var syncLabelBotWithIgnore = testBotBuilder(issueProject, storageFolder, null, "8u4\\d").create("synclabel", JSON.object());
var syncLabelBotWithIgnore = testBotBuilder(issueProject, storageFolder, null, "8u8\\d").create("synclabel", JSON.object());
TestBotRunner.runPeriodicItems(syncLabelBotWithIgnore);
assertEquals(List.of(), issue1.labelNames());
assertEquals(List.of("hgupdate-sync"), issue2.labelNames());
@@ -296,7 +296,7 @@ void testInspect(TestInfo testInfo) throws IOException {
var syncLabelBot = testBotBuilder(issueProject, storageFolder).create("synclabel", JSON.object());

var issue1 = credentials.createIssue(issueProject, "Issue 1");
issue1.setProperty("fixVersions", JSON.array().add(JSON.of("8u41")));
issue1.setProperty("fixVersions", JSON.array().add(JSON.of("8u81")));
issue1.setProperty("issuetype", JSON.of("Bug"));
issue1.setState(RESOLVED);
TestBotRunner.runPeriodicItems(syncLabelBot);
@@ -237,7 +237,7 @@ private static List<String> releaseStreams(JdkVersion jdkVersion) {
ret.add(jdkVersion.feature() + "+updates-openjdk");
} else if (numericUpdate > 2) {
if (jdkVersion.opt().isPresent() && jdkVersion.opt().get().equals("oracle")) {
if (jdkVersion.patch().isPresent()) {
if (jdkVersion.components().size() > 4) {
ret.add(jdkVersion.feature()+ "+bpr");
} else {
ret.add(jdkVersion.feature() + "+updates-oracle");
@@ -304,6 +304,39 @@ private static List<List<Issue>> groupByReleaseStream(List<Issue> issues) {
return ret;
}

// Certain versions / build numbers have a special meaning, and should be excluded from stream processing
private static boolean onExcludeList(Issue issue) {
var fixVersion = mainFixVersion(issue);
if (fixVersion.isEmpty()) {
return false;
}

var version = fixVersion.get();

// 8u260 is a contingency release
if (version.raw().equals("8u260")) {
return true;
}

// 8u41 to 8u44 are reserved for JSR maintenance releases
if (version.feature().equals("8") && version.interim().isPresent() && Integer.parseInt(version.interim().get()) >= 41 && Integer.parseInt(version.interim().get()) <= 44) {
return true;
}

// JEP-322 interim releases (second digit > 0) should be excluded from evaluation
var featureFamilyMatcher = featureFamilyPattern.matcher(version.feature());
if (featureFamilyMatcher.matches()) {
var featureVersion = featureFamilyMatcher.group(2);
var numericFeature = Integer.parseInt(featureVersion);

if (numericFeature >= 9 && version.interim().isPresent() && !version.interim().get().equals("0")) {
return true;
}
}

return false;
}

/**
* Returns release stream duplicate issue. I.e.
* it will contain issues in any given stream if the fix version of the issue *is not* the first
@@ -314,7 +347,11 @@ private static List<List<Issue>> groupByReleaseStream(List<Issue> issues) {
public static List<Issue> releaseStreamDuplicates(List<Issue> related) {
var ret = new ArrayList<Issue>();

for (var streamIssues : groupByReleaseStream(related)) {
var includedOnly = related.stream()
.filter(issue -> !onExcludeList(issue))
.collect(Collectors.toList());

for (var streamIssues : groupByReleaseStream(includedOnly)) {
// The first issue may have the label if it was part of another
// stream. (e.g. feature release has 14 & 15 where update release
// has 15, 15.0.1 & 15.0.2. In this case the label should be
@@ -375,7 +375,7 @@ void labelTest8244004(TestInfo testInfo) throws IOException {
backports.assertLabeled();

backports.addBackports("8u260/master", "8u261/b06");
backports.assertLabeled("8u261", "8u271");
backports.assertLabeled( "8u271");
}
}

@@ -477,8 +477,7 @@ void labelTest8242283(TestInfo testInfo) throws IOException {
}

@Test
void labelTest8261303(TestInfo testInfo) throws IOException
{
void labelTest8261303(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "openjfx17");
backports.assertLabeled();
@@ -491,4 +490,268 @@ void labelTest8261303(TestInfo testInfo) throws IOException
backports.assertLabeled("8u301", "11.0.9.0.1-oracle", "11.0.10-oracle", "11.0.11-oracle");
}
}

@Test
void sampleTest1(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "16");
backports.assertLabeled();

backports.addBackports("16.0.1", "16.0.2");
backports.assertLabeled("16.0.1", "16.0.2");
}
}

@Test
void sampleTest2(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "17");
backports.assertLabeled();

backports.addBackports("16", "16.0.1");
backports.assertLabeled("17", "16.0.1");
}
}

@Test
void sampleTest3(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "17");
backports.assertLabeled();

backports.addBackports("16u-cpu", "16.0.1", "16.0.2");
backports.assertLabeled("16.0.2");
}
}

@Test
void sampleTest4(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "16");
backports.assertLabeled();

backports.addBackports("16.0.1", "16.0.2", "17");
backports.assertLabeled("16.0.1", "16.0.2", "17");
}
}

@Test
void sampleTest5(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "18");
backports.assertLabeled();

backports.addBackports("17.0.2", "17.0.3-oracle");
backports.assertLabeled("17.0.3-oracle");
}
}

@Test
void sampleTest6(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u291");
backports.assertLabeled();

backports.addBackports("8u281", "8u271/b34", "8u261/b32");
backports.assertLabeled("8u291", "8u271");
}
}

@Test
void sampleTest7(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u291");
backports.assertLabeled();

backports.addBackports("8u281/b31", "8u271/b60", "7u301");
backports.assertLabeled();
}
}

@Test
void sampleTest8(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u291");
backports.assertLabeled();

backports.addBackports("8u281/b31", "8u271/b37", "openjdk8u292");
backports.assertLabeled("8u281");
}
}

@Test
void sampleTest9(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u260");
backports.assertLabeled();

backports.addBackports("8u261", "8u271");
backports.assertLabeled("8u271");
}
}

@Test
void sampleTest10(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u261");
backports.assertLabeled();

backports.addBackports("8u271", "8u281", "emb-8u271", "emb-8u281");
backports.assertLabeled("8u271", "8u281", "emb-8u281");
}
}

@Test
void sampleTest11(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u271/b35");
backports.assertLabeled();

backports.addBackports("8u281/b31", "8u291", "openjdk8u292");
backports.assertLabeled("8u281");
}
}

@Test
void sampleTest12(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u261");
backports.assertLabeled();

backports.addBackports("8u271", "openjdk8u275", "openjdk8u292", "emb-8u271");
backports.assertLabeled("8u271", "openjdk8u292");
}
}

@Test
void sampleTest13(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u261");
backports.assertLabeled();

backports.addBackports("8u-tls13-repo", "8u271", "emb-8u261");
backports.assertLabeled("8u271");
}
}

@Test
void sampleTest14(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u41");
backports.assertLabeled();

backports.addBackports("8u261", "8u251");
backports.assertLabeled("8u261");
}
}

@Test
void sampleTest15(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u291");
backports.assertLabeled();

backports.addBackports("8u301", "8u281-b31");
backports.assertLabeled("8u301");
}
}

@Test
void sampleTest16(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "8u301");
backports.assertLabeled();

backports.addBackports("8u293");
backports.assertLabeled("8u301");
}
}

@Test
void sampleTest17(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "11.0.11");
backports.assertLabeled();

backports.addBackports("11.0.11-oracle");
backports.assertLabeled();
}
}

@Test
void sampleTest18(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "11.0.9");
backports.assertLabeled();

backports.addBackports("11.0.10-oracle");
backports.assertLabeled();
}
}

@Test
void sampleTest19(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "11.0.12-oracle");
backports.assertLabeled();

backports.addBackports("11.0.13-oracle", "11.0.11.0.1-oracle");
backports.assertLabeled("11.0.13-oracle");
}
}

@Test
void sampleTest20(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "11.0.13-oracle");
backports.assertLabeled();

backports.addBackports("11.0.14-oracle", "11.0.12.1-oracle");
backports.assertLabeled("11.0.13-oracle", "11.0.14-oracle");
}
}

@Test
void sampleTest21(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "11.0.13-oracle");
backports.assertLabeled();

backports.addBackports("11.0.14-oracle", "11.1.2");
backports.assertLabeled("11.0.14-oracle");
}
}

@Test
void sampleTest22(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "15");
backports.assertLabeled();

backports.addBackports("14.0.1", "14", "13.0.2", "11.0.7", "11.0.6-oracle", "11.0.6", "openjdk8u252", "openjdk8u242", "8u241");
backports.assertLabeled("15", "14.0.1", "11.0.7", "openjdk8u252");
}
}

@Test
void sampleTest23(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "17");
backports.assertLabeled();

backports.addBackports("11.0.11-oracle", "11.0.11", "8u291", "8u281/b31", "8u271/b60", "emb-8u291", "7u301");
backports.assertLabeled();
}
}

@Test
void sampleTest24(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "15");
backports.assertLabeled();

backports.addBackports("14u-cpu", "14.0.2", "13.0.7", "11.0.9-oracle", "11.0.9");
backports.assertLabeled();
}
}
}

1 comment on commit f12ee73

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on f12ee73 Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.