Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmt, improve live test #22555

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.profile.AzureProfile;
import com.azure.core.test.annotation.DoNotRecord;
import com.azure.core.util.polling.LongRunningOperationStatus;
import com.azure.core.util.polling.PollResponse;
import com.azure.resourcemanager.compute.models.AvailabilitySet;
Expand Down Expand Up @@ -833,6 +834,7 @@ public void canRunScriptOnVM() {
}

@Test
@DoNotRecord(skipInPlayback = true)
public void canPerformSimulateEvictionOnSpotVirtualMachine() {
VirtualMachine virtualMachine = computeManager.virtualMachines()
.define(vmName)
Expand All @@ -843,7 +845,7 @@ public void canPerformSimulateEvictionOnSpotVirtualMachine() {
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
.withRootUsername("firstuser")
.withRootPassword(password())
.withSsh(sshPublicKey())
.withSpotPriority(VirtualMachineEvictionPolicyTypes.DEALLOCATE)
.withSize(VirtualMachineSizeTypes.fromString("Standard_D2a_v4"))
.create();
Expand All @@ -856,12 +858,23 @@ public void canPerformSimulateEvictionOnSpotVirtualMachine() {

// call simulate eviction
virtualMachine.simulateEviction();
ResourceManagerUtils.sleep(Duration.ofMinutes(30));
boolean deallocated = false;
int pollIntervalInMinutes = 5;
for (int i = 0; i < 30; i += pollIntervalInMinutes) {
ResourceManagerUtils.sleep(Duration.ofMinutes(pollIntervalInMinutes));

virtualMachine = computeManager.virtualMachines().getById(virtualMachine.id());
if (virtualMachine.powerState() == PowerState.DEALLOCATED) {
deallocated = true;
break;
}
}
Assertions.assertTrue(deallocated);

virtualMachine = computeManager.virtualMachines().getById(virtualMachine.id());
Assertions.assertNotNull(virtualMachine);
Assertions.assertNull(virtualMachine.osDiskStorageAccountType());
Assertions.assertTrue(virtualMachine.osDiskSize() == 0);
Assertions.assertEquals(0, virtualMachine.osDiskSize());
disk = computeManager.disks().getById(virtualMachine.osDiskId());
Assertions.assertEquals(DiskState.RESERVED, disk.innerModel().diskState());
}
Expand Down