Skip to content

Commit

Permalink
Remove more usages of deprecated constructors in tests (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Dec 20, 2024
1 parent 4d2067f commit bcb70f1
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 29 deletions.
12 changes: 9 additions & 3 deletions src/test/java/hudson/plugins/ec2/EC2AbstractSlaveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public void testMaxUsesBackwardCompat() throws Exception {
List<SlaveTemplate> templates = new ArrayList<>();
templates.add(orig);
String cloudName = "us-east-1";
AmazonEC2Cloud ac = new AmazonEC2Cloud(cloudName, false, "abc", "us-east-1", "ghi", "3", templates, null, null);
AmazonEC2Cloud ac =
new AmazonEC2Cloud(cloudName, false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);
EC2AbstractSlave slave =
new EC2AbstractSlave(
Expand All @@ -134,16 +135,21 @@ public void testMaxUsesBackwardCompat() throws Exception {
"tmpDir",
new ArrayList<>(),
"root",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvm",
false,
"idle",
null,
cloudName,
false,
Integer.MAX_VALUE,
new UnixData("remote", null, null, "22", null),
ConnectionStrategy.PRIVATE_IP,
0) {
-1,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED) {
@Override
public void terminate() {}

Expand Down
18 changes: 14 additions & 4 deletions src/test/java/hudson/plugins/ec2/EC2OndemandSlaveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@ public void testSpecifyMode() throws Exception {
"tmpDir",
Collections.emptyList(),
"remoteAdmin",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvmopts",
false,
"30",
"publicDNS",
"privateDNS",
Collections.emptyList(),
"cloudName",
false,
0,
new UnixData("a", null, null, "b", null),
ConnectionStrategy.PRIVATE_IP,
-1);
-1,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
assertEquals(Node.Mode.NORMAL, slaveNormal.getMode());

EC2OndemandSlave slaveExclusive = new EC2OndemandSlave(
Expand All @@ -53,18 +58,23 @@ public void testSpecifyMode() throws Exception {
"tmpDir",
Collections.emptyList(),
"remoteAdmin",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvmopts",
false,
"30",
"publicDNS",
"privateDNS",
Collections.emptyList(),
"cloudName",
false,
0,
new UnixData("a", null, null, "b", null),
ConnectionStrategy.PRIVATE_IP,
-1);
-1,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);

assertEquals(Node.Mode.EXCLUSIVE, slaveExclusive.getMode());
}
Expand Down
28 changes: 22 additions & 6 deletions src/test/java/hudson/plugins/ec2/EC2RetentionStrategyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,21 @@ private EC2Computer computerWithIdleTime(
"tmpDir",
new ArrayList<>(),
"remote",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvm",
false,
"idle",
null,
"cloud",
false,
Integer.MAX_VALUE,
null,
ConnectionStrategy.PRIVATE_IP,
-1) {
-1,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED) {
@Override
public void terminate() {}

Expand Down Expand Up @@ -372,16 +377,21 @@ private EC2Computer computerWithUpTime(
"tmpDir",
new ArrayList<>(),
"remote",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvm",
false,
"idle",
null,
"cloud",
false,
Integer.MAX_VALUE,
null,
ConnectionStrategy.PRIVATE_IP,
-1) {
-1,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED) {
@Override
public void terminate() {}

Expand Down Expand Up @@ -533,16 +543,21 @@ private EC2Computer computerWithUsageLimit(final int usageLimit) throws Exceptio
"tmpDir",
new ArrayList<>(),
"remote",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvm",
false,
"idle",
null,
"cloud",
false,
Integer.MAX_VALUE,
null,
ConnectionStrategy.PRIVATE_IP,
usageLimit) {
usageLimit,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED) {
@Override
public void terminate() {
terminateCalled.set(true);
Expand Down Expand Up @@ -990,6 +1005,7 @@ public void testRetentionIdleWithMinimumInstanceInactiveTimeRange() throws Excep
"abc",
"us-east-1",
PrivateKeyHelper.generate(),
null,
"3",
Collections.singletonList(template),
"roleArn",
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/hudson/plugins/ec2/SlaveTemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void testConfigRoundtrip() throws Exception {
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -223,7 +223,7 @@ public void testConfigRoundtripWithCustomSSHHostKeyVerificationStrategy() throws
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -300,7 +300,7 @@ public void testConfigWithSpotBidPrice() throws Exception {
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -372,7 +372,7 @@ public void testSpotConfigWithoutBidPrice() throws Exception {
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -403,7 +403,7 @@ public void testWindowsConfigRoundTrip() throws Exception {
"aaa",
"10",
"rrr",
new WindowsData("password", false, ""),
new WindowsData("password", false, "", false, true),
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
Expand Down Expand Up @@ -437,7 +437,7 @@ public void testWindowsConfigRoundTrip() throws Exception {
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -500,7 +500,7 @@ public void testUnixConfigRoundTrip() throws Exception {
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -571,7 +571,7 @@ public void testMinimumNumberOfInstancesActiveRangeConfig() throws Exception {
templates.add(slaveTemplate);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.configRoundtrip();
Expand Down Expand Up @@ -1030,7 +1030,7 @@ public void testMacConfig() throws Exception {
templates.add(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(getConfigForm(ac));
Expand Down Expand Up @@ -1135,11 +1135,11 @@ public void testAgentName() {
templates.add(broken);
templates.add(working);
AmazonEC2Cloud brokenCloud =
new AmazonEC2Cloud("broken/cloud", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("broken/cloud", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
assertThat(broken.getSlaveName("test"), is("test"));
assertThat(working.getSlaveName("test"), is("test"));
AmazonEC2Cloud workingCloud =
new AmazonEC2Cloud("cloud", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("cloud", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
assertThat(broken.getSlaveName("test"), is("test"));
assertThat(working.getSlaveName("test"), is("EC2 (cloud) - working (test)"));
}
Expand Down Expand Up @@ -1196,7 +1196,7 @@ public void testMetadataV2Config() throws Exception {
List<SlaveTemplate> templates = Collections.singletonList(orig);

AmazonEC2Cloud ac =
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
r.jenkins.clouds.add(ac);

r.submit(r.createWebClient().goTo("configure").getFormByName("config"));
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/hudson/plugins/ec2/TemplateLabelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void setUpCloud(String label, Node.Mode mode) throws Exception {
List<SlaveTemplate> templates = new ArrayList<>();
templates.add(template);

ac = new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", "3", templates, null, null);
ac = new AmazonEC2Cloud("us-east-1", false, "abc", "us-east-1", "ghi", null, "3", templates, null, null);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,21 @@ private static MockEC2Computer createComputer(String suffix) throws Exception {
"tmpDir",
new ArrayList<>(),
"remote",
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"jvm",
false,
"idle",
null,
"cloud",
false,
Integer.MAX_VALUE,
null,
ConnectionStrategy.PRIVATE_IP,
-1) {
-1,
Tenancy.Default,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED) {
@Override
public void terminate() {}

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/hudson/plugins/ec2/win/WinConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public void testExecute() throws Exception {
WinConnection connect = new WinConnection(
System.getProperty("winrm.host"),
System.getProperty("winrm.username", "Administrator"),
System.getProperty("winrm.password"));
System.getProperty("winrm.password"),
true);
connect.setUseHTTPS(true);
WindowsProcess process = connect.execute("dir c:\\");
process.waitFor();
Expand Down

0 comments on commit bcb70f1

Please sign in to comment.