From 9617537ea947fbb684d824b400e68fb728e4828c Mon Sep 17 00:00:00 2001 From: Gavin Burris <66969321+GavinBurris42@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:09:32 -0600 Subject: [PATCH] Add backwards compatibility for executor scaling feature (#424) * Reverted small name changes in comments and documentation * Reverted remaming of EC2Fleet to Fleet * Reverted EC2Fleet to Fleet name changes. Changed EC2Fleet to EC2EC2Fleet * Reverted additional EC2Fleet to Fleet changes * Reverted EC2Fleet name change in EC2FleetLabelCloudConfigurationAsCodeTest * Fixed setting of ExcessCapacityTerminationPolicy in modify fleet request * Added backwards compatability for Executor Scaling feature for EC2FleetCloud * Revised tests with backwards compatability changes * Updated CasC documentation * Updated CloudNanny cloud reaplcement for better testability. Added new test for cloud replacement when no Scaler is present --- docs/CONFIGURATION-AS-CODE.md | 27 +++- .../amazon/jenkins/ec2fleet/CloudNanny.java | 28 +++- .../jenkins/ec2fleet/EC2FleetCloud.java | 7 + .../ec2fleet/AutoResubmitIntegrationTest.java | 6 +- .../jenkins/ec2fleet/CloudNamesTest.java | 22 +-- .../jenkins/ec2fleet/CloudNannyTest.java | 48 ++++-- .../jenkins/ec2fleet/EC2FleetCloudTest.java | 138 +++++++++--------- .../ec2fleet/EC2FleetCloudWithHistory.java | 2 +- .../ec2fleet/EC2FleetCloudWithMeter.java | 2 +- .../EC2RetentionStrategyIntegrationTest.java | 16 +- .../ec2fleet/ProvisionIntegrationTest.java | 16 +- .../com/amazon/jenkins/ec2fleet/RealTest.java | 4 +- .../jenkins/ec2fleet/UiIntegrationTest.java | 36 ++--- 13 files changed, 216 insertions(+), 136 deletions(-) diff --git a/docs/CONFIGURATION-AS-CODE.md b/docs/CONFIGURATION-AS-CODE.md index 6bd410b9..491f7300 100644 --- a/docs/CONFIGURATION-AS-CODE.md +++ b/docs/CONFIGURATION-AS-CODE.md @@ -85,13 +85,32 @@ jenkins: numExecutors: 12 addNodeOnlyIfRunning: true restrictUsage: true - executorScaler: - nodeHardwareScaler: - memoryGiBPerExecutor: 2 - vCpuPerExecutor: 3 + executorScaler: "noScaler" initOnlineTimeoutSec: 181 initOnlineCheckIntervalSec: 13 cloudStatusIntervalSec: 11 disableTaskResubmit: true noDelayProvision: true ``` + +### EC2FleetCloud (Node Hardware Scaling) + +```yaml +jenkins: + clouds: + - eC2Fleet: + name: ec2-fleet + computerConnector: + sshConnector: + credentialsId: cred + sshHostKeyVerificationStrategy: + NonVerifyingKeyVerificationStrategy + region: us-east-2 + fleet: my-fleet + minSize: 1 + maxSize: 10 + executorScaler: + nodeHardwareScaler: + memoryGiBPerExecutor: 2 + vCpuPerExecutor: 3 +``` diff --git a/src/main/java/com/amazon/jenkins/ec2fleet/CloudNanny.java b/src/main/java/com/amazon/jenkins/ec2fleet/CloudNanny.java index 4af14599..a402b904 100644 --- a/src/main/java/com/amazon/jenkins/ec2fleet/CloudNanny.java +++ b/src/main/java/com/amazon/jenkins/ec2fleet/CloudNanny.java @@ -5,6 +5,7 @@ import hudson.slaves.Cloud; import jenkins.model.Jenkins; +import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; @@ -51,6 +52,7 @@ protected void doRun() { recurrenceCounter.set(fleetCloud.getCloudStatusIntervalSec()); try { + updateCloudWithScaler(getClouds(), fleetCloud); // Update the cluster states fleetCloud.update(); } catch (Exception e) { @@ -66,10 +68,34 @@ protected void doRun() { * * @return basic java list */ - private static List getClouds() { + private static Jenkins.CloudList getClouds() { return Jenkins.get().clouds; } + private void updateCloudWithScaler(Jenkins.CloudList clouds, EC2FleetCloud oldCloud) throws IOException { + if(oldCloud.getExecutorScaler() != null) return; + + EC2FleetCloud.ExecutorScaler scaler = oldCloud.isScaleExecutorsByWeight() ? new EC2FleetCloud.WeightedScaler() : + new EC2FleetCloud.NoScaler(); + scaler.withNumExecutors(oldCloud.getNumExecutors()); + EC2FleetCloud fleetCloudWithScaler = createCloudWithScaler(oldCloud, scaler); + clouds.replace(oldCloud, fleetCloudWithScaler); + Jenkins.get().save(); + } + + private EC2FleetCloud createCloudWithScaler(EC2FleetCloud oldCloud, EC2FleetCloud.ExecutorScaler scaler) { + return new EC2FleetCloud(oldCloud.getDisplayName(), oldCloud.getAwsCredentialsId(), + oldCloud.getAwsCredentialsId(), oldCloud.getRegion(), oldCloud.getEndpoint(), oldCloud.getFleet(), + oldCloud.getLabelString(), oldCloud.getFsRoot(), oldCloud.getComputerConnector(), + oldCloud.isPrivateIpUsed(), oldCloud.isAlwaysReconnect(), oldCloud.getIdleMinutes(), + oldCloud.getMinSize(), oldCloud.getMaxSize(), oldCloud.getMinSpareSize(), oldCloud.getNumExecutors(), + oldCloud.isAddNodeOnlyIfRunning(), oldCloud.isRestrictUsage(), + String.valueOf(oldCloud.getMaxTotalUses()), oldCloud.isDisableTaskResubmit(), + oldCloud.getInitOnlineTimeoutSec(), oldCloud.getInitOnlineCheckIntervalSec(), + oldCloud.getCloudStatusIntervalSec(), oldCloud.isNoDelayProvision(), + oldCloud.isScaleExecutorsByWeight(), scaler); + } + private AtomicInteger getRecurrenceCounter(EC2FleetCloud fleetCloud) { AtomicInteger counter = new AtomicInteger(fleetCloud.getCloudStatusIntervalSec()); // If a counter already exists, return the value, otherwise set the new counter value and return it. diff --git a/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java b/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java index a2585524..d2ab8d9c 100644 --- a/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java +++ b/src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java @@ -119,6 +119,7 @@ public class EC2FleetCloud extends AbstractEC2FleetCloud { private final int numExecutors; private final boolean addNodeOnlyIfRunning; private final boolean restrictUsage; + private final boolean scaleExecutorsByWeight; private final ExecutorScaler executorScaler; private final Integer initOnlineTimeoutSec; private final Integer initOnlineCheckIntervalSec; @@ -183,6 +184,7 @@ public EC2FleetCloud(@Nonnull final String name, final Integer initOnlineCheckIntervalSec, final Integer cloudStatusIntervalSec, final boolean noDelayProvision, + final boolean scaleExecutorsByWeight, final ExecutorScaler executorScaler) { super(StringUtils.isNotBlank(name) ? name : CloudNames.generateUnique(BASE_DEFAULT_FLEET_CLOUD_ID)); init(); @@ -212,6 +214,7 @@ public EC2FleetCloud(@Nonnull final String name, this.initOnlineCheckIntervalSec = initOnlineCheckIntervalSec; this.cloudStatusIntervalSec = cloudStatusIntervalSec; this.noDelayProvision = noDelayProvision; + this.scaleExecutorsByWeight = scaleExecutorsByWeight; this.executorScaler = executorScaler == null ? new NoScaler().withNumExecutors(this.numExecutors) : executorScaler.withNumExecutors(this.numExecutors); if (fleet != null) { @@ -317,6 +320,10 @@ public int getNumExecutors() { return numExecutors; } + public boolean isScaleExecutorsByWeight() { + return scaleExecutorsByWeight; + } + public ExecutorScaler getExecutorScaler() { return this.executorScaler; } diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/AutoResubmitIntegrationTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/AutoResubmitIntegrationTest.java index a76e64b7..59261351 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/AutoResubmitIntegrationTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/AutoResubmitIntegrationTest.java @@ -81,7 +81,7 @@ public void should_successfully_resubmit_freestyle_task() throws Exception { null, "fId", "momo", null, new LocalComputerConnector(j), false, false, 0, 0, 10, 0, 1, false, true, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); List rs = enqueTask(1); @@ -117,7 +117,7 @@ public void should_successfully_resubmit_parametrized_task() throws Exception { null, "fId", "momo", null, new LocalComputerConnector(j), false, false, 0, 0, 10, 0, 1, false, true, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); List rs = new ArrayList<>(); @@ -172,7 +172,7 @@ public void should_not_resubmit_if_disabled() throws Exception { EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, 0, 0, 10, 0, 1, false, true, - "-1", true, 0, 0, 10, false, noScaling); + "-1", true, 0, 0, 10, false, false, noScaling); j.jenkins.clouds.add(cloud); List rs = enqueTask(1); diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/CloudNamesTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/CloudNamesTest.java index 434f8a28..40532d1f 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/CloudNamesTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/CloudNamesTest.java @@ -17,7 +17,7 @@ public void isUnique_true() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); Assert.assertTrue(CloudNames.isUnique("TestCloud")); } @@ -28,7 +28,7 @@ public void isUnique_false() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); Assert.assertFalse(CloudNames.isUnique("SomeDefaultName")); } @@ -39,13 +39,13 @@ public void isDuplicated_false() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); j.jenkins.clouds.add(new EC2FleetCloud("TestCloud2", null, null, null, null, null, "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); Assert.assertFalse(CloudNames.isDuplicated("TestCloud")); } @@ -56,13 +56,13 @@ public void isDuplicated_true() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); j.jenkins.clouds.add(new EC2FleetCloud("TestCloud", null, null, null, null, null, "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); Assert.assertTrue(CloudNames.isDuplicated("TestCloud")); } @@ -78,7 +78,7 @@ public void generateUnique_addsSuffixOnlyWhenNeeded() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); Assert.assertEquals("UniqueCloud", CloudNames.generateUnique("UniqueCloud")); } @@ -89,13 +89,13 @@ public void generateUnique_addsSuffixCorrectly() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); j.jenkins.clouds.add(new EC2FleetCloud("UniqueCloud-1", null, null, null, null, null, "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); String actual = CloudNames.generateUnique("UniqueCloud"); Assert.assertTrue(actual.length() == ("UniqueCloud".length() + CloudNames.SUFFIX_LENGTH + 1)); @@ -108,7 +108,7 @@ public void generateUnique_emptyStringInConstructor() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); EC2FleetLabelCloud fleetLabelCloud = new EC2FleetLabelCloud("", null, null, null, null, new LocalComputerConnector(j), false, false, @@ -128,7 +128,7 @@ public void generateUnique_nonEmptyStringInConstructor() { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); EC2FleetLabelCloud fleetLabelCloud = new EC2FleetLabelCloud("UniqueLabelCloud", null, null, null, null, new LocalComputerConnector(j), false, false, diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/CloudNannyTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/CloudNannyTest.java index fb4075cf..bfc922a8 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/CloudNannyTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/CloudNannyTest.java @@ -1,6 +1,9 @@ package com.amazon.jenkins.ec2fleet; +import com.amazon.jenkins.ec2fleet.fleet.EC2Fleet; +import com.amazon.jenkins.ec2fleet.fleet.EC2Fleets; import hudson.slaves.Cloud; +import jenkins.model.Jenkins; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,24 +13,22 @@ import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicInteger; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @RunWith(PowerMockRunner.class) -@PrepareForTest(CloudNanny.class) +@PrepareForTest({CloudNanny.class, Jenkins.class, EC2Fleets.class}) public class CloudNannyTest { + @Mock + private Jenkins jenkins; + + @Mock + private EC2Fleet ec2Fleet; @Mock private EC2FleetCloud cloud1; @@ -35,7 +36,7 @@ public class CloudNannyTest { @Mock private EC2FleetCloud cloud2; - private List clouds = new ArrayList<>(); + private Jenkins.CloudList clouds = new Jenkins.CloudList(); private FleetStateStats stats1 = new FleetStateStats( "f1", 1, new FleetStateStats.State(true, false, "a"), Collections.emptySet(), Collections.emptyMap()); @@ -55,6 +56,15 @@ public void before() throws Exception { PowerMockito.mockStatic(CloudNanny.class); PowerMockito.when(CloudNanny.class, "getClouds").thenReturn(clouds); + PowerMockito.mockStatic(Jenkins.class); + PowerMockito.when(Jenkins.get()).thenReturn(jenkins); + + PowerMockito.mockStatic(EC2Fleets.class); + when(EC2Fleets.get(anyString())).thenReturn(ec2Fleet); + PowerMockito.when(ec2Fleet.getState(anyString(), anyString(), anyString(), anyString())) + .thenReturn(new FleetStateStats("", 0, FleetStateStats.State.active(), + Collections.emptySet(), Collections.emptyMap())); + when(cloud1.getLabelString()).thenReturn("a"); when(cloud2.getLabelString()).thenReturn(""); when(cloud1.getFleet()).thenReturn("f1"); @@ -187,4 +197,22 @@ public void updateOnlyOneCloud() { assertEquals(1, recurrenceCounter1.get()); assertEquals(cloud2.getCloudStatusIntervalSec(), recurrenceCounter2.get()); } + + @Test + public void doRun_updatesCloudsWithScaler_whenScalerIsNull() { + when(cloud1.isScaleExecutorsByWeight()).thenReturn(true); + when(cloud2.isScaleExecutorsByWeight()).thenReturn(false); + + clouds.add(cloud1); + clouds.add(cloud2); + CloudNanny cloudNanny = getMockCloudNannyInstance(); + + cloudNanny.doRun(); + + cloud1 = (EC2FleetCloud) clouds.get(0); + cloud2 = (EC2FleetCloud) clouds.get(1); + + assertEquals(EC2FleetCloud.WeightedScaler.class, cloud1.getExecutorScaler().getClass()); + assertEquals(EC2FleetCloud.NoScaler.class, cloud2.getExecutorScaler().getClass()); + } } diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudTest.java index fe045214..a6ddf683 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudTest.java @@ -167,7 +167,7 @@ public void canProvision_fleetIsNull(){ "", null, "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); Label label = new LabelAtom("momo"); boolean result = fleetCloud.canProvision(new Cloud.CloudState(label, 0)); @@ -180,7 +180,7 @@ public void canProvision_restrictUsageLabelIsNull(){ "", "", "", null, null, false, false, 0, 0, 10, 0, 1, true, true, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); Label label = null; boolean result = fleetCloud.canProvision(new Cloud.CloudState(label, 0)); @@ -193,7 +193,7 @@ public void canProvision_LabelNotInLabelString(){ "", "", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); Label label = new LabelAtom("momo"); boolean result = fleetCloud.canProvision(new Cloud.CloudState(label, 0)); @@ -206,7 +206,7 @@ public void canProvision_LabelInLabelString(){ "", "", "label1 momo", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); // have to mock these for the Label.parse(...) call otherwise we get an NPE when(jenkins.getLabelAtom("momo")).thenReturn(new LabelAtom("momo")); @@ -230,7 +230,7 @@ public void provision_shouldProvisionNoneWhenMaxReached() { "", "", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 10, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -256,7 +256,7 @@ public void provision_shouldProvisionNoneWhenMaxReachedAndNumExecutorsMoreOne() "", "", "", null, null, false, false, 0, 1, 8, 0, 3, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 1, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -282,7 +282,7 @@ public void provision_shouldProvisionNoneWhenMaxReachedAndNumExecutorsMoreOne1() "", "", "", null, null, false, false, 0, 1, 8, 0, 3, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 7, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -308,7 +308,7 @@ public void provision_shouldProvisionNoneWhenExceedMax() { "", "", "", null, null, false, false, 0, 0, 9, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 10, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -334,7 +334,7 @@ public void provision_shouldProvisionIfBelowMax() { "", "", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -360,7 +360,7 @@ public void provision_shouldProvisionNoMoreMax() { "", "", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -386,7 +386,7 @@ public void provision_shouldProvisionNoMoreMaxWhenMultipleCallBeforeUpdate() { "", "", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -416,7 +416,7 @@ public void provision_shouldProvisionNoneIfNotYetUpdated() { "", "", "", null, null, false, false, 0, 0, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); // when Collection r = fleetCloud.provision(new Cloud.CloudState(null, 0), 1); @@ -439,7 +439,7 @@ public void scheduleToTerminate_shouldNotRemoveIfStatsNotUpdated() { "", "", "", null, null, false, false, 0, 0, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); // when boolean r = fleetCloud.scheduleToTerminate("z", false, EC2AgentTerminationReason.IDLE_FOR_TOO_LONG); @@ -461,7 +461,7 @@ public void scheduleToTerminate_notRemoveIfBelowMin() { "", "", "", null, null, false, false, 0, 1, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 0, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -486,7 +486,7 @@ public void scheduleToTerminate_notRemoveIfEqualMin() { "", "", "", null, null, false, false, 0, 1, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 1, FleetStateStats.State.active(), Collections.singleton("z"), Collections.emptyMap())); @@ -512,7 +512,7 @@ public void scheduleToTerminate_notRemoveIfEqualMinSpare() { "", "", "", null, null, false, false, 0, 0, 5, 1, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 1, FleetStateStats.State.active(), Collections.singleton("z"), Collections.emptyMap())); @@ -537,7 +537,7 @@ public void scheduleToTerminate_remove() { "", "", "", null, null, false, false, 0, 1, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 2, FleetStateStats.State.active(), new HashSet<>(Arrays.asList("z", "z1")), Collections.emptyMap())); @@ -563,7 +563,7 @@ public void scheduleToTerminate_upToZeroNodes() { "", "", "", null, null, false, false, 0, 0, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 2, FleetStateStats.State.active(), new HashSet<>(Arrays.asList("z-1", "z-2")), Collections.emptyMap())); @@ -594,7 +594,7 @@ public void scheduleToTerminate_removeNoMoreMinIfCalledMultipleBeforeUpdate() { "", "", "", null, null, false, false, 0, 1, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 3, FleetStateStats.State.active(), new HashSet<>(Arrays.asList("z1", "z2", "z3")), Collections.emptyMap())); @@ -627,7 +627,7 @@ public void update_shouldDoNothingIfNoTerminationOrProvisionAndFleetIsEmpty() { "", "fleetId", "", null, null, false, false, 0, 0, 1, 0, 1, true, false, "-1", false, 0, - 0, 10, false, noScaling); + 0, 10, false, false, noScaling); // when FleetStateStats stats = fleetCloud.update(); @@ -651,7 +651,7 @@ public void update_shouldIncreaseTargetCapacityWhenProvisioned() { "", "fleetId", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, noScaling); + 0, 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 0, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -679,7 +679,7 @@ public void update_shouldResetTerminateAndProvision() { "", "fleetId", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, noScaling); + 0, 10, false, false, noScaling); fleetCloud.setStats(currentState); @@ -708,7 +708,7 @@ public void update_shouldNotIncreaseMoreThenMax() { "", "fleetId", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, noScaling); + 0, 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -739,7 +739,7 @@ public void update_shouldNotCountScheduledToTerminateWhenScaleUp() { "", "fleetId", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, noScaling); + 0, 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -769,7 +769,7 @@ public void update_shouldDecreaseTargetCapacityAndTerminateInstancesIfScheduled( "", "fleetId", "", null, null, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, noScaling); + 0, 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 4, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -810,7 +810,7 @@ public void update_shouldAddNodeIfAnyNewDescribed() throws IOException { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, false, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -852,7 +852,7 @@ public void update_shouldTagNewNodesBeforeAdding() throws IOException { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 2, 0, 1, false, false, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -888,7 +888,7 @@ public void update_shouldTagNewNodesBeforeAddingWithFleetName() throws IOExcepti "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, false, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -929,7 +929,7 @@ public void update_givenFailedTaggingShouldIgnoreExceptionAndAddNode() throws IO "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, false, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -967,7 +967,7 @@ public void update_shouldAddNodeIfAnyNewDescribed_restrictUsage() throws IOExcep "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1012,7 +1012,7 @@ public void update_shouldAddNodeWithNumExecutors_whenWeightProvidedButNotEnabled "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1045,7 +1045,7 @@ public void update_givenManuallyUpdatedFleetShouldCorrectLocalTargetCapacityToKe "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); fleetCloud.setStats(initState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1082,7 +1082,7 @@ public void update_shouldTrimPlannedNodesIfExceedTargetCapacity() throws IOExcep "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); fleetCloud.setStats(initState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1130,7 +1130,7 @@ public void update_shouldTrimPlannedNodesBasedOnUpdatedTargetCapacityIfProvision "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); fleetCloud.setStats(initState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1182,7 +1182,7 @@ public void update_shouldUpdateStateWithFleetTargetCapacityPlusToAdd() throws IO "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0,1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); fleetCloud.setStats(initState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1228,7 +1228,7 @@ public void update_shouldUpdateStateWithFleetTargetCapacityMinusToTerminate() th "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10,0, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); fleetCloud.setStats(initState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1263,7 +1263,7 @@ public void update_shouldTerminateIdleOrNullInstancesOnly() { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 2, 0, 1, false, false, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); when(jenkins.getComputer("i-1")).thenReturn(idleComputer); when(jenkins.getComputer("i-2")).thenReturn(busyComputer); @@ -1307,7 +1307,7 @@ public void update_shouldUpdateStateWithMinSpare() throws IOException { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, minSpareSize, 1, false, true, "-1", false, - 0, 0, 10, false, noScaling); + 0, 0, 10, false, false, noScaling); fleetCloud.setStats(initState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1348,7 +1348,7 @@ public void update_shouldAddNodeWithScaledNumExecutors_whenWeightPresentAndEnabl "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1390,7 +1390,7 @@ public void update_shouldAddNodeWithNumExecutors_whenWeightPresentAndEnabledButF "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1432,7 +1432,7 @@ public void update_shouldAddNodeWithRoundToLowScaledNumExecutors_whenWeightPrese "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1474,7 +1474,7 @@ public void update_shouldAddNodeWithRoundToLowScaledNumExecutors_whenWeightPrese "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(EC2FleetNode.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1517,7 +1517,7 @@ public void update_shouldAddNodeWithScaledToOneNumExecutors_whenWeightPresentBut "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); // set init state so we can do provision fleetCloud.setStats(new FleetStateStats("", 0, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -1562,7 +1562,7 @@ public void update_givenFailedModifyShouldNotUpdateToAddToDelete() throws IOExce "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1610,7 +1610,7 @@ public void update_givenFleetInModifyingShouldNotDoAnyUpdates() throws IOExcepti "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); fleetCloud.setStats(initialState); doNothing().when(jenkins).addNode(any(Node.class)); @@ -1640,7 +1640,7 @@ public void update_scheduledFuturesExecutesAfterTimeout() throws IOException, In "", "", "", null, null, false, false, 0, 0, 10, 0,1, true, false, "-1", false, timeout, 0, - 1, false, noScaling); + 1, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -1671,7 +1671,7 @@ public void update_scheduledFuturesIsCancelledAfterUpdate() throws IOException, "", "", "", null, null, false, false, 0, 0, 10, 0,1, true, false, "-1", false, timeout, 0, - 10, false, noScaling); + 10, false, false, noScaling); fleetCloud.setStats(new FleetStateStats("", 5, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -1698,7 +1698,7 @@ public void update_shouldScaleUpToMinSize() { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 1, 1, 0,1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); // when fleetCloud.update(); @@ -1746,7 +1746,7 @@ public void update_whenScalingByNodeHardwareWithLessVCPUs_shouldScaleExecutorsBy "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1798,7 +1798,7 @@ public void update_whenScalingByNodeHardwareWithLessMemory_shouldScaleExecutorsB "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1850,7 +1850,7 @@ public void update_whenScalingByNodeHardwareWithNoVCPUs_shouldScaleExecutorsByMe "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1902,7 +1902,7 @@ public void update_whenScalingByNodeHardwareWithNoMemory_shouldScaleExecutorsByV "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -1954,7 +1954,7 @@ public void update_whenScalingByNodeHardwareByMemoryWithLowMemory_shouldSetOneEx "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -2006,7 +2006,7 @@ public void update_whenScalingByNodeHardwareByVCPUsWithLowVCPUCount_shouldSetOne "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -2058,7 +2058,7 @@ public void update_whenScalingByNodeHardwareWithNoVCPUsAndNoMemory_shouldSetExec "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 10, 0, 3, true, false, "-1", false, 0, - 0, 10, false, nodeHardwareScaler); + 0, 10, false, false, nodeHardwareScaler); ArgumentCaptor nodeCaptor = ArgumentCaptor.forClass(Node.class); doNothing().when(jenkins).addNode(nodeCaptor.capture()); @@ -2078,7 +2078,7 @@ public void removeScheduledFutures_success() { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArrayList> scheduledFutures = new ArrayList<>(); scheduledFutures.add(mock(ScheduledFuture.class)); @@ -2099,7 +2099,7 @@ public void removeScheduledFutures_scheduledFutureIsEmpty() { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArrayList> scheduledFutures = new ArrayList<>(); fleetCloud.setPlannedNodeScheduledFutures(scheduledFutures); @@ -2118,7 +2118,7 @@ public void removeScheduledFutures_numToRemoveIsZero() { "", "fleetId", "", null, PowerMockito.mock(ComputerConnector.class), false, false, 0, 0, 1, 0, 1, false, true, "-1", false, - 0, 0, 10, false, weightedScaling); + 0, 0, 10, false, false, weightedScaling); ArrayList> scheduledFutures = new ArrayList<>(); scheduledFutures.add(mock(ScheduledFuture.class)); @@ -2329,7 +2329,7 @@ public void getDisplayName_returnDisplayName() { false, null, 0, 1, 0, 1, true, false, "-1", false , 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); assertEquals(ec2FleetCloud.getDisplayName(), "CloudName"); } @@ -2341,7 +2341,7 @@ public void getAwsCredentialsId_returnNull_whenNoCredentialsIdOrAwsCredentialsId false, null, 0, 1, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); Assert.assertNull(ec2FleetCloud.getAwsCredentialsId()); } @@ -2353,7 +2353,7 @@ public void getAwsCredentialsId_returnValue_whenCredentialsIdPresent() { false, null, 0, 1, 0, 1, true, false, "-1", false , 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); assertEquals("Opa", ec2FleetCloud.getAwsCredentialsId()); } @@ -2365,7 +2365,7 @@ public void getAwsCredentialsId_returnValue_whenAwsCredentialsIdPresent() { false, null, 0, 1, 0, 1, true, false, "-1", false , 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); assertEquals("Opa", ec2FleetCloud.getAwsCredentialsId()); } @@ -2377,7 +2377,7 @@ public void getAwsCredentialsId_returnAwsCredentialsId_whenAwsCredentialsIdAndCr false, null, 0, 1, 0, 1, true, false, "-1", false , 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); assertEquals("A", ec2FleetCloud.getAwsCredentialsId()); } @@ -2391,7 +2391,7 @@ public void getCloudStatusInterval_returnCloudStatusInterval() { false, null, 0, 1, 0, 1, true, false, "-1", false , 0, 0, - 45, false, noScaling); + 45, false, false, noScaling); assertEquals(45, ec2FleetCloud.getCloudStatusIntervalSec()); } @@ -2403,7 +2403,7 @@ public void create_numExecutorsLessThenOneShouldUpgradedToOne() { false, null, 0, 1, 0, 0, true, false, "-1", false , 0, 0, - 45, false, noScaling); + 45, false, false, noScaling); assertEquals(1, ec2FleetCloud.getNumExecutors()); } @@ -2416,7 +2416,7 @@ public void hasUnlimitedUsesForNodes_shouldReturnTrueWhenUnlimited() { false, null, 0, 1, 0, 0, true, false, String.valueOf(maxTotalUses), false , 0, 0, - 45, false, noScaling); + 45, false, false, noScaling); assertTrue(ec2FleetCloud.hasUnlimitedUsesForNodes()); } @@ -2429,7 +2429,7 @@ public void hasUnlimitedUsesForNodes_shouldReturnDefaultTrueForNull() { false, null, 0, 1, 0, 0, true, false, maxTotalUses, false , 0, 0, - 45, false, noScaling); + 45, false, false, noScaling); assertTrue(ec2FleetCloud.hasUnlimitedUsesForNodes()); } @@ -2442,7 +2442,7 @@ public void hasUnlimitedUsesForNodes_shouldReturnDefaultTrueForEmptyString() { false, null, 0, 1, 0, 0, true, false, maxTotalUses, false , 0, 0, - 45, false, noScaling); + 45, false, false, noScaling); assertTrue(ec2FleetCloud.hasUnlimitedUsesForNodes()); } @@ -2455,7 +2455,7 @@ public void hasUnlimitedUsesForNodes_shouldReturnFalseWhenLimited() { false, null, 0, 1, 0, 0, true, false, String.valueOf(maxTotalUses), false , 0, 0, - 45, false, noScaling); + 45, false, false, noScaling); assertFalse(ec2FleetCloud.hasUnlimitedUsesForNodes()); } diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithHistory.java b/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithHistory.java index 00bc83e6..a89087b7 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithHistory.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithHistory.java @@ -22,7 +22,7 @@ public EC2FleetCloudWithHistory( super(name, awsCredentialsId, credentialsId, region, endpoint, fleet, labelString, fsRoot, computerConnector, privateIpUsed, alwaysReconnect, idleMinutes, minSize, maxSize, minSpareSize, numExecutors, addNodeOnlyIfRunning, restrictUsage, "-1", disableTaskResubmit, initOnlineTimeoutSec, - initOnlineCheckIntervalSec, cloudStatusIntervalSec, immediatelyProvision, executorScaler); + initOnlineCheckIntervalSec, cloudStatusIntervalSec, immediatelyProvision, false, executorScaler); } @Override diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithMeter.java b/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithMeter.java index 7b0167d3..19a7a99d 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithMeter.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/EC2FleetCloudWithMeter.java @@ -23,7 +23,7 @@ public EC2FleetCloudWithMeter( super(name, awsCredentialsId, credentialsId, region, endpoint, fleet, labelString, fsRoot, computerConnector, privateIpUsed, alwaysReconnect, idleMinutes, minSize, maxSize, minSpareSize, numExecutors, addNodeOnlyIfRunning, restrictUsage, "-1", disableTaskResubmit, initOnlineTimeoutSec, initOnlineCheckIntervalSec, - cloudStatusIntervalSec, immediatelyProvision, executorScaler); + cloudStatusIntervalSec, immediatelyProvision, false, executorScaler); } @Override diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/EC2RetentionStrategyIntegrationTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/EC2RetentionStrategyIntegrationTest.java index 9cf38a6c..67910654 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/EC2RetentionStrategyIntegrationTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/EC2RetentionStrategyIntegrationTest.java @@ -76,7 +76,7 @@ public void before() { public void shouldTerminateNodeMarkedForDeletion() throws Exception { final EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 0, 0, 0, 1, false, true, "-1", false, 0, 0, 999, false, noScaling); + 1, 0, 0, 0, 1, false, true, "-1", false, 0, 0, 999, false, false, noScaling); // Set initial jenkins nodes cloud.update(); j.jenkins.clouds.add(cloud); @@ -100,7 +100,7 @@ public void shouldTerminateNodeMarkedForDeletion() throws Exception { public void shouldTerminateExcessCapacity() throws Exception { final EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 0, 0, 0, 1, false, true, "-1", false, 0, 0, 999, false, noScaling); + 1, 0, 0, 0, 1, false, true, "-1", false, 0, 0, 999, false, false, noScaling); // Set initial jenkins nodes cloud.update(); j.jenkins.clouds.add(cloud); @@ -139,14 +139,14 @@ public void shouldNotTerminateExcessCapacityWhenNodeIsBusy() throws Exception { EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 2, 2, 0, 1, false, true, "-1", false, 0, 0, 999, false, noScaling); + 1, 2, 2, 0, 1, false, true, "-1", false, 0, 0, 999, false, false, noScaling); j.jenkins.clouds.add(cloud); cloud.update(); assertAtLeastOneNode(); cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 0, 0, 0, 1, false, true, "-1", false, 0, 0, 99, false, noScaling); + 1, 0, 0, 0, 1, false, true, "-1", false, 0, 0, 99, false, false, noScaling); j.jenkins.clouds.clear(); j.jenkins.clouds.add(cloud); assertAtLeastOneNode(); @@ -171,7 +171,7 @@ public void shouldNotTerminateExcessCapacityWhenNodeIsBusy() throws Exception { public void shouldTerminateIdleNodesAfterIdleTimeout() throws Exception { final EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 0, 2, 0, 1, false, true, "-1", false, 0, 0, 99, false, noScaling); + 1, 0, 2, 0, 1, false, true, "-1", false, 0, 0, 99, false, false, noScaling); j.jenkins.clouds.add(cloud); cloud.update(); @@ -202,7 +202,7 @@ public void shouldTerminateIdleNodesAfterIdleTimeout() throws Exception { public void shouldNotTerminateBelowMinSize() throws Exception { final EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 2, 5, 0, 1, false, true, "-1", false, 0, 0, 30, false, noScaling); + 1, 2, 5, 0, 1, false, true, "-1", false, 0, 0, 30, false, false, noScaling); j.jenkins.clouds.add(cloud); cloud.update(); @@ -226,7 +226,7 @@ public void shouldNotTerminateBelowMinSize() throws Exception { public void shouldNotTerminateBelowMinSpareSize() throws Exception { final EC2FleetCloud cloud = new EC2FleetCloud("TestCloud", "credId", null, "region", null, "fId", "momo", null, new LocalComputerConnector(j), false, false, - 1, 0, 5, 2, 1, false, true, "-1", false, 0, 0, 30, false, noScaling); + 1, 0, 5, 2, 1, false, true, "-1", false, 0, 0, 30, false, false, noScaling); j.jenkins.clouds.add(cloud); cloud.update(); @@ -256,7 +256,7 @@ public void shouldTerminateWhenMaxTotalUsesIsExhausted() throws Exception { EC2FleetCloud cloud = spy(new EC2FleetCloud("testCloud", "credId", null, "region", null, "fId", label, null, new LocalComputerConnector(j), false, false, 0, 0, 10, 0, 1, false, true, - String.valueOf(maxTotalUses), true, 0, 0, 10, false, noScaling)); + String.valueOf(maxTotalUses), true, 0, 0, 10, false, false, noScaling)); j.jenkins.clouds.add(cloud); cloud.update(); assertAtLeastOneNode(); diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/ProvisionIntegrationTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/ProvisionIntegrationTest.java index 25322507..34d76396 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/ProvisionIntegrationTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/ProvisionIntegrationTest.java @@ -71,7 +71,7 @@ public void dont_provide_any_planned_if_empty_and_reached_max_capacity() throws null, "fId", "momo", null, computerConnector, false, false, 0, 0, 0, 0, 1, true, false, "-1", false, 0, 0, - 2, false, noScaling); + 2, false, false, noScaling); j.jenkins.clouds.add(cloud); final EC2Api ec2Api = spy(EC2Api.class); @@ -105,7 +105,7 @@ public void should_add_planned_if_capacity_required_but_not_described_yet() thro null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 2, false, noScaling); + 2, false, false, noScaling); j.jenkins.clouds.add(cloud); List rs = enqueTask(1); @@ -140,7 +140,7 @@ public void should_keep_planned_node_until_node_will_not_be_online_so_jenkins_wi null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 300, 15, - 2, false, noScaling)); + 2, false, false, noScaling)); j.jenkins.clouds.add(cloud); @@ -174,7 +174,7 @@ public void should_not_keep_planned_node_if_configured_so_jenkins_will_overprovi null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); j.jenkins.clouds.add(cloud); mockEc2FleetApiToEc2SpotFleet(InstanceStateName.Running); @@ -202,7 +202,7 @@ public void should_not_allow_jenkins_to_provision_if_address_not_available() thr null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); cloud.setStats(new FleetStateStats("", 0, FleetStateStats.State.active(), Collections.emptySet(), Collections.emptyMap())); @@ -263,7 +263,7 @@ public void should_not_convert_planned_to_node_if_state_is_not_running_and_check null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 0, 1, true, false, "-1", false, 0, 0, - 2, false, noScaling); + 2, false, false, noScaling); j.jenkins.clouds.add(cloud); mockEc2FleetApiToEc2SpotFleet(InstanceStateName.Pending); @@ -300,7 +300,7 @@ public void should_successfully_create_nodes() throws Exception { null, "fId", "momo", null, computerConnector, false, false, 0, 0, 2, 0, 1, true, false, "-1", false, 0, 0, - 2, false, noScaling); + 2, false, false, noScaling); j.jenkins.clouds.add(cloud); mockEc2FleetApiToEc2SpotFleet(InstanceStateName.Running); @@ -331,7 +331,7 @@ public void should_continue_update_after_termination() throws IOException { null, "fId", "momo", null, computerConnector, false, false, 1, 0, 5, 0, 1, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); waitFirstStats(cloud); diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/RealTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/RealTest.java index f4baeeb8..52dd0a5a 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/RealTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/RealTest.java @@ -137,7 +137,7 @@ public void run() { "momo", null, computerConnector, false, false, 1, 0, 5, 0, 1, true, false, "-1", false, 180, 15, - 10, true, noScaling); + 10, true, false, noScaling); j.jenkins.clouds.add(cloud); final List tasks = enqueTask(2); @@ -189,7 +189,7 @@ public void givenEc2SpotFleet_shouldScaleUpExecuteTaskAndScaleDown() throws Exce "momo", null, computerConnector, false, false, 1, 0, 5, 0, 1, true, false, "-1", false, 180, 15, - 10, true, noScaling); + 10, true, false, noScaling); j.jenkins.clouds.add(cloud); final List tasks = enqueTask(2); diff --git a/src/test/java/com/amazon/jenkins/ec2fleet/UiIntegrationTest.java b/src/test/java/com/amazon/jenkins/ec2fleet/UiIntegrationTest.java index e1bdb53f..6658c6f5 100644 --- a/src/test/java/com/amazon/jenkins/ec2fleet/UiIntegrationTest.java +++ b/src/test/java/com/amazon/jenkins/ec2fleet/UiIntegrationTest.java @@ -82,7 +82,7 @@ public void shouldShowNodeConfigurationPage() throws Exception { "test-label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); j.jenkins.addNode(new EC2FleetNode(nodeName, "", "", 1, @@ -100,7 +100,7 @@ public void shouldReplaceCloudForNodesAfterConfigurationSave() throws Exception "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); j.jenkins.addNode(new EC2FleetNode("mock", "", "", 1, @@ -126,7 +126,7 @@ public void shouldShowInConfigurationClouds() throws IOException, SAXException { null, null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -140,14 +140,14 @@ public void shouldShowMultipleClouds() throws IOException, SAXException { null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); Cloud cloud2 = new EC2FleetCloud("b", null, null, null, null, null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud2); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -164,14 +164,14 @@ public void shouldShowMultipleCloudsWithDefaultName() throws IOException, SAXExc null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); Cloud cloud2 = new EC2FleetCloud("TestCloud2", null, null, null, null, null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud2); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -188,14 +188,14 @@ public void shouldUpdateProperCloudWhenMultiple() throws Exception { null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); EC2FleetCloud cloud2 = new EC2FleetCloud("TestCloud2", null, null, null, null, null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud2); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -214,7 +214,7 @@ public void shouldContainRegionValueInRegionLabel() throws IOException, SAXExcep null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -236,7 +236,7 @@ public void shouldHaveRegionCodeAndRegionDescriptionInRegionLabel() throws IOExc null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -264,14 +264,14 @@ public void shouldGetFirstWhenMultipleCloudWithSameName() { null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); EC2FleetCloud cloud2 = new EC2FleetCloud("TestCloud", null, null, null, null, null, "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud2); assertSame(cloud1, j.jenkins.getCloud("TestCloud")); @@ -283,14 +283,14 @@ public void shouldGetProperWhenMultipleWithDiffName() { null, null, null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud1); EC2FleetCloud cloud2 = new EC2FleetCloud("b", null, null, null, null, null, null, null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud2); assertSame(cloud1, j.jenkins.getCloud("a")); @@ -303,7 +303,7 @@ public void verifyCloudNameReadOnlyAfterCloudCreated() throws Exception { "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling); + 10, false, false, noScaling); j.jenkins.clouds.add(cloud); HtmlPage page = j.createWebClient().goTo("configureClouds"); @@ -318,13 +318,13 @@ public void verifyExistingDuplicateCloudNamesEditable() throws Exception { "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); j.jenkins.clouds.add(new EC2FleetCloud("test-cloud", null, null, null, null, "", "label", null, null, false, false, 0, 0, 0, 0, 0, true, false, "-1", false, 0, 0, - 10, false, noScaling)); + 10, false, false, noScaling)); HtmlPage page = j.createWebClient().goTo("configureClouds");