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

New configRoundtrip method for Cloud configuration #426

Merged
merged 4 commits into from
Apr 22, 2022
Merged
Changes from 3 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
19 changes: 19 additions & 0 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import hudson.security.AbstractPasswordBasedSecurityRealm;
import hudson.security.GroupDetails;
import hudson.security.csrf.CrumbIssuer;
import hudson.slaves.Cloud;
import hudson.slaves.ComputerConnector;
import hudson.slaves.ComputerLauncher;
import hudson.slaves.DumbSlave;
Expand Down Expand Up @@ -180,6 +181,7 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;
Expand Down Expand Up @@ -1426,6 +1428,23 @@ public <V extends View> V configRoundtrip(V view) throws Exception {
return view;
}

/**
* Performs a configuration round-trip testing for a cloud.
* The given cloud is added to the cloud list of Jenkins.
*
sparsick marked this conversation as resolved.
Show resolved Hide resolved
* If a cloud with the same name already exists, then this old one will be replaced by the given one.
*/
public <C extends Cloud> C configRoundtrip(C cloud) throws Exception {
Cloud cloudConfig = jenkins.getCloud(cloud.name);
if (cloudConfig != null) {
jenkins.clouds.remove(cloudConfig);
}
jenkins.clouds.add(cloud);
sparsick marked this conversation as resolved.
Show resolved Hide resolved
jenkins.save();
submit(createWebClient().goTo("configureClouds/").getFormByName("config"));
return (C)jenkins.getCloud(cloud.name);
}


/**
* Asserts that the outcome of the build is a specific outcome.
Expand Down