Search in sources :

Example 11 with DomainClient

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);
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 12 with DomainClient

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);
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 13 with DomainClient

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));
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient)

Example 14 with DomainClient

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);
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) InputStream(java.io.InputStream) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) DeploymentPlanResult(org.jboss.as.controller.client.helpers.domain.DeploymentPlanResult) DeploymentPlan(org.jboss.as.controller.client.helpers.domain.DeploymentPlan) DomainDeploymentManager(org.jboss.as.controller.client.helpers.domain.DomainDeploymentManager) Test(org.junit.Test)

Example 15 with DomainClient

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);
        }
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

DomainClient (org.jboss.as.controller.client.helpers.domain.DomainClient)24 ModelNode (org.jboss.dmr.ModelNode)17 Test (org.junit.Test)16 PathAddress (org.jboss.as.controller.PathAddress)5 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)2 DeploymentPlan (org.jboss.as.controller.client.helpers.domain.DeploymentPlan)2 DeploymentPlanResult (org.jboss.as.controller.client.helpers.domain.DeploymentPlanResult)2 DomainDeploymentManager (org.jboss.as.controller.client.helpers.domain.DomainDeploymentManager)2 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)2 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)2 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)2 Map (java.util.Map)1 PathElement (org.jboss.as.controller.PathElement)1 Operations (org.jboss.as.controller.client.helpers.Operations)1 ServerIdentity (org.jboss.as.controller.client.helpers.domain.ServerIdentity)1 ServerStatus (org.jboss.as.controller.client.helpers.domain.ServerStatus)1