use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.
the class SimpleMixedDomainTest method profileCloneEap6x.
private void profileCloneEap6x() throws Exception {
// EAP 6 does not have the clone operation
// For an EAP 7 slave we will need another test since EAP 7 allows the clone operation.
// However EAP 7 will need to take into account the ignore-unused-configuration
// setting which does not exist in 6.x
final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
final DomainClient slaveClient = support.getDomainSlaveLifecycleUtil().createDomainClient();
try {
final PathAddress newProfileAddress = PathAddress.pathAddress(PROFILE, "new-profile");
// Create a new profile (so that we can ignore it on the host later)
DomainTestUtils.executeForResult(Util.createAddOperation(newProfileAddress), masterClient);
// Attempt to clone it. It should fail since the transformers reject it.
final ModelNode clone = Util.createEmptyOperation(CLONE, newProfileAddress);
clone.get(TO_PROFILE).set("cloned");
DomainTestUtils.executeForFailure(clone, masterClient);
// Ignore the new profile on the slave and reload
final PathAddress ignoredResourceAddress = PathAddress.pathAddress(HOST, "slave").append(CORE_SERVICE, IGNORED_RESOURCES).append(IGNORED_RESOURCE_TYPE, PROFILE);
final ModelNode ignoreNewProfile = Util.createAddOperation(ignoredResourceAddress);
ignoreNewProfile.get(NAMES).add("new-profile");
DomainTestUtils.executeForResult(ignoreNewProfile, slaveClient);
// Reload slave so ignore takes effect
reloadHost(support.getDomainSlaveLifecycleUtil(), "slave");
// Clone should work now that the new profile is ignored
DomainTestUtils.executeForResult(clone, masterClient);
// Adding a subsystem to the cloned profile should fail since the profile does not exist on the slave
DomainTestUtils.executeForFailure(Util.createAddOperation(PathAddress.pathAddress(PROFILE, "cloned").append(SUBSYSTEM, "jmx")), masterClient);
// Reload slave
reloadHost(support.getDomainSlaveLifecycleUtil(), "slave");
// Reloading should have brought over the cloned profile, so adding a subsystem should now work
DomainTestUtils.executeForResult(Util.createAddOperation(PathAddress.pathAddress(PROFILE, "cloned").append(SUBSYSTEM, "jmx")), masterClient);
} finally {
IoUtils.safeClose(slaveClient);
IoUtils.safeClose(masterClient);
}
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.
the class ServerHelper method isDomainRunning.
/**
* Checks to see if a domain server is running.
*
* @param client the client used to communicate with the server
* @param forShutdown if this is checking for a shutdown
*
* @return {@code true} if the server, and it's auto-start servers, are running, otherwise {@code false}
*/
public static boolean isDomainRunning(final ModelControllerClient client, final boolean forShutdown) {
final DomainClient domainClient = (client instanceof DomainClient ? (DomainClient) client : DomainClient.Factory.create(client));
try {
// Check for admin-only
final ModelNode hostAddress = determineHostAddress(domainClient);
final Operations.CompositeOperationBuilder builder = Operations.CompositeOperationBuilder.create().addStep(Operations.createReadAttributeOperation(hostAddress, "running-mode")).addStep(Operations.createReadAttributeOperation(hostAddress, "host-state"));
ModelNode response = domainClient.execute(builder.build());
if (Operations.isSuccessfulOutcome(response)) {
response = Operations.readResult(response);
if ("ADMIN_ONLY".equals(Operations.readResult(response.get("step-1")).asString())) {
if (Operations.isSuccessfulOutcome(response.get("step-2"))) {
final String state = Operations.readResult(response).asString();
return !CONTROLLER_PROCESS_STATE_STARTING.equals(state) && !CONTROLLER_PROCESS_STATE_STOPPING.equals(state);
}
}
}
final Map<ServerIdentity, ServerStatus> servers = new HashMap<>();
final Map<ServerIdentity, ServerStatus> statuses = domainClient.getServerStatuses();
for (ServerIdentity id : statuses.keySet()) {
final ServerStatus status = statuses.get(id);
switch(status) {
case DISABLED:
case STARTED:
{
servers.put(id, status);
break;
}
}
}
if (forShutdown) {
return statuses.isEmpty();
}
return statuses.size() == servers.size();
} catch (IllegalStateException | IOException ignore) {
}
return false;
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.
the class LegacyConfigTest method testServerLaunching.
@Test
public void testServerLaunching() throws IOException, MgmtOperationException, InterruptedException {
DomainClient client = support.getDomainMasterLifecycleUtil().getDomainClient();
for (Map.Entry<String, String> entry : getProfilesToTest().entrySet()) {
String profile = entry.getKey();
String sbg = entry.getValue();
try {
installTestServer(client, profile, sbg);
awaitServerLaunch(client, profile);
validateServerProfile(client, profile);
verifyHttp(profile);
} finally {
cleanTestServer(client);
}
}
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.
the class DeploymentOverlayTestCase method testDeploymentOverlayInDomainMode.
/**
* This test creates and links two deployment overlays, does a deployment, and then tests that the overlay has taken effect
* @throws Exception
*/
@Test
public void testDeploymentOverlayInDomainMode() throws Exception {
setupDeploymentOverride();
ModelNode content = new ModelNode();
content.get(INPUT_STREAM_INDEX).set(0);
ModelNode composite = createDeploymentOperation(content, MAIN_SERVER_GROUP_DEPLOYMENT_ADDRESS);
OperationBuilder builder = new OperationBuilder(composite, true);
builder.addInputStream(webArchive.as(ZipExporter.class).exportAsInputStream());
executeOnMaster(builder.build());
DomainClient client = testSupport.getDomainMasterLifecycleUtil().createDomainClient();
Assert.assertEquals("OVERRIDDEN", performHttpCall(client, "master", "main-one", "standard-sockets"));
Assert.assertEquals("OVERRIDDEN", performHttpCall(client, "slave", "main-three", "standard-sockets"));
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.
the class ModelPersistenceTestCase method testTakeAndDeleteSnapshot.
@Test
public void testTakeAndDeleteSnapshot() throws Exception {
DomainClient client = domainMasterLifecycleUtil.getDomainClient();
// take snapshot
ModelNode op = ModelUtil.createOpNode(null, "take-snapshot");
ModelNode result = executeOperation(client, op);
// check that the snapshot file exists
String snapshotFileName = result.asString();
File snapshotFile = new File(snapshotFileName);
Assert.assertTrue(snapshotFile.exists());
// compare with current cfg
long snapshotHash = FileUtils.checksumCRC32(snapshotFile);
long lastHash = FileUtils.checksumCRC32(domainLastCfgFile);
Assert.assertTrue(snapshotHash == lastHash);
// delete snapshot
op = ModelUtil.createOpNode(null, "delete-snapshot");
op.get("name").set(snapshotFile.getName());
executeOperation(client, op);
// check that the file is deleted
Assert.assertFalse("Snapshot file still exists.", snapshotFile.exists());
}
Aggregations