Skip to content

Commit

Permalink
DNS Config is not saved properly (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
sparsick authored Apr 19, 2022
1 parent 347e8e3 commit a780fad
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ public void setLaunchMethodTypeContent(LaunchMethodTypeContent launchMethodTypeC
this.sshPort = StringUtils.defaultString(launchMethodTypeContent.getSshPort(), "22");
}
}

public LaunchMethodTypeContent getLaunchMethodTypeContent() {
return new LaunchMethodTypeContent(sshCredentialsId, sshPort);
}

public AciPrivateIpAddress getPrivateIpAddress() {
return privateIpAddress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">

<f:entry>
<f:repeatable field="dnsServerNames" minimum="0">
<f:entry title="DNS server name" field="dnsServer">
<f:repeatable field="dnsServers" minimum="0">
<f:entry title="DNS server name" field="address">
<f:textbox/>
</f:entry>
</f:repeatable>
Expand Down
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;
}
}

0 comments on commit a780fad

Please sign in to comment.