-
Notifications
You must be signed in to change notification settings - Fork 322
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
Require Jenkins 2.414.3 or newer #1016
Changes from all commits
e88d5df
0103d7e
e84b15c
33e6941
8cf32d3
ea7f0e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,6 @@ | |
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.logging.Level; | ||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.core.IsIterableContaining; | ||
import org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials; | ||
import org.jenkinsci.plugins.docker.commons.credentials.DockerServerEndpoint; | ||
import org.junit.Assert; | ||
|
@@ -58,34 +56,14 @@ public void testConstructor_0_10_2() { | |
|
||
private static final String LOG_MESSAGE = "Docker cloud requires a non-blank name after Jenkins 2.402"; | ||
|
||
@Issue("JENKINS-70729") // Warn if cloud name is empty | ||
@Test | ||
public void testConstructorWithEmptyName() { | ||
lr.record(DockerCloud.class.getName(), Level.ALL).capture(16); | ||
DockerCloud cloud = | ||
new DockerCloud("", new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of()); | ||
Assert.assertEquals(cloud.getDisplayName(), ""); | ||
MatcherAssert.assertThat(lr.getMessages(), IsIterableContaining.hasItem(LOG_MESSAGE)); | ||
} | ||
|
||
@Issue("JENKINS-70729") // Warn if cloud name is null | ||
@Test | ||
public void testConstructorWithNullName() { | ||
lr.record(DockerCloud.class.getName(), Level.ALL).capture(16); | ||
DockerCloud cloud = | ||
new DockerCloud(null, new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of()); | ||
Assert.assertEquals(cloud.getDisplayName(), null); | ||
MatcherAssert.assertThat(lr.getMessages(), IsIterableContaining.hasItem(LOG_MESSAGE)); | ||
} | ||
|
||
@Issue("JENKINS-70729") // Handle null or empty cloud name | ||
@Test | ||
public void testCopyConstructor() { | ||
lr.record(DockerCloud.class.getName(), Level.ALL).capture(16); | ||
DockerCloud cloud = | ||
new DockerCloud(null, new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of()); | ||
new DockerCloud("tmp", new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MarkEWaite I kept the CopyConstructor test since it covers backwards compatibility, but I had to modify it to allow an "empty" named DockerCloud There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @car-roll . That makes sense to me. Assigning directly to the |
||
cloud.name = null; | ||
Assert.assertEquals(cloud.getDisplayName(), null); | ||
MatcherAssert.assertThat(lr.getMessages(), IsIterableContaining.hasItem(LOG_MESSAGE)); | ||
String newName = "docker-cloud-" + Integer.toHexString(cloud.hashCode()); | ||
DockerCloud copy = new DockerCloud(newName, cloud); | ||
Assert.assertEquals(cloud.getDockerApi(), copy.getDockerApi()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarkEWaite I removed these two tests because the base class (
Cloud
) now throws anIllegalArgumentException
that does not allow the creation ofDockerCloud
. The warning log message will now never be generated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @car-roll ! Has the base class been extended to handle upgrades on systems that already have a Docker cloud named with an empty string? If not, that seems like it will be needed in order to not break upgrades.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the base class has not been extended to support empty string Cloud names, but support is still there as I did not touch the
readResolve
inDockerCloud
.Just to clarify what I meant, I believe the code that these two tests are testing (
testConstructorWithEmptyName
andtestConstructorWithNullName
) are testing the constructor itselfdocker-plugin/src/main/java/com/nirima/jenkins/plugins/docker/DockerCloud.java
Line 136 in ccec39c
However, with this new jenkins version, we are now failing on the
super(name)
call, so that log message will now never be called. Test-wise, I do not think I can reproduce this scenario with the new Jenkins version.The only time now we will have to deal with a null name constructor should be in existing cloud names, which is tested in
testCopyConstructor
.