use of com.microsoft.azure.vmagent.AzureVMCloud in project azure-vm-agents-plugin by jenkinsci.
the class ITAzureVMManagementServiceDelegate method attachPublicIPIsNoOpWhenAlreadyExists.
@Test
public void attachPublicIPIsNoOpWhenAlreadyExists() {
try {
final AzureVMDeploymentInfo deploymentInfo = createDefaultDeployment(1, true, null);
final String nodeName = deploymentInfo.getVmBaseName() + "0";
AzureVMAgent agentMock = mock(AzureVMAgent.class);
AzureVMAgentTemplate templateMock = mock(AzureVMAgentTemplate.class);
AzureVMCloud cloudMock = mock(AzureVMCloud.class);
when(templateMock.retrieveAzureCloudReference()).thenReturn(cloudMock);
when(templateMock.getResourceGroupName()).thenReturn(testEnv.azureResourceGroup);
when(templateMock.getLocation()).thenReturn(testEnv.azureLocation);
when(agentMock.getNodeName()).thenReturn(nodeName);
final String initialPublicIPId = azureClient.virtualMachines().getByResourceGroup(testEnv.azureResourceGroup, nodeName).getPrimaryPublicIPAddress().id();
delegate.attachPublicIP(agentMock, templateMock);
final PublicIpAddress publicIP = azureClient.virtualMachines().getByResourceGroup(testEnv.azureResourceGroup, nodeName).getPrimaryPublicIPAddress();
Assert.assertNotNull(publicIP);
Assert.assertEquals(initialPublicIPId, publicIP.id());
verify(agentMock, never()).setPublicDNSName(any(String.class));
verify(agentMock, never()).setSshPort(any(int.class));
verify(agentMock, never()).setPublicIP(any(String.class));
verify(agentMock, never()).setPrivateIP(any(String.class));
} catch (Exception e) {
LOGGER.log(Level.SEVERE, null, e);
Assert.fail(e.getMessage());
}
}
use of com.microsoft.azure.vmagent.AzureVMCloud 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"));
}
use of com.microsoft.azure.vmagent.AzureVMCloud 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"));
}
Aggregations