Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read resolvedInBuild JBS property properly #1042

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -339,4 +339,49 @@ void testInspect(TestInfo testInfo) throws IOException {
assertEquals(List.of("hgupdate-sync"), issue4.labels());
}
}

@Test
void testAddLabelWithBuild(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var storageFolder = tempFolder.path().resolve("storage");
var issueProject = credentials.getIssueProject();
var syncLabelBot = testBotBuilder(issueProject, storageFolder).create("synclabel", JSON.object());

var issue1 = credentials.createIssue(issueProject, "Issue 1");
issue1.setProperty("fixVersions", JSON.array().add(JSON.of("openjfx17")));
issue1.setProperty("issuetype", JSON.of("Bug"));
issue1.setState(RESOLVED);
TestBotRunner.runPeriodicItems(syncLabelBot);
assertEquals(List.of(), issue1.labels());

var issue2 = credentials.createIssue(issueProject, "Issue 2");
issue2.setProperty("fixVersions", JSON.array().add(JSON.of("8u271")));
issue2.setProperty("issuetype", JSON.of("Backport"));
issue2.setProperty("customfield_10006", JSON.of("b33"));
issue2.setState(RESOLVED);
issue1.addLink(Link.create(issue2, "backported by").build());
TestBotRunner.runPeriodicItems(syncLabelBot);
assertEquals(List.of(), issue1.labels());

var issue3 = credentials.createIssue(issueProject, "Issue 3");
issue3.setProperty("fixVersions", JSON.array().add(JSON.of("8u291")));
issue3.setProperty("issuetype", JSON.of("Backport"));
issue3.setState(RESOLVED);
issue1.addLink(Link.create(issue3, "backported by").build());
TestBotRunner.runPeriodicItems(syncLabelBot);
assertEquals(List.of(), issue3.labels());

var issue4 = credentials.createIssue(issueProject, "Issue 4");
issue4.setProperty("fixVersions", JSON.array().add(JSON.of("8u301")));
issue4.setProperty("issuetype", JSON.of("Backport"));
issue4.setState(RESOLVED);
issue1.addLink(Link.create(issue4, "backported by").build());
TestBotRunner.runPeriodicItems(syncLabelBot);
assertEquals(List.of(), issue1.labels());
assertEquals(List.of(), issue2.labels());
assertEquals(List.of(), issue3.labels());
assertEquals(List.of("hgupdate-sync"), issue4.labels());
}
}
}
@@ -73,8 +73,8 @@ public static Optional<JdkVersion> mainFixVersion(Issue issue) {
log.warning("Issue " + issue.id() + " has multiple valid fixVersions - ignoring");
return Optional.empty();
}
if (issue.properties().containsKey("customfield_10006") && issue.properties().get("customfield_10006").isObject()) {
return JdkVersion.parse(versionString.get(0), issue.properties().get("customfield_10006").get("value").asString());
if (issue.properties().containsKey("customfield_10006")) {
return JdkVersion.parse(versionString.get(0), issue.properties().get("customfield_10006").asString());
Copy link
Member

@edvbld edvbld Mar 10, 2021

Choose a reason for hiding this comment

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

Would you mind creating a variable naming the custom field? For example:

var resolvedInBuild = "customfield_10006";
if (issue.properties().containsKey(resolvedInBuild)) {

Copy link
Member Author

@rwestberg rwestberg Mar 10, 2021

Choose a reason for hiding this comment

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

This exist in quite a few places already, and properly fixing it would require a larger refactoring. So I think we should do that separately.

Copy link
Member

@edvbld edvbld Mar 10, 2021

Choose a reason for hiding this comment

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

Ok, sounds good!

} else {
return JdkVersion.parse(versionString.get(0));
}
@@ -196,7 +196,7 @@ private void setState(Issue issue, String version) {
}
issue.setProperty("fixVersions", JSON.array().add(version));
if (!resolvedInBuild.isEmpty()) {
issue.setProperty("customfield_10006", JSON.object().put("value", resolvedInBuild));
issue.setProperty("customfield_10006", JSON.of(resolvedInBuild));
}
}

@@ -475,4 +475,20 @@ void labelTest8242283(TestInfo testInfo) throws IOException {
backports.assertLabeled();
}
}

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

backports.addBackports("8u271/b33", "8u291", "8u301");
backports.assertLabeled("8u301");

backports.addBackports("11.0.11-oracle", "11.0.11", "11.0.10-oracle", "11.0.9.0.1-oracle/b01",
"11.0.9-oracle", "11.0.8.0.2-oracle");
backports.assertLabeled("8u301", "11.0.9.0.1-oracle", "11.0.10-oracle", "11.0.11-oracle");
}
}
}