Search in sources :

Example 1 with AzureVMCloudRetensionStrategy

use of com.microsoft.azure.vmagent.AzureVMCloudRetensionStrategy in project azure-vm-agents-plugin by jenkinsci.

the class AdvancedConfigAsCodeTest method importAdvancedConfiguration.

@Test
public void importAdvancedConfiguration() {
    AzureVMCloud cloud = (AzureVMCloud) r.jenkins.clouds.get(0);
    // cloud
    assertThat(cloud.getCloudName(), is("azure"));
    assertThat(cloud.getCloudTags().get(0), is(new AzureTagPair("author", "gavin")));
    assertThat(cloud.getAzureCredentialsId(), is("azure-cred"));
    assertThat(cloud.getDeploymentTimeout(), is(1200));
    assertThat(cloud.getMaxVirtualMachinesLimit(), is(10));
    assertThat(cloud.getNewResourceGroupName(), nullValue());
    assertThat(cloud.getExistingResourceGroupName(), is("vm-agents"));
    assertThat(cloud.getResourceGroupReferenceType(), is("existing"));
    // vmTemplate
    AzureVMAgentTemplate template = cloud.getVmTemplates().get(0);
    assertThat(template.getAgentLaunchMethod(), is("SSH"));
    assertThat(template.getBuiltInImage(), is("Windows Server 2016"));
    assertThat(template.getCredentialsId(), is("admin-cred"));
    assertThat(template.getDiskType(), is("managed"));
    assertThat(template.getDoNotUseMachineIfInitFails(), is(true));
    assertThat(template.isEnableMSI(), is(false));
    assertThat(template.isEnableUAMI(), is(false));
    assertThat(template.getExecuteInitScriptAsRoot(), is(true));
    AzureVMAgentTemplate.ImageReferenceTypeClass imageReference = template.getImageReference();
    assertThat(imageReference.getVersion(), nullValue());
    assertThat(imageReference.getGalleryImageVersion(), is("latest"));
    assertThat(imageReference.getGalleryImageDefinition(), is("Linux"));
    assertThat(imageReference.getGalleryName(), is("gallery"));
    assertThat(imageReference.getGalleryResourceGroup(), is("gallery"));
    assertThat(imageReference.getGallerySubscriptionId(), is("e5587777-5750-4d2e-9e45-d6fbae67b8ea"));
    assertThat(template.getImageTopLevelType(), is("advanced"));
    assertThat(template.isInstallDocker(), is(false));
    assertThat(template.isInstallGit(), is(false));
    assertThat(template.isInstallMaven(), is(false));
    assertThat(template.getLabels(), is("linux"));
    assertThat(template.getLocation(), is("UK South"));
    assertThat(template.getNewStorageAccountName(), is("agent-storage"));
    assertThat(template.getNoOfParallelJobs(), is(1));
    assertThat(template.getOsDiskSize(), is(40));
    assertThat(template.getOsType(), is("Linux"));
    assertThat(template.isPreInstallSsh(), is(false));
    AzureVMCloudRetensionStrategy retentionStrategy = (AzureVMCloudRetensionStrategy) template.getRetentionStrategy();
    assertThat(retentionStrategy.getIdleTerminationMinutes(), is(40L));
    assertThat(template.isShutdownOnIdle(), is(false));
    assertThat(template.getStorageAccountNameReferenceType(), is("new"));
    assertThat(template.getStorageAccountType(), is("Standard_LRS"));
    assertThat(template.isTemplateDisabled(), is(false));
    assertThat(template.getTemplateName(), is("azure"));
    assertThat(template.getUsageMode(), is(Node.Mode.NORMAL));
    assertThat(template.getUsePrivateIP(), is(true));
    assertThat(template.getVirtualMachineSize(), is("Standard_A2"));
}
Also used : AzureVMCloud(com.microsoft.azure.vmagent.AzureVMCloud) AzureVMAgentTemplate(com.microsoft.azure.vmagent.AzureVMAgentTemplate) AzureVMCloudRetensionStrategy(com.microsoft.azure.vmagent.AzureVMCloudRetensionStrategy) AzureTagPair(com.microsoft.azure.vmagent.AzureTagPair) Test(org.junit.Test)

Example 2 with AzureVMCloudRetensionStrategy

use of com.microsoft.azure.vmagent.AzureVMCloudRetensionStrategy in project azure-vm-agents-plugin by jenkinsci.

the class BasicConfigAsCodeTest method importBasicConfiguration.

@Test
public void importBasicConfiguration() {
    AzureVMCloud cloud = (AzureVMCloud) r.jenkins.clouds.get(0);
    // cloud
    assertThat(cloud.getCloudName(), is("azure"));
    assertThat(cloud.getAzureCredentialsId(), is("azure-cred"));
    assertThat(cloud.getDeploymentTimeout(), is(1200));
    assertThat(cloud.getMaxVirtualMachinesLimit(), is(10));
    assertThat(cloud.getNewResourceGroupName(), is("vm-agent"));
    assertThat(cloud.getResourceGroupReferenceType(), is("new"));
    // vmTemplate
    AzureVMAgentTemplate template = cloud.getVmTemplates().get(0);
    assertThat(template.getAgentLaunchMethod(), is("SSH"));
    assertThat(template.getBuiltInImage(), is("Ubuntu 16.14 LTS"));
    assertThat(template.getCredentialsId(), is("admin-cred"));
    assertThat(template.getDiskType(), is("managed"));
    assertThat(template.getDoNotUseMachineIfInitFails(), is(true));
    assertThat(template.isEnableMSI(), is(false));
    assertThat(template.isEnableUAMI(), is(false));
    assertThat(template.isEphemeralOSDisk(), is(false));
    assertThat(template.getExecuteInitScriptAsRoot(), is(true));
    assertThat(template.getTags(), contains(new AzureTagPair("env", "test")));
    AzureVMAgentTemplate.ImageReferenceTypeClass imageReference = template.getImageReference();
    assertThat(imageReference.getVersion(), is("latest"));
    assertThat(template.getImageTopLevelType(), is("basic"));
    assertThat(template.isInstallDocker(), is(true));
    assertThat(template.isInstallGit(), is(true));
    assertThat(template.isInstallMaven(), is(true));
    assertThat(template.getLabels(), is("ubuntu"));
    assertThat(template.getLocation(), is("East US"));
    assertThat(template.getNewStorageAccountName(), is("agent-storage"));
    assertThat(template.getNoOfParallelJobs(), is(1));
    assertThat(template.getOsDiskSize(), is(0));
    assertThat(template.getOsType(), is("Linux"));
    assertThat(template.isPreInstallSsh(), is(true));
    AzureVMCloudRetensionStrategy retentionStrategy = (AzureVMCloudRetensionStrategy) template.getRetentionStrategy();
    assertThat(retentionStrategy.getIdleTerminationMinutes(), is(60L));
    assertThat(template.isShutdownOnIdle(), is(false));
    assertThat(template.getStorageAccountNameReferenceType(), is("new"));
    assertThat(template.getStorageAccountType(), is("Standard_LRS"));
    assertThat(template.isTemplateDisabled(), is(false));
    assertThat(template.getTemplateName(), is("ubuntu"));
    assertThat(template.getUsageMode(), is(Node.Mode.NORMAL));
    assertThat(template.getUsePrivateIP(), is(false));
    assertThat(template.getVirtualMachineSize(), is("Standard_DS2_v2"));
}
Also used : AzureVMCloud(com.microsoft.azure.vmagent.AzureVMCloud) AzureVMAgentTemplate(com.microsoft.azure.vmagent.AzureVMAgentTemplate) AzureVMCloudRetensionStrategy(com.microsoft.azure.vmagent.AzureVMCloudRetensionStrategy) AzureTagPair(com.microsoft.azure.vmagent.AzureTagPair) Test(org.junit.Test)

Aggregations

AzureTagPair (com.microsoft.azure.vmagent.AzureTagPair)2 AzureVMAgentTemplate (com.microsoft.azure.vmagent.AzureVMAgentTemplate)2 AzureVMCloud (com.microsoft.azure.vmagent.AzureVMCloud)2 AzureVMCloudRetensionStrategy (com.microsoft.azure.vmagent.AzureVMCloudRetensionStrategy)2 Test (org.junit.Test)2