diff --git a/pom.xml b/pom.xml index ed13db5..259a00f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - + 4.0.0 org.jenkins-ci.plugins plugin 4.9 - + spotinst @@ -14,7 +15,6 @@ hpi Spotinst plugin - This plugin allows Jenkins to start agents with the Spot framework and terminate them as they become idle. https://github.com/jenkinsci/spotinst-plugin/blob/master/JenkinsWiki.adoc @@ -33,19 +33,39 @@ - scm:git:git://github.com/jenkinsci/spotinst-plugin.git + scm:git:https://github.com/jenkinsci/spotinst-plugin.git scm:git:git@github.com:jenkinsci/spotinst-plugin.git https://github.com/jenkinsci/spotinst-plugin HEAD - 2.222.4 - 8 + 2.426.3 + 11 + 11 + 11 + 11 + 11 + 1.33 + + org.jenkins-ci.plugins + variant + 60.v7290fc0eb_b_cd + + + javax.servlet + javax.servlet-api + 4.0.1 + + + commons-logging + commons-logging + 1.3.1 + io.jenkins.tools.bom bom-2.249.x @@ -53,64 +73,323 @@ import pom + + commons-io + commons-io + 2.15.1 + + + com.github.spotbugs + spotbugs-annotations + 4.8.3 + + + junit + junit + 4.13.2 + + + org.kohsuke.stapler + stapler + 1839.ved17667b_a_eb_5 + + + args4j + args4j + 2.37 + + + com.google.code.findbugs + jsr305 + 3.0.2 + true + + + com.google.errorprone + error_prone_annotations + 2.26.1 + + + com.google.guava + guava + 33.1.0-jre + + + com.google.guava + guava-testlib + 33.1.0-jre + + + com.google.inject + guice + 7.0.0 + + + com.google.inject + guice + 7.0.0 + classes + + + com.google.inject.extensions + guice-assistedinject + 7.0.0 + + + com.google.inject.extensions + guice-dagger-adapter + 7.0.0 + + + com.google.inject.extensions + guice-grapher + 7.0.0 + + + com.google.inject.extensions + guice-jmx + 7.0.0 + + + com.google.inject.extensions + guice-jndi + 7.0.0 + + + com.google.inject.extensions + guice-persist + 7.0.0 + + + com.google.inject.extensions + guice-servlet + 7.0.0 + + + com.google.inject.extensions + guice-spring + 7.0.0 + + + com.google.inject.extensions + guice-struts2 + 7.0.0 + + + com.google.inject.extensions + guice-testlib + 7.0.0 + + + com.google.inject.extensions + guice-throwingproviders + 7.0.0 + + + com.google.truth + truth + 1.4.2 + test + + + com.google.truth.extensions + truth-java8-extension + 1.4.2 + test + + + commons-codec + commons-codec + 1.16.1 + + + commons-collections + commons-collections + 20040616 + + + io.jenkins + configuration-as-code + 1775.v810dc950b_514 + + + io.jenkins.configuration-as-code + test-harness + 1775.v810dc950b_514 + + + io.jenkins.plugins + snakeyaml-api + 2.2-111.vc6598e30cc65 + + + org.codehaus.mojo.signature + java18 + 1.0 + signature + + + com.github.spotbugs + spotbugs-annotations + 4.8.3 + provided + true + + + commons-logging + commons-logging + 1.3.1 + provided + + + junit + junit + 4.13.2 + test + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + org.apache.httpcomponents httpclient - 4.5 + 4.5.14 + + + commons-logging + commons-logging + + org.apache.httpcomponents httpcore - 4.4.1 + 4.4.16 com.fasterxml.jackson.core jackson-core - 2.7.4 + 2.17.0 com.fasterxml.jackson.core jackson-annotations - 2.7.4 + 2.17.0 com.fasterxml.jackson.core jackson-databind - 2.7.4 + 2.17.0 + + + org.codehaus.mojo + animal-sniffer-annotations + 1.23 org.mockito mockito-all - 1.8.4 + 2.0.2-beta + test + + + org.jenkins-ci.main + jenkins-test-harness + 2182.v0138ccb_c0b_cb_ test + + org.jenkins-ci + test-annotations + 1.4 + org.jenkins-ci.plugins trilead-api - 1.0.13 + 2.142.v748523a_76693 + + + org.jenkins-ci + symbol-annotation + 1.24 + + + org.jenkins-ci.plugins + ssh-credentials + 334.v7732563deee1 org.jenkins-ci.plugins ssh-slaves - 1.31.3 + 2.948.vb_8050d697fec + + + org.jenkins-ci.plugins + structs + 337.v1b_04ea_4df7c8 + + + org.jenkins-ci.plugins + credentials + 1337.v60b_d7b_c7b_c9f org.jenkins-ci.plugins plain-credentials - 1.7 + 179.vc5cb_98f6db_38 org.apache.commons commons-collections4 4.4 + compile + + + commons-codec + commons-codec + 1.16.1 + compile + + + org.kohsuke.stapler + stapler + 1839.ved17667b_a_eb_5 + compile + + + commons-logging + commons-logging + + + + + org.twdata.maven + mojo-executor + 2.4.0 + + + javax.inject + javax.inject + 1 + + + false + + central + Maven Repository Switchboard + https://repo1.maven.org/maven2 + repo.jenkins-ci.org http://repo.jenkins-ci.org/public/ @@ -118,9 +397,20 @@ + + + never + + + false + + central + Maven Plugin Repository + https://repo1.maven.org/maven2 + repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ + https://repo.jenkins-ci.org/public/ @@ -128,18 +418,100 @@ + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + --illegal-access=permit + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M4 + + + --illegal-access=permit + + + + + org.jenkins-ci.tools + maven-hpi-plugin + 3.48 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 - true + 11 + 11 + 11 + + org.codehaus.mojo findbugs-maven-plugin - - - none - - + 3.0.5 + + + + org.jenkins-ci.tools + maven-hpi-plugin + 3.48 + + + maven-enforcer-plugin + 3.4.1 + + + org.codehaus.mojo + extra-enforcer-rules + 1.8.0 + compile + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + 1.19 + + + check + test + + check + + + + org.codehaus.mojo.signature + java18 + + + + + + true + + org.codehaus.mojo.signature + java18 + 1.0 + + java.lang.invoke.MethodHandle + + + + org.eclipse.jetty + jetty-maven-plugin + 11.0.20 + + diff --git a/src/main/java/hudson/plugins/spotinst/api/SpotinstApi.java b/src/main/java/hudson/plugins/spotinst/api/SpotinstApi.java index abac8e9..8cd62c4 100644 --- a/src/main/java/hudson/plugins/spotinst/api/SpotinstApi.java +++ b/src/main/java/hudson/plugins/spotinst/api/SpotinstApi.java @@ -16,9 +16,9 @@ import hudson.plugins.spotinst.model.redis.LockGroupControllerRequest; import hudson.plugins.spotinst.model.redis.LockGroupControllerResponse; import jenkins.model.Jenkins; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/hudson/plugins/spotinst/cloud/AwsSpotinstCloud.java b/src/main/java/hudson/plugins/spotinst/cloud/AwsSpotinstCloud.java index b6ed9fe..910d02f 100644 --- a/src/main/java/hudson/plugins/spotinst/cloud/AwsSpotinstCloud.java +++ b/src/main/java/hudson/plugins/spotinst/cloud/AwsSpotinstCloud.java @@ -298,26 +298,34 @@ protected BlResponse checkIsStatefulGroup() { ApiResponse groupResponse = awsGroupRepo.getGroup(groupId, this.accountId); if (groupResponse.isRequestSucceed()) { - Boolean result = false; - AwsGroup awsGroup = groupResponse.getValue(); + Boolean result = getIsStatefulFromGroup(groupResponse.getValue()); + + retVal = new BlResponse<>(result); + } + else { + LOGGER.error(String.format("Failed to get group %s. Errors: %s", groupId, groupResponse.getErrors())); + retVal = new BlResponse<>(false); + } + + return retVal; + } + + private static Boolean getIsStatefulFromGroup(AwsGroup awsGroup) { + boolean retVal = false; + + if(awsGroup != null) { AwsGroupStrategy groupStrategy = awsGroup.getStrategy(); if (groupStrategy != null) { AwsGroupPersistence groupPersistence = groupStrategy.getPersistence(); if (groupPersistence != null) { - result = BooleanUtils.isTrue(groupPersistence.getShouldPersistPrivateIp()) || + retVal = BooleanUtils.isTrue(groupPersistence.getShouldPersistPrivateIp()) || BooleanUtils.isTrue(groupPersistence.getShouldPersistBlockDevices()) || BooleanUtils.isTrue(groupPersistence.getShouldPersistRootDevice()) || StringUtils.isNotEmpty(groupPersistence.getBlockDevicesMode()); } } - - retVal = new BlResponse<>(result); - } - else { - LOGGER.error(String.format("Failed to get group %s. Errors: %s", groupId, groupResponse.getErrors())); - retVal = new BlResponse<>(false); } return retVal; diff --git a/src/main/java/hudson/plugins/spotinst/cloud/BaseSpotinstCloud.java b/src/main/java/hudson/plugins/spotinst/cloud/BaseSpotinstCloud.java index dfc5ed9..b0d9cc4 100644 --- a/src/main/java/hudson/plugins/spotinst/cloud/BaseSpotinstCloud.java +++ b/src/main/java/hudson/plugins/spotinst/cloud/BaseSpotinstCloud.java @@ -177,6 +177,11 @@ public Collection provision(Label label, int excessWorkload) { return Collections.emptyList(); } + @Override + public Collection provision(CloudState state, int excessWorkload) { + return this.provision(state.getLabel(), excessWorkload); + } + @Override public boolean canProvision(Label label) { boolean canProvision = true; @@ -193,6 +198,11 @@ public boolean canProvision(Label label) { return canProvision; } + @Override + public boolean canProvision(CloudState state) { + return this.canProvision(state.getLabel()); + } + @Override public DescriptorImpl getDescriptor() { return (DescriptorImpl) super.getDescriptor(); diff --git a/src/main/java/hudson/plugins/spotinst/cloud/monitor/AwsSpotinstCloudInstanceTypeMonitor.java b/src/main/java/hudson/plugins/spotinst/cloud/monitor/AwsSpotinstCloudInstanceTypeMonitor.java index 180c70e..1dcf563 100644 --- a/src/main/java/hudson/plugins/spotinst/cloud/monitor/AwsSpotinstCloudInstanceTypeMonitor.java +++ b/src/main/java/hudson/plugins/spotinst/cloud/monitor/AwsSpotinstCloudInstanceTypeMonitor.java @@ -5,7 +5,7 @@ import hudson.plugins.spotinst.cloud.AwsSpotinstCloud; import hudson.slaves.Cloud; import jenkins.model.Jenkins; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/hudson/plugins/spotinst/cloud/monitor/SpotinstCloudsCommunicationMonitor.java b/src/main/java/hudson/plugins/spotinst/cloud/monitor/SpotinstCloudsCommunicationMonitor.java index c87b3fc..957c2d5 100644 --- a/src/main/java/hudson/plugins/spotinst/cloud/monitor/SpotinstCloudsCommunicationMonitor.java +++ b/src/main/java/hudson/plugins/spotinst/cloud/monitor/SpotinstCloudsCommunicationMonitor.java @@ -6,7 +6,7 @@ import hudson.plugins.spotinst.common.GroupLockingManager; import hudson.plugins.spotinst.common.SpotinstCloudCommunicationState; import jenkins.model.Jenkins; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/hudson/plugins/spotinst/jobs/SpotinstSyncGroupsController.java b/src/main/java/hudson/plugins/spotinst/jobs/SpotinstSyncGroupsController.java index 222edd1..61a3096 100644 --- a/src/main/java/hudson/plugins/spotinst/jobs/SpotinstSyncGroupsController.java +++ b/src/main/java/hudson/plugins/spotinst/jobs/SpotinstSyncGroupsController.java @@ -10,7 +10,7 @@ import hudson.plugins.spotinst.jobs.jobSynchronizer.JobSynchronizer; import hudson.slaves.Cloud; import jenkins.model.Jenkins; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly new file mode 100644 index 0000000..61b3296 --- /dev/null +++ b/src/main/resources/index.jelly @@ -0,0 +1,7 @@ + + + +
+ This plugin allows Jenkins to start agents with the Spot framework and terminate them as they become idle. +
+
diff --git a/src/test/java/hudson/plugins/spotinst/SpotinstCloudTest.java b/src/test/java/hudson/plugins/spotinst/SpotinstCloudTest.java index 3f28084..56111b5 100644 --- a/src/test/java/hudson/plugins/spotinst/SpotinstCloudTest.java +++ b/src/test/java/hudson/plugins/spotinst/SpotinstCloudTest.java @@ -1,5 +1,6 @@ package hudson.plugins.spotinst; +import hudson.model.Label; import hudson.model.Node; import hudson.plugins.spotinst.api.infra.ApiResponse; import hudson.plugins.spotinst.cloud.*; @@ -90,13 +91,14 @@ private PendingInstance buildPendingInstance(String id, Integer executors) { @Test public void testAwsProvision_whenThereArePendingInsatcnesForAllExecutors_thenShouldNotSacleUp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotinstCloud = new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, SlaveUsageEnum.NORMAL, "", false, true, "", null, - null, null, null, null, null, null, null); + null, accountId, null, null, null, null, null); Map pendingInstances = new HashMap<>(); pendingInstances.put("sir-1", buildPendingInstance("sir-1", 2)); spotinstCloud.setPendingInstances(pendingInstances); - spotinstCloud.provision(null, 2); + spotinstCloud.provision((Label)null, 2); Mockito.verify(RepoManager.getInstance().getAwsGroupRepo(), Mockito.never()) .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()); } @@ -124,7 +126,7 @@ public void testAwsProvision_whenThereArePendingInsatcnesForPartOfTheExecutors_t .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(result)); - spotinstCloud.provision(null, 4); + spotinstCloud.provision((Label)null, 4); ArgumentCaptor groupCapture = ArgumentCaptor.forClass(String.class); ArgumentCaptor unitsCapture = ArgumentCaptor.forClass(Integer.class); @@ -138,8 +140,9 @@ public void testAwsProvision_whenThereArePendingInsatcnesForPartOfTheExecutors_t @Test public void testAwCloud_whenNoConnectionMethodIsProvided_thenDefaultIsJNLP() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotCloud = - new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, null, + new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, accountId, null, null, false, null, null); jenkinsRule.jenkins.clouds.add(spotCloud); assertEquals(spotCloud.getConnectionMethod(), ConnectionMethodEnum.JNLP); @@ -158,7 +161,7 @@ public void testAwCloud_whenNoConnectionMethodIsProvided_thenDefaultIsJNLP() { .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(result)); - spotCloud.provision(null, 2); + spotCloud.provision((Label)null, 2); List allNodes = Jenkins.get().getNodes(); @@ -208,7 +211,7 @@ public void testAwsCloud_whenSshConnectionMethod_andIpIsAvailable_thenCreateSshL .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - spotCloud.provision(null, 1); + spotCloud.provision((Label)null, 1); spotCloud.monitorInstances(); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(incomingInstance.getInstanceId()); @@ -255,7 +258,7 @@ public void testAwsCloud_whenSshConnectionMethod_andIpIsNotAvailable_thenDoNotCo .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - spotCloud.provision(null, 1); + spotCloud.provision((Label)null, 1); spotCloud.monitorInstances(); @@ -271,8 +274,9 @@ public void testAwsCloud_whenSshConnectionMethod_andIpIsNotAvailable_thenDoNotCo @Test public void testAwCloud_whenUsePrivateIpIsNull_thenUsePublicIp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotCloud = - new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, null, + new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, accountId, null, null, null, null, null); assertFalse(spotCloud.getShouldUsePrivateIp()); @@ -281,8 +285,9 @@ public void testAwCloud_whenUsePrivateIpIsNull_thenUsePublicIp() { @Test public void testAwCloud_whenUsePrivateIpIsTrue_thenUsePrivateIp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotCloud = - new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, null, + new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, accountId, null, null, true, null, null); assertTrue(spotCloud.getShouldUsePrivateIp()); @@ -291,8 +296,9 @@ public void testAwCloud_whenUsePrivateIpIsTrue_thenUsePrivateIp() { @Test public void testAwCloud_whenUsePrivateIpIsFalse_thenUsePublicIp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotCloud = - new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, null, + new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, accountId, null, null, false, null, null); assertFalse(spotCloud.getShouldUsePrivateIp()); @@ -303,13 +309,14 @@ public void testAwCloud_whenUsePrivateIpIsFalse_thenUsePublicIp() { @Test public void testGcpProvision_whenThereArePendingInsatcnesForAllExecutors_thenShouldNotSacleUp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotinstCloud = - new GcpSpotinstCloud(groupId, "", "20", "/tmp", null, "", false, true, "", null, null, null, null, null, + new GcpSpotinstCloud(groupId, "", "20", "/tmp", null, "", false, true, "", null, null, accountId, null, null, null, null, null); Map pendingInstances = new HashMap<>(); pendingInstances.put("sin-1", buildPendingInstance("sin-1", 2)); spotinstCloud.setPendingInstances(pendingInstances); - spotinstCloud.provision(null, 2); + spotinstCloud.provision((Label)null, 2); Mockito.verify(RepoManager.getInstance().getGcpGroupRepo(), Mockito.never()) .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()); } @@ -336,7 +343,7 @@ public void testGcpProvision_whenThereArePendingInsatcnesForPartOfTheExecutors_t .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(result)); - spotinstCloud.provision(null, 4); + spotinstCloud.provision((Label)null, 4); ArgumentCaptor groupCapture = ArgumentCaptor.forClass(String.class); ArgumentCaptor unitsCapture = ArgumentCaptor.forClass(Integer.class); @@ -352,14 +359,15 @@ public void testGcpProvision_whenThereArePendingInsatcnesForPartOfTheExecutors_t @Test public void testAzureProvision_whenThereArePendingInsatcnesForAllExecutors_thenShouldNotSacleUp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotinstCloud = - new AzureSpotinstCloud(groupId, "", "20", "/tmp", null, "", false, false, "", null, null, null, null, + new AzureSpotinstCloud(groupId, "", "20", "/tmp", null, "", false, false, "", null, null, accountId, null, null, null, null, null); Map pendingInstances = new HashMap<>(); pendingInstances.put("q3213", buildPendingInstance(groupId, 1)); pendingInstances.put("41234", buildPendingInstance(groupId, 1)); spotinstCloud.setPendingInstances(pendingInstances); - spotinstCloud.provision(null, 2); + spotinstCloud.provision((Label)null, 2); Mockito.verify(RepoManager.getInstance().getAzureGroupRepo(), Mockito.never()) .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()); } @@ -380,7 +388,7 @@ public void testAzureProvision_whenThereArePendingInsatcnesForPartOfTheExecutors .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(Boolean.TRUE)); - spotinstCloud.provision(null, 4); + spotinstCloud.provision((Label)null, 4); ArgumentCaptor groupCapture = ArgumentCaptor.forClass(String.class); ArgumentCaptor unitsCapture = ArgumentCaptor.forClass(Integer.class); @@ -396,14 +404,15 @@ public void testAzureProvision_whenThereArePendingInsatcnesForPartOfTheExecutors @Test public void testAzureV3Provision_whenThereArePendingInstancesForAllExecutors_thenShouldNotScaleUp() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotinstCloud = - new AzureSpotCloud(groupId, "", "20", "/tmp", null, "", false, true, "", null, null, null, null, null, + new AzureSpotCloud(groupId, "", "20", "/tmp", null, "", false, true, "", null, null, accountId, null, null, null, null, null); Map pendingInstances = new HashMap<>(); pendingInstances.put("vm-1", buildPendingInstance("vm-1", 2)); spotinstCloud.setPendingInstances(pendingInstances); - spotinstCloud.provision(null, 2); + spotinstCloud.provision((Label)null, 2); Mockito.verify(RepoManager.getInstance().getAzureVmGroupRepo(), Mockito.never()) .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString()); @@ -432,7 +441,7 @@ public void testAzureV3Provision_whenThereArePendingInstancesForPartOfTheExecuto .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(vms)); - spotinstCloud.provision(null, 4); + spotinstCloud.provision((Label)null, 4); ArgumentCaptor groupCapture = ArgumentCaptor.forClass(String.class); ArgumentCaptor unitsCapture = ArgumentCaptor.forClass(Integer.class); @@ -463,7 +472,7 @@ public void testAzureV3Provision_whenUnrecognizedVmSize_thenDefaultTo1Executor() .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(vms)); - spotinstCloud.provision(null, 4); + spotinstCloud.provision((Label)null, 4); Node node = Jenkins.get().getNode("vm-2"); assertNotNull(node); @@ -497,7 +506,7 @@ public void testAzureV3Provision_whenNewInstancesAreLaunched_thenTheirSizeIsAcco .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(vms)); - spotinstCloud.provision(null, 4); + spotinstCloud.provision((Label)null, 4); List allNodes = Jenkins.get().getNodes(); @@ -538,8 +547,8 @@ public void testAzureV3Provision_whenNewInstancesAreLaunched_thenTheirSizeIsAcco .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(vms)); - spotinstCloud.provision(null, 3); - spotinstCloud.provision(null, 2); + spotinstCloud.provision((Label)null, 3); + spotinstCloud.provision((Label)null, 2); Mockito.verify(RepoManager.getInstance().getAzureVmGroupRepo(), Mockito.times(1)) .scaleUp(groupId, 1, accountId); @@ -550,8 +559,9 @@ public void testAzureV3Provision_whenNewInstancesAreLaunched_thenTheirSizeIsAcco @Test public void testAzureV3Cloud_whenNoConnectionMethodIsProvided_thenDefaultIsJNLP() { String groupId = "sig-1"; + String accountId = "act-111"; BaseSpotinstCloud spotCloud = - new AzureSpotCloud(groupId, "", "20", "/tmp", null, "", false, true, "", null, null, null, null, null, + new AzureSpotCloud(groupId, "", "20", "/tmp", null, "", false, true, "", null, null, accountId, null, null, null, null, null); jenkinsRule.jenkins.clouds.add(spotCloud); @@ -569,7 +579,7 @@ public void testAzureV3Cloud_whenNoConnectionMethodIsProvided_thenDefaultIsJNLP( .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(vms)); - spotCloud.provision(null, 2); + spotCloud.provision((Label)null, 2); List allNodes = Jenkins.get().getNodes(); @@ -586,9 +596,10 @@ public void testAzureV3Cloud_whenNoConnectionMethodIsProvided_thenDefaultIsJNLP( @Test public void testGlobalExecutorOverride_whenIsPassedAsNullInCloudConstructor_ThenDefaultIsNotEnabledAndExecutors1() { String groupId = "sig-1"; + String accountId = "act-111"; SpotGlobalExecutorOverride globalOverride = null; BaseSpotinstCloud cloud = - new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, null, + new AwsSpotinstCloud(groupId, "", "20", "/tmp", null, null, "", true, null, null, null, null, accountId, ConnectionMethodEnum.SSH, getSSHConnector(), false, globalOverride, null); jenkinsRule.jenkins.clouds.add(cloud); @@ -632,7 +643,7 @@ public void testGlobalExecutorOverride_whenIsEnabledAndInstanceTypeIsMatchedInEn .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -673,7 +684,7 @@ public void testGlobalExecutorOverride_whenIsEnabledAndInstanceTypeIsNotMatchedI .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -720,7 +731,7 @@ null, accountId, ConnectionMethodEnum.SSH, getSSHConnector(), false, .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -763,7 +774,7 @@ public void testGlobalExecutorOverride_whenIsDisabledAndInstanceTypeIsNotMatched .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -804,7 +815,7 @@ public void testGlobalExecutorOverride_whenIsDisabledAndInstanceTypeIsMatchedInE .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -852,7 +863,7 @@ null, accountId, ConnectionMethodEnum.SSH, getSSHConnector(), false, .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -894,7 +905,7 @@ public void testGlobalExecutorOverride_whenIsInvalidNegativeAndInstanceTypeIsMat .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -935,7 +946,7 @@ public void testGlobalExecutorOverride_whenIsInvalidNegativeAndInstanceTypeIsNot .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -983,7 +994,7 @@ null, accountId, ConnectionMethodEnum.SSH, getSSHConnector(), false, .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1024,7 +1035,7 @@ public void testGlobalExecutorOverride_whenIsInvalidNullAndInstanceTypeIsMatched .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1065,7 +1076,7 @@ public void testGlobalExecutorOverride_whenIsInvalidNullAndInstanceTypeIsNotMatc .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1113,7 +1124,7 @@ null, accountId, ConnectionMethodEnum.SSH, getSSHConnector(), false, .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1155,7 +1166,7 @@ public void testGlobalExecutorOverride_whenIsNullAndInstanceTypeIsMatchedInEnum_ .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1195,7 +1206,7 @@ public void testGlobalExecutorOverride_whenIsNullAndInstanceTypeIsNotMatchedInEn .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1243,7 +1254,7 @@ null, accountId, ConnectionMethodEnum.SSH, getSSHConnector(), false, .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); SpotinstSlave agent = (SpotinstSlave) Jenkins.get().getNode(newSpot.getInstanceId()); assertNotNull(agent); @@ -1290,7 +1301,7 @@ public void testSpotinstSlaveTermination_ifAgentInPendingInstances_thenAgentIsRe .scaleUp(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) .thenReturn(new ApiResponse<>(scaleUpResult)); - cloud.provision(null, 1); + cloud.provision((Label)null, 1); Boolean detachResult = true; Mockito.when(