Search in sources :

Example 21 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

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 22 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

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 23 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project wildfly by wildfly.

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 24 with DomainClient

use of org.jboss.as.controller.client.helpers.domain.DomainClient in project eap-additional-testsuite by jboss-set.

the class ModelPersistenceTestCase method testHostOperation.

private void testHostOperation(ModelNode operation, Host controller, Host target) throws Exception {
    DomainClient client = controller.equals(Host.MASTER) ? domainMasterLifecycleUtil.getDomainClient() : domainSlaveLifecycleUtil.getDomainClient();
    CfgFileDescription lastDomainBackupDesc = getLatestBackup(domainCurrentCfgDir);
    CfgFileDescription lastMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
    CfgFileDescription lastSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
    long lastDomainFileHash = domainLastCfgFile.exists() ? FileUtils.checksumCRC32(domainLastCfgFile) : -1;
    long lastMasterFileHash = masterLastCfgFile.exists() ? FileUtils.checksumCRC32(masterLastCfgFile) : -1;
    long lastSlaveFileHash = slaveLastCfgFile.exists() ? FileUtils.checksumCRC32(slaveLastCfgFile) : -1;
    // execute operation so the model gets updated
    executeOperation(client, operation);
    // check that the automated snapshot of the domain has not been generated
    CfgFileDescription newDomainBackupDesc = getLatestBackup(domainCurrentCfgDir);
    Assert.assertTrue(lastDomainBackupDesc.version == newDomainBackupDesc.version);
    // check that only the appropriate host snapshot has been generated
    CfgFileDescription newMasterBackupDesc = getLatestBackup(masterCurrentCfgDir);
    CfgFileDescription newSlaveBackupDesc = getLatestBackup(slaveCurrentCfgDir);
    if (target == Host.MASTER) {
        Assert.assertTrue(lastMasterBackupDesc.version == newMasterBackupDesc.version - 1);
        Assert.assertTrue(lastSlaveBackupDesc.version == newSlaveBackupDesc.version);
        Assert.assertTrue(lastMasterFileHash != FileUtils.checksumCRC32(masterLastCfgFile));
        Assert.assertTrue(lastSlaveFileHash == FileUtils.checksumCRC32(slaveLastCfgFile));
    } else {
        Assert.assertTrue(lastMasterBackupDesc.version == newMasterBackupDesc.version);
        Assert.assertTrue(lastSlaveBackupDesc.version == newSlaveBackupDesc.version - 1);
        Assert.assertTrue(lastMasterFileHash == FileUtils.checksumCRC32(masterLastCfgFile));
        Assert.assertTrue(lastSlaveFileHash != FileUtils.checksumCRC32(slaveLastCfgFile));
    }
    Assert.assertTrue(lastDomainBackupDesc.version == newDomainBackupDesc.version);
    Assert.assertTrue(lastDomainFileHash == FileUtils.checksumCRC32(domainLastCfgFile));
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient)

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