Search in sources :

Example 11 with InstalledIdentity

use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.

the class ModuleTaskTestCase method testUpdateModule.

@Test
public void testUpdateModule() throws Exception {
    String moduleName = randomString();
    // create an empty module in the AS7 installation base layer
    File baseModuleDir = newFile(env.getInstalledImage().getModulesDir(), SYSTEM, LAYERS, BASE);
    File moduleDir = createModule0(baseModuleDir, moduleName);
    // build a one-off patch for the base installation
    // with 1 module updated
    String patchID = randomString();
    String baseLayerPatchID = randomString();
    File patchDir = mkdir(tempDir, patchID);
    // create the patch with the updated module
    ContentModification moduleModified = ContentModificationUtils.modifyModule(patchDir, baseLayerPatchID, moduleDir, "new resource in the module");
    Patch patch = PatchBuilder.create().setPatchId(patchID).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().oneOffPatchElement(baseLayerPatchID, BASE, false).addContentModification(moduleModified).getParent().build();
    createPatchXMLFile(patchDir, patch);
    File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId());
    PatchingResult result = executePatch(zippedPatch);
    assertPatchHasBeenApplied(result, patch);
    tree(env.getInstalledImage().getJbossHome());
    InstalledIdentity installedIdentity = loadInstalledIdentity();
    File modulesPatchDir = installedIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(baseLayerPatchID);
    assertDirExists(modulesPatchDir);
    // check that the defined module is the updated one
    assertDefinedModule(modulesPatchDir, moduleName, moduleModified.getItem().getContentHash());
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchingResult(org.jboss.as.patching.tool.PatchingResult) TestUtils.randomString(org.jboss.as.patching.runner.TestUtils.randomString) IoUtils.newFile(org.jboss.as.patching.IoUtils.newFile) TestUtils.createPatchXMLFile(org.jboss.as.patching.runner.TestUtils.createPatchXMLFile) File(java.io.File) TestUtils.createZippedPatchFile(org.jboss.as.patching.runner.TestUtils.createZippedPatchFile) ContentModification(org.jboss.as.patching.metadata.ContentModification) Patch(org.jboss.as.patching.metadata.Patch) Test(org.junit.Test)

Example 12 with InstalledIdentity

use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.

the class PatchingHistoryDirArtifact method process.

@Override
public boolean process(PatchingArtifacts.PatchID parent, PatchingArtifactProcessor processor) {
    final InstalledIdentity identity = processor.getValidationContext().getInstalledIdentity();
    final File history = identity.getInstalledImage().getPatchHistoryDir(parent.getPatchID());
    final PatchingFileArtifact.DirectoryArtifactState state = new PatchingFileArtifact.DirectoryArtifactState(history, this);
    return processor.process(this, state);
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) File(java.io.File)

Example 13 with InstalledIdentity

use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.

the class AbstractPatchingTest method rollback.

protected PatchingResult rollback(final PatchingTestStepBuilder builder, final ContentVerificationPolicy verificationPolicy, final PatchStepAssertions assertions, boolean rollbackTo) throws PatchingException {
    final Patch patch = builder.build();
    final File installation = new File(tempDir, JBOSS_INSTALLATION);
    try {
        assertions.before(installation, patch, installationManager);
    } catch (IOException e) {
        throw new PatchingException(e);
    }
    final String patchId = patch.getPatchId();
    final PatchTool patchTool = PatchTool.Factory.create(installationManager);
    final PatchingResult result = patchTool.rollback(patchId, verificationPolicy, rollbackTo, false);
    result.commit();
    final InstalledIdentity identity = installationManager.getInstalledIdentity(patch.getIdentity().getName(), null);
    Assert.assertFalse(identity.getAllInstalledPatches().contains(patch.getPatchId()));
    try {
        assertions.after(installation, patch, installationManager);
    } catch (IOException e) {
        throw new PatchingException(e);
    }
    return result;
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchingException(org.jboss.as.patching.PatchingException) PatchingResult(org.jboss.as.patching.tool.PatchingResult) PatchTool(org.jboss.as.patching.tool.PatchTool) IOException(java.io.IOException) TestUtils.randomString(org.jboss.as.patching.runner.TestUtils.randomString) Patch(org.jboss.as.patching.metadata.Patch) File(java.io.File)

Example 14 with InstalledIdentity

use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.

the class BasicHistoryUnitTestCase method testIncrementalLayersPatch.

@Test
public void testIncrementalLayersPatch() throws Exception {
    final PatchingTestBuilder builder = createDefaultBuilder("layer-2", "layer-1", "base");
    final byte[] moduleHashOne = new byte[20];
    final byte[] moduleHashTwo = new byte[20];
    final byte[] moduleHashThree = new byte[20];
    final byte[] moduleHashFour = new byte[20];
    final byte[] moduleHashFive = new byte[20];
    final byte[] moduleHashSix = new byte[20];
    final PatchingTestStepBuilder cp1 = builder.createStepBuilder();
    cp1.setPatchId("CP1").upgradeIdentity(PRODUCT_VERSION, PRODUCT_VERSION).upgradeElement("base-CP1", "base", false).addModuleWithRandomContent("org.jboss.test", moduleHashOne);
    // Apply CP1
    apply(cp1);
    final PatchingTestStepBuilder cp2 = builder.createStepBuilder();
    cp2.setPatchId("CP2").upgradeIdentity(PRODUCT_VERSION, PRODUCT_VERSION).upgradeElement("layer-1-CP1", "layer-1", false).addModuleWithRandomContent("org.jboss.test.two", moduleHashTwo);
    // Apply CP2
    apply(cp2);
    final PatchingTestStepBuilder cp3 = builder.createStepBuilder();
    cp3.setPatchId("CP3").upgradeIdentity(PRODUCT_VERSION, PRODUCT_VERSION).upgradeElement("layer-2-CP1", "layer-2", false).removeModule("org.jboss.test.three", "main", moduleHashThree);
    // Apply CP2
    apply(cp3);
    final PatchingTestStepBuilder cp4 = builder.createStepBuilder();
    cp4.setPatchId("CP4").upgradeIdentity(PRODUCT_VERSION, PRODUCT_VERSION).upgradeElement("base-CP2", "base", false).addModuleWithRandomContent("org.jboss.test.four", moduleHashFour);
    // Apply CP4
    apply(cp4);
    InstalledIdentity identity = loadInstallationManager().getDefaultIdentity();
    PatchStepAssertions.assertModule("base-CP2", identity.getLayer("base"), "org.jboss.test", "main");
    PatchStepAssertions.assertModule("base-CP2", identity.getLayer("base"), "org.jboss.test.four", "main");
    final PatchingTestStepBuilder cp5 = builder.createStepBuilder();
    cp5.setPatchId("CP5").upgradeIdentity(PRODUCT_VERSION, PRODUCT_VERSION).upgradeElement("base-CP3", "base", false).updateModuleWithRandomContent("org.jboss.test.four", moduleHashFour, null).getParent().upgradeElement("layer-1-CP2", "layer-1", false).addModuleWithRandomContent("org.jboss.test.five", moduleHashFive).getParent().upgradeElement("layer-2-CP2", "layer-2", false).addModuleWithRandomContent("org.jboss.test.six", moduleHashSix);
    // Apply CP5
    apply(cp5);
    identity = loadInstallationManager().getDefaultIdentity();
    PatchStepAssertions.assertModule("base-CP3", identity.getLayer("base"), "org.jboss.test", "main");
    PatchStepAssertions.assertModule("base-CP3", identity.getLayer("base"), "org.jboss.test.four", "main");
    PatchStepAssertions.assertModule("layer-1-CP2", identity.getLayer("layer-1"), "org.jboss.test.two", "main");
    PatchStepAssertions.assertModule("layer-1-CP2", identity.getLayer("layer-1"), "org.jboss.test.five", "main");
    PatchStepAssertions.assertModule("layer-2-CP2", identity.getLayer("layer-2"), "org.jboss.test.three", "main");
    PatchStepAssertions.assertModule("layer-2-CP2", identity.getLayer("layer-2"), "org.jboss.test.six", "main");
    rollback(cp5);
    rollback(cp4);
    rollback(cp3);
    rollback(cp2);
    rollback(cp1);
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) Test(org.junit.Test)

Example 15 with InstalledIdentity

use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.

the class MergingPatchContentTestCase method assertNotPatched.

private void assertNotPatched() throws Exception {
    assertFileExists(standaloneSh);
    assertFileContent(originalStandaloneHash, standaloneSh);
    assertFileDoesNotExist(addedByCP1);
    assertFileDoesNotExist(addedByCP1RemovedByCP3);
    assertFileDoesNotExist(addedByCP2);
    final InstalledIdentity installedIdentity = loadInstalledIdentity();
    Assert.assertTrue(installedIdentity.getAllInstalledPatches().isEmpty());
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity)

Aggregations

InstalledIdentity (org.jboss.as.patching.installation.InstalledIdentity)44 File (java.io.File)23 Patch (org.jboss.as.patching.metadata.Patch)19 Test (org.junit.Test)19 ContentModification (org.jboss.as.patching.metadata.ContentModification)17 TestUtils.createPatchXMLFile (org.jboss.as.patching.runner.TestUtils.createPatchXMLFile)17 TestUtils.createZippedPatchFile (org.jboss.as.patching.runner.TestUtils.createZippedPatchFile)17 PatchingResult (org.jboss.as.patching.tool.PatchingResult)16 PatchingException (org.jboss.as.patching.PatchingException)15 TestUtils.randomString (org.jboss.as.patching.runner.TestUtils.randomString)15 HashUtils.hashFile (org.jboss.as.patching.HashUtils.hashFile)14 IOException (java.io.IOException)8 IoUtils.newFile (org.jboss.as.patching.IoUtils.newFile)8 PatchableTarget (org.jboss.as.patching.installation.PatchableTarget)8 PatchElement (org.jboss.as.patching.metadata.PatchElement)5 Identity (org.jboss.as.patching.installation.Identity)4 PatchElementProvider (org.jboss.as.patching.metadata.PatchElementProvider)4 ArrayList (java.util.ArrayList)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 InstallationManager (org.jboss.as.patching.installation.InstallationManager)3