Skip to content

Commit

Permalink
[WFCORE-6815] Fix conflicts introduced by reload parameters usage
Browse files Browse the repository at this point in the history
  • Loading branch information
yersan committed Jun 5, 2024
1 parent 4a3678a commit 75810ff
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
*/
package org.jboss.as.test.integration.domain.management.util;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DOMAIN_CONFIG;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST_CONFIG;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD_ENHANCED;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART_SERVERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STABILITY;
import static org.jboss.as.test.integration.domain.management.util.DomainTestSupport.safeClose;

import java.io.File;
Expand Down Expand Up @@ -104,7 +113,7 @@ private DomainLifecycleUtil(final WildFlyManagedConfiguration configuration,
assert clientConfiguration != null : "clientConfiguration is null";
this.configuration = configuration;
this.clientConfiguration = clientConfiguration;
this.address = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.HOST, configuration.getHostName()));
this.address = PathAddress.pathAddress(PathElement.pathElement(HOST, configuration.getHostName()));
this.closeClientConfig = closeClientConfig;
}

Expand Down Expand Up @@ -444,17 +453,29 @@ public void reloadAdminOnly(String host, Long timeout) throws IOException, Inter
*/
public void reload(String host, ReloadParameters parameters) throws IOException, InterruptedException, TimeoutException {
ModelNode op = new ModelNode();
op.get(ModelDescriptionConstants.ADDRESS).add(ModelDescriptionConstants.HOST, host);
op.get(ModelDescriptionConstants.OP).set("reload");
op.get(ADDRESS).add(HOST, host);
op.get(OP).set(RELOAD);
op.get("admin-only").set(parameters.adminOnly);
op.get(ModelDescriptionConstants.RESTART_SERVERS).set(parameters.restartServers);
op.get(RESTART_SERVERS).set(parameters.restartServers);
long startupTimeout;
if (parameters.timeout == null) {
startupTimeout = configuration.getStartupTimeoutInSeconds();
} else {
startupTimeout = parameters.timeout;
}

if (parameters.hostConfig != null) {
op.get(HOST_CONFIG).set(parameters.hostConfig);
}
if (parameters.domainConfig != null) {
op.get(DOMAIN_CONFIG).set(parameters.domainConfig);
}
if (parameters instanceof ReloadEnhancedParameters) {
Stability stabilityParam = ((ReloadEnhancedParameters) parameters).stability;
if (stabilityParam != null) {
op.get(OP).set(RELOAD_ENHANCED);
op.get(STABILITY).set(stabilityParam.toString());
}
}
executeAwaitConnectionClosed(op);
// Try to reconnect to the hc
connect();
Expand All @@ -480,6 +501,10 @@ public static class ReloadParameters {

Long timeout = null;

String hostConfig;

String domainConfig;

/**
* Sets the adminOnly
*
Expand Down Expand Up @@ -526,6 +551,46 @@ public ReloadParameters setTimeout(Long timeout) {
this.timeout = timeout;
return this;
}

/**
* Sets the hostConfig
*
* @param hostConfig the path to the host configuration file to use
* @return this ReloadParameters object
*/
public ReloadParameters setHostConfig(String hostConfig) {
this.hostConfig = hostConfig;
return this;
}

/**
* Sets the domainConfig
*
* @param domainConfig the path to the domain configuration file to use
* @return this ReloadParameters object
*/
public ReloadParameters setDomainConfig(String domainConfig) {
this.domainConfig = domainConfig;
return this;
}
}

/**
* Reload parameters to execute reload-enhanced operation
*/
public static class ReloadEnhancedParameters extends ReloadParameters {
Stability stability;

/**
* Sets the stability
*
* @param stability the stability level to use
* @return this ReloadParameters object
*/
public ReloadParameters setStability(Stability stability) {
this.stability = stability;
return this;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ public static AutoCloseable takeSnapshot(DomainTestSupport testSupport) {
@Override
public void close() throws Exception {
for (Snapshot snapshot : snapShots) {
snapshot.lifecycleUtil.reload(snapshot.hostName, snapshot.stability, snapshot.hostConfig, snapshot.domainConfig);
DomainLifecycleUtil.ReloadEnhancedParameters reloadParams = new DomainLifecycleUtil.ReloadEnhancedParameters();
reloadParams.setStability(snapshot.stability)
.setHostConfig(snapshot.hostConfig)
.setDomainConfig(snapshot.domainConfig);

snapshot.lifecycleUtil.reload(snapshot.hostName, reloadParams);
PathAddress hostAddress = PathAddress.pathAddress(HOST, snapshot.hostName);
Stability reloadedStability = getStability(hostAddress, snapshot.lifecycleUtil.getDomainClient());
Assert.assertSame(reloadedStability, snapshot.stability);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ private void reloadToDesiredStability(PathAddress hostAddress, DomainLifecycleUt
}

//Reload the server to the desired stability level
domainLifecycleUtil.reload(hostAddress.getLastElement().getValue(), stability, null, null);
DomainLifecycleUtil.ReloadEnhancedParameters reload = new DomainLifecycleUtil.ReloadEnhancedParameters();
reload.setStability(stability);
domainLifecycleUtil.reload(hostAddress.getLastElement().getValue(), reload);
client = domainLifecycleUtil.getDomainClient();
Stability reloadedStability = readCurrentStability(hostAddress, client);
Assert.assertEquals(stability, reloadedStability);
Expand Down

0 comments on commit 75810ff

Please sign in to comment.