Skip to content

Commit

Permalink
Remove usages of deprecated constructor in tests (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Dec 17, 2024
1 parent f0f5683 commit 4d2067f
Show file tree
Hide file tree
Showing 7 changed files with 675 additions and 115 deletions.
36 changes: 28 additions & 8 deletions src/test/java/hudson/plugins/ec2/EC2CloudTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void testSlaveTemplateAddition() throws Exception {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -76,10 +77,14 @@ public void testSlaveTemplateAddition() throws Exception {
false,
ConnectionStrategy.PUBLIC_IP,
-1,
null,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT);
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
cloud.addTemplate(orig);
assertNotNull(cloud.getTemplate(orig.description));
}
Expand Down Expand Up @@ -114,6 +119,7 @@ public void testSlaveTemplateUpdate() throws Exception {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -133,10 +139,14 @@ public void testSlaveTemplateUpdate() throws Exception {
false,
ConnectionStrategy.PUBLIC_IP,
-1,
null,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT);
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
SlaveTemplate secondSlaveTemplate = new SlaveTemplate(
"ami-123",
EC2AbstractSlave.TEST_ZONE,
Expand All @@ -154,6 +164,7 @@ public void testSlaveTemplateUpdate() throws Exception {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -173,10 +184,14 @@ public void testSlaveTemplateUpdate() throws Exception {
false,
ConnectionStrategy.PUBLIC_IP,
-1,
null,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT);
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
cloud.addTemplate(oldSlaveTemplate);
cloud.addTemplate(secondSlaveTemplate);
SlaveTemplate newSlaveTemplate = new SlaveTemplate(
Expand All @@ -196,6 +211,7 @@ public void testSlaveTemplateUpdate() throws Exception {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -215,10 +231,14 @@ public void testSlaveTemplateUpdate() throws Exception {
false,
ConnectionStrategy.PUBLIC_IP,
-1,
null,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT);
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
int index = cloud.getTemplates().indexOf(oldSlaveTemplate);

cloud.updateTemplate(newSlaveTemplate, "OldSlaveDescription");
Expand Down
103 changes: 84 additions & 19 deletions src/test/java/hudson/plugins/ec2/EC2RetentionStrategyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,34 @@ public SlaveTemplate getSlaveTemplate() {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet-123 subnet-456",
null,
null,
true,
0,
0,
null,
"",
false,
false,
"",
false,
"");
"",
false,
false,
false,
ConnectionStrategy.PRIVATE_DNS,
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
}

@Override
Expand Down Expand Up @@ -429,19 +444,34 @@ public SlaveTemplate getSlaveTemplate() {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet-123 subnet-456",
null,
null,
true,
0,
0,
null,
"",
false,
false,
"",
false,
"");
"",
false,
false,
false,
ConnectionStrategy.PRIVATE_DNS,
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
}

@Override
Expand Down Expand Up @@ -703,6 +733,7 @@ public void testRetentionDespiteIdleWithMinimumInstances() throws Exception {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -714,16 +745,22 @@ public void testRetentionDespiteIdleWithMinimumInstances() throws Exception {
null,
true,
true,
false,
"",
false,
"",
false,
false,
true,
ConnectionStrategy.PRIVATE_IP,
0,
Collections.emptyList());
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);
SSHCredentialHelper.assureSshCredentialAvailableThroughCredentialProviders("ghi");
AmazonEC2Cloud cloud = new AmazonEC2Cloud(
"us-east-1",
Expand Down Expand Up @@ -805,6 +842,7 @@ public void testRetentionDespiteIdleWithMinimumInstanceActiveTimeRange() throws
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -816,16 +854,22 @@ public void testRetentionDespiteIdleWithMinimumInstanceActiveTimeRange() throws
null,
true,
true,
false,
"",
false,
"",
false,
false,
true,
ConnectionStrategy.PRIVATE_IP,
0,
Collections.emptyList());
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);

MinimumNumberOfInstancesTimeRangeConfig minimumNumberOfInstancesTimeRangeConfig =
new MinimumNumberOfInstancesTimeRangeConfig();
Expand Down Expand Up @@ -897,6 +941,7 @@ public void testRetentionIdleWithMinimumInstanceInactiveTimeRange() throws Excep
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -908,16 +953,22 @@ public void testRetentionIdleWithMinimumInstanceInactiveTimeRange() throws Excep
null,
true,
true,
false,
"",
false,
"",
false,
false,
true,
ConnectionStrategy.PRIVATE_IP,
0,
Collections.emptyList());
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);

MinimumNumberOfInstancesTimeRangeConfig minimumNumberOfInstancesTimeRangeConfig =
new MinimumNumberOfInstancesTimeRangeConfig();
Expand Down Expand Up @@ -974,6 +1025,7 @@ public void testRetentionDespiteIdleWithMinimumInstanceActiveTimeRangeAfterMidni
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -985,16 +1037,22 @@ public void testRetentionDespiteIdleWithMinimumInstanceActiveTimeRangeAfterMidni
null,
true,
true,
false,
"",
false,
"",
false,
false,
true,
ConnectionStrategy.PRIVATE_IP,
0,
Collections.emptyList());
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);

MinimumNumberOfInstancesTimeRangeConfig minimumNumberOfInstancesTimeRangeConfig =
new MinimumNumberOfInstancesTimeRangeConfig();
Expand Down Expand Up @@ -1066,6 +1124,7 @@ public void testRetentionStopsAfterActiveRangeEnds() throws Exception {
"10",
"fff",
null,
EC2AbstractSlave.DEFAULT_JAVA_PATH,
"-Xmx1g",
false,
"subnet 456",
Expand All @@ -1077,16 +1136,22 @@ public void testRetentionStopsAfterActiveRangeEnds() throws Exception {
null,
true,
true,
false,
"",
false,
"",
false,
false,
true,
ConnectionStrategy.PRIVATE_IP,
0,
Collections.emptyList());
-1,
Collections.emptyList(),
null,
Tenancy.Default,
EbsEncryptRootVolume.DEFAULT,
EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED,
EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED,
EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT,
EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED);

MinimumNumberOfInstancesTimeRangeConfig minimumNumberOfInstancesTimeRangeConfig =
new MinimumNumberOfInstancesTimeRangeConfig();
Expand Down
Loading

0 comments on commit 4d2067f

Please sign in to comment.