use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.
the class ModelPersistenceTestCase method testDomainOperationRollback.
@Test
public void testDomainOperationRollback() throws Exception {
DomainClient client = domainMasterLifecycleUtil.getDomainClient();
CfgFileDescription lastDomainBackupDesc = getLatestBackup(domainCurrentCfgDir);
CfgFileDescription lastMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
CfgFileDescription lastSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
// execute operation so the model gets updated
ModelNode op = ModelUtil.createOpNode("system-property=model-persistence-test", "add");
op.get(VALUE).set("test");
executeAndRollbackOperation(client, op);
// check that the model has not been updated
CfgFileDescription newDomainBackupDesc = getLatestBackup(domainCurrentCfgDir);
CfgFileDescription newMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
CfgFileDescription newSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
// check that the configs did not change
Assert.assertTrue(lastDomainBackupDesc.version == newDomainBackupDesc.version);
Assert.assertTrue(lastMasterBackupDesc.version == newMasterBackupDesc.version);
Assert.assertTrue(lastSlaveBackupDesc.version == newSlaveBackupDesc.version);
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.
the class ModelPersistenceTestCase method testHostOperationRollback.
@Test
public void testHostOperationRollback() throws Exception {
DomainClient client = domainMasterLifecycleUtil.getDomainClient();
for (Host host : Host.values()) {
CfgFileDescription lastDomainBackupDesc = getLatestBackup(domainCurrentCfgDir);
CfgFileDescription lastMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
CfgFileDescription lastSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
// execute operation so the model gets updated
ModelNode op = host.equals(Host.MASTER) ? ModelUtil.createOpNode("host=master/system-property=model-persistence-test", "add") : ModelUtil.createOpNode("host=slave/system-property=model-persistence-test", "add");
op.get(VALUE).set("test");
executeAndRollbackOperation(client, op);
// check that the model has not been updated
CfgFileDescription newDomainBackupDesc = getLatestBackup(domainCurrentCfgDir);
CfgFileDescription newMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
CfgFileDescription newSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
// check that the configs did not change
Assert.assertTrue(lastDomainBackupDesc.version == newDomainBackupDesc.version);
Assert.assertTrue(lastMasterBackupDesc.version == newMasterBackupDesc.version);
Assert.assertTrue(lastSlaveBackupDesc.version == newSlaveBackupDesc.version);
}
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.
the class ModelPersistenceTestCase method testDomainOperation.
private void testDomainOperation(ModelNode operation) throws Exception {
DomainClient client = domainMasterLifecycleUtil.getDomainClient();
CfgFileDescription lastBackupDesc = getLatestBackup(domainCurrentCfgDir);
CfgFileDescription lastMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
CfgFileDescription lastSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
long lastFileHash = domainLastCfgFile.exists() ? FileUtils.checksumCRC32(domainLastCfgFile) : -1;
// execute operation so the model gets updated
executeOperation(client, operation);
// check that the automated snapshot of the domain has been generated
CfgFileDescription newBackupDesc = getLatestBackup(domainCurrentCfgDir);
Assert.assertNotNull("Model snapshot not found.", newBackupDesc);
// check that the version is incremented by one
Assert.assertTrue(lastBackupDesc.version == newBackupDesc.version - 1);
// check that the both master and slave host snapshot have not been generated
CfgFileDescription newMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
CfgFileDescription newSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
Assert.assertTrue(lastMasterBackupDesc.version == newMasterBackupDesc.version);
Assert.assertTrue(lastSlaveBackupDesc.version == newSlaveBackupDesc.version);
// check that the last cfg file has changed
Assert.assertTrue(lastFileHash != FileUtils.checksumCRC32(domainLastCfgFile));
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.
the class ReadEnvironmentVariablesTestCase method testReadEnvironmentVariablesForServers.
@Test
public void testReadEnvironmentVariablesForServers() throws Exception {
DomainClient client = domainMasterLifecycleUtil.createDomainClient();
DomainDeploymentManager manager = client.getDeploymentManager();
try {
// Deploy the archive
WebArchive archive = ShrinkWrap.create(WebArchive.class, "env-test.war").addClass(EnvironmentTestServlet.class);
archive.addAsResource(new StringAsset("Manifest-Version: 1.0\nDependencies: org.jboss.dmr \n"), "META-INF/MANIFEST.MF");
archive.addAsManifestResource(createPermissionsXmlAsset(new RuntimePermission("getenv.*")), "permissions.xml");
final InputStream contents = archive.as(ZipExporter.class).exportAsInputStream();
try {
DeploymentPlan plan = manager.newDeploymentPlan().add("env-test.war", contents).deploy("env-test.war").toServerGroup("main-server-group").toServerGroup("other-server-group").build();
DeploymentPlanResult result = manager.execute(plan).get();
Assert.assertTrue(result.isValid());
} finally {
IoUtils.safeClose(contents);
}
Map<String, String> env = getEnvironmentVariables(client, "master", "main-one", "standard-sockets");
checkEnvironmentVariable(env, "DOMAIN_TEST_MAIN_GROUP", "main_group");
checkEnvironmentVariable(env, "DOMAIN_TEST_SERVER", "server");
checkEnvironmentVariable(env, "DOMAIN_TEST_JVM", "jvm");
env = getEnvironmentVariables(client, "slave", "main-three", "standard-sockets");
checkEnvironmentVariable(env, "DOMAIN_TEST_MAIN_GROUP", "main_group");
Assert.assertFalse(env.containsKey("DOMAIN_TEST_SERVER"));
Assert.assertFalse(env.containsKey("DOMAIN_TEST_JVM"));
env = getEnvironmentVariables(client, "slave", "other-two", "other-sockets");
Assert.assertFalse(env.containsKey("DOMAIN_TEST_MAIN_GROUP"));
Assert.assertFalse(env.containsKey("DOMAIN_TEST_SERVER"));
Assert.assertFalse(env.containsKey("DOMAIN_TEST_JVM"));
} finally {
DeploymentPlanResult result = manager.execute(manager.newDeploymentPlan().undeploy("env-test.war").build()).get();
Assert.assertTrue(result.isValid());
IoUtils.safeClose(client);
}
}
use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.
the class SimpleMixedDomainTest method test00009_SecurityTransformers.
@Test
public void test00009_SecurityTransformers() throws Exception {
final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
final DomainClient slaveClient = support.getDomainSlaveLifecycleUtil().createDomainClient();
try {
PathAddress subsystem = PathAddress.pathAddress(PathElement.pathElement(PROFILE, ACTIVE_PROFILE), PathElement.pathElement(SUBSYSTEM, SecurityExtension.SUBSYSTEM_NAME));
PathAddress webPolicy = subsystem.append(Constants.SECURITY_DOMAIN, "jboss-web-policy").append(Constants.AUTHORIZATION, Constants.CLASSIC);
ModelNode options = new ModelNode();
options.add("a", "b");
ModelNode op = Util.getWriteAttributeOperation(webPolicy.append(Constants.POLICY_MODULE, "Delegating"), Constants.MODULE_OPTIONS, options);
DomainTestUtils.executeForResult(op, masterClient);
//TODO check the resources
//System.out.println(DomainTestUtils.executeForResult(Util.createOperation(READ_RESOURCE_OPERATION, address), modelControllerClient));
PathAddress jaspi = subsystem.append(Constants.SECURITY_DOMAIN, "jaspi-test").append(Constants.AUTHENTICATION, Constants.JASPI);
PathAddress jaspiLoginStack = jaspi.append(Constants.LOGIN_MODULE_STACK, "lm-stack");
op = Util.createAddOperation(jaspiLoginStack.append(Constants.LOGIN_MODULE, "test2"));
op.get(Constants.CODE).set("UserRoles");
op.get(Constants.FLAG).set("required");
op.get(Constants.MODULE).set("test-jaspi");
DomainTestUtils.executeForResult(op, masterClient);
op = Util.createAddOperation(jaspi.append(Constants.AUTH_MODULE, "Delegating"));
op.get(Constants.CODE).set("Delegating");
op.get(Constants.LOGIN_MODULE_STACK_REF).set("lm-stack");
op.get(Constants.FLAG).set("optional");
DomainTestUtils.executeForResult(op, masterClient);
op = new ModelNode();
op.get(OP).set(READ_RESOURCE_OPERATION);
op.get(OP_ADDR).set(jaspi.toModelNode());
op.get(INCLUDE_ALIASES).set(false);
op.get(RECURSIVE).set(true);
ModelNode masterResource = DomainTestUtils.executeForResult(op, masterClient);
ModelNode slaveResource = DomainTestUtils.executeForResult(op, slaveClient);
ModelTestUtils.compare(masterResource, slaveResource, true);
} finally {
try {
//The server will be in restart-required mode, so restart it to get rid of the changes
PathAddress serverAddress = PathAddress.pathAddress(HOST, "slave").append(SERVER_CONFIG, "server-one");
ModelNode op = Util.createOperation(RESTART, PathAddress.pathAddress(serverAddress));
op.get(BLOCKING).set(true);
Assert.assertEquals("STARTED", validateResponse(slaveClient.execute(op), true).asString());
} finally {
IoUtils.safeClose(slaveClient);
IoUtils.safeClose(masterClient);
}
}
}
Aggregations