-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DNS Config is not saved properly (#130)
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/test/java/com/microsoft/jenkins/containeragents/AciCloudConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.microsoft.jenkins.containeragents; | ||
|
||
import com.gargoylesoftware.htmlunit.html.HtmlForm; | ||
import com.gargoylesoftware.htmlunit.html.HtmlPage; | ||
import com.microsoft.jenkins.containeragents.aci.AciCloud; | ||
import com.microsoft.jenkins.containeragents.aci.AciContainerTemplate; | ||
import com.microsoft.jenkins.containeragents.aci.AciPrivateIpAddress; | ||
import com.microsoft.jenkins.containeragents.aci.dns.AciDnsConfig; | ||
import com.microsoft.jenkins.containeragents.aci.dns.AciDnsServer; | ||
import com.microsoft.jenkins.containeragents.strategy.ContainerOnceRetentionStrategy; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.util.Arrays; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
public class AciCloudConfigTest { | ||
|
||
@Rule | ||
public JenkinsRule jenkins = new JenkinsRule(); | ||
|
||
@Test | ||
public void configRoundTrip() throws Exception { | ||
String cloudName = "aciTest"; | ||
AciCloud expectedAciCloud = createConfiguredAciCloud(cloudName); | ||
|
||
jenkins.jenkins.clouds.add(expectedAciCloud); | ||
jenkins.jenkins.save(); | ||
JenkinsRule.WebClient testClient = jenkins.createWebClient(); | ||
HtmlPage cloudPage = testClient.goTo("configureClouds/"); | ||
HtmlForm configForm = cloudPage.getFormByName("config"); | ||
jenkins.submit(configForm); | ||
|
||
AciCloud actualAciCloud = (AciCloud) jenkins.jenkins.getCloud(cloudName); | ||
jenkins.assertEqualDataBoundBeans(expectedAciCloud, actualAciCloud); | ||
|
||
|
||
} | ||
|
||
@NotNull | ||
private AciCloud createConfiguredAciCloud(String cloudName) { | ||
AciContainerTemplate containerTemplate = new AciContainerTemplate("containerName", "label", | ||
100, "Linux", "helloworld", "command", "rootFs", emptyList(), | ||
emptyList(), emptyList(), emptyList(), new ContainerOnceRetentionStrategy(), "cpu", "memory" ); | ||
AciPrivateIpAddress privateIpAddress = new AciPrivateIpAddress("vnet", "subnet"); | ||
privateIpAddress.setResourceGroup("vnetResourceGroup"); | ||
AciDnsConfig dnsConfig = new AciDnsConfig(); | ||
dnsConfig.setDnsServers(Arrays.asList(new AciDnsServer("dnsServerAddress"))); | ||
privateIpAddress.setDnsConfig(dnsConfig); | ||
containerTemplate.setPrivateIpAddress(privateIpAddress); | ||
AciCloud acicloud = new AciCloud(cloudName, "", "", Arrays.asList(containerTemplate)); | ||
acicloud.setLogAnalyticsCredentialsId(""); | ||
return acicloud; | ||
} | ||
} |