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

Refactoring configuration test #132

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<java.level>8</java.level>
<maven.javadoc.skip>true</maven.javadoc.skip>
<docker-commons.version>1.19</docker-commons.version>
<jenkins-test-harness.version>1742.v54b_55b_42b_6cb_</jenkins-test-harness.version> <!-- TODO https://github.com/jenkinsci/jenkins-test-harness/pull/426 -->
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
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;
Expand All @@ -24,24 +22,15 @@ public class AciCloudConfigTest {

@Test
public void configRoundTrip() throws Exception {
String cloudName = "aciTest";
AciCloud expectedAciCloud = createConfiguredAciCloud(cloudName);
AciCloud expectedAciCloud = createConfiguredAciCloud();

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 = jenkins.configRoundtrip(expectedAciCloud);

AciCloud actualAciCloud = (AciCloud) jenkins.jenkins.getCloud(cloudName);
jenkins.assertEqualDataBoundBeans(expectedAciCloud, actualAciCloud);


}

@NotNull
private AciCloud createConfiguredAciCloud(String cloudName) {
private AciCloud createConfiguredAciCloud() {
AciContainerTemplate containerTemplate = new AciContainerTemplate("containerName", "label",
100, "Linux", "helloworld", "command", "rootFs", emptyList(),
emptyList(), emptyList(), emptyList(), new ContainerOnceRetentionStrategy(), "cpu", "memory" );
Expand All @@ -51,7 +40,7 @@ private AciCloud createConfiguredAciCloud(String cloudName) {
dnsConfig.setDnsServers(Arrays.asList(new AciDnsServer("dnsServerAddress")));
privateIpAddress.setDnsConfig(dnsConfig);
containerTemplate.setPrivateIpAddress(privateIpAddress);
AciCloud acicloud = new AciCloud(cloudName, "", "", Arrays.asList(containerTemplate));
AciCloud acicloud = new AciCloud("aciTest", "", "", Arrays.asList(containerTemplate));
acicloud.setLogAnalyticsCredentialsId("");
return acicloud;
}
Expand Down