Search in sources :

Example 41 with InstalledIdentity

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

the class PatchUndoTestCase method testWrongModuleContentOverride.

private void testWrongModuleContentOverride(final ContentVerificationPolicy contentVerificationPolicy) throws Exception {
    final PatchingTestBuilder builder = createDefaultBuilder();
    // Add some random content
    ContentModificationUtils.addModule(builder.getRoot(), "base-patch-003", "test.module", randomString());
    // Override the hash with a wrong one
    final ModuleItem item = new ModuleItem("test.module", "main", WRONG_HASH);
    final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD);
    final PatchingTestStepBuilder step1 = builder.createStepBuilder();
    step1.oneOffPatchIdentity(PRODUCT_VERSION).setPatchId("oo3").oneOffPatchElement("base-patch-003", "base", false).addContentModification(wrongModification).getParent().addFileWithRandomContent(null, "test", "content");
    apply(step1, contentVerificationPolicy);
    Assert.assertTrue(builder.hasFile("test", "content"));
    final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity();
    final PatchableTarget base = identity.getLayer("base");
    Assert.assertTrue(base.getDirectoryStructure().getModulePatchDirectory("base-patch-003").exists());
    Assert.assertTrue(identity.getInstalledImage().getPatchHistoryDir("oo3").exists());
}
Also used : ModuleItem(org.jboss.as.patching.metadata.ModuleItem) InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchableTarget(org.jboss.as.patching.installation.PatchableTarget) ContentModification(org.jboss.as.patching.metadata.ContentModification)

Example 42 with InstalledIdentity

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

the class PatchingHistoryUnitTestCase method cannotRollbackPatch.

protected void cannotRollbackPatch(final String patchID) throws Exception {
    InstalledIdentity installedIdentity = updateInstallationManager().getDefaultIdentity();
    PatchingException expectedEx = null;
    try {
        validateRollbackState(patchID, installedIdentity);
    } catch (PatchingException e) {
        expectedEx = e;
    }
    assertNotNull("should not be able to rollback " + patchID, expectedEx);
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchingException(org.jboss.as.patching.PatchingException)

Example 43 with InstalledIdentity

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

the class ConfigurationBackupTestCase method testCumulativePatch.

@Test
public void testCumulativePatch() throws Exception {
    // build a cumulative patch for the base installation
    // with 1 added module
    String patchID = randomString();
    String layerPatchID = randomString();
    File patchDir = mkdir(tempDir, patchID);
    String moduleName = randomString();
    ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchID, moduleName);
    InstalledIdentity installedIdentity = loadInstalledIdentity();
    final PatchBuilder builder = PatchBuilder.create();
    builder.setPatchId(patchID).setDescription(randomString()).upgradeIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion(), productConfig.getProductVersion() + "-CP1").getParent().upgradeElement(layerPatchID, BASE, false).addContentModification(moduleAdded);
    Patch patch = builder.build();
    checkApplyPatchAndRollbackRestoresBackupConfiguration(patchDir, patch);
}
Also used : InstalledIdentity(org.jboss.as.patching.installation.InstalledIdentity) PatchBuilder(org.jboss.as.patching.metadata.PatchBuilder) HashUtils.bytesToHexString(org.jboss.as.patching.HashUtils.bytesToHexString) TestUtils.randomString(org.jboss.as.patching.runner.TestUtils.randomString) TestUtils.createPatchXMLFile(org.jboss.as.patching.runner.TestUtils.createPatchXMLFile) HashUtils.hashFile(org.jboss.as.patching.HashUtils.hashFile) 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 44 with InstalledIdentity

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

the class CumulativePatchTestCase method testInvalidateOneOffPatches.

@Test
public void testInvalidateOneOffPatches() throws Exception {
    // build a one-off patch for the base installation
    // with 1 added module
    // randomString();
    String oneOffPatchID = "oneOffPatchID";
    // randomString();
    String oneOffLayerPatchID = "oneOffLayerPatchID";
    File oneOffPatchDir = mkdir(tempDir, oneOffPatchID);
    // randomString();
    String moduleName = "mymodule";
    ContentModification moduleAdded = ContentModificationUtils.addModule(oneOffPatchDir, oneOffLayerPatchID, moduleName);
    InstalledIdentity identityBeforePatch = loadInstalledIdentity();
    Patch oneOffPatch = PatchBuilder.create().setPatchId(oneOffPatchID).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().oneOffPatchElement(oneOffLayerPatchID, BASE, false).addContentModification(moduleAdded).getParent().build();
    createPatchXMLFile(oneOffPatchDir, oneOffPatch);
    File zippedOneOffPatch = createZippedPatchFile(oneOffPatchDir, oneOffPatchID);
    PatchingResult resultOfOneOffPatch = executePatch(zippedOneOffPatch);
    assertPatchHasBeenApplied(resultOfOneOffPatch, oneOffPatch);
    InstalledIdentity installedIdentityAfterOneOffPatch = loadInstalledIdentity();
    File modulePatchDirectory = installedIdentityAfterOneOffPatch.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID);
    assertDirExists(modulePatchDirectory);
    assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash());
    // build a Release patch for the base installation
    // randomString() + "-Release";
    String releasePatchID = "releasePatchID";
    // randomString();
    String releaseLayerPatchID = "releaseLayerPatchID";
    File releasePatchDir = mkdir(tempDir, releasePatchID);
    ContentModification moduleAddedInReleasePatch = ContentModificationUtils.addModule(releasePatchDir, releaseLayerPatchID, moduleName, "different content in the module");
    final String resultingVersion = identityBeforePatch.getIdentity().getVersion() + "-Release1";
    Patch releasePatch = PatchBuilder.create().setPatchId(releasePatchID).setDescription(randomString()).upgradeIdentity(identityBeforePatch.getIdentity().getName(), identityBeforePatch.getIdentity().getVersion(), resultingVersion).getParent().upgradeElement(releaseLayerPatchID, BASE, false).addContentModification(moduleAddedInReleasePatch).getParent().build();
    createPatchXMLFile(releasePatchDir, releasePatch);
    File zippedReleasePatch = createZippedPatchFile(releasePatchDir, releasePatchID);
    PatchingResult resultOfReleasePatch = executePatch(zippedReleasePatch);
    assertPatchHasBeenApplied(resultOfReleasePatch, releasePatch);
    tree(env.getInstalledImage().getJbossHome());
    modulePatchDirectory = installedIdentityAfterOneOffPatch.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(releaseLayerPatchID);
    assertDirExists(modulePatchDirectory);
    assertDefinedModule(modulePatchDirectory, moduleName, moduleAddedInReleasePatch.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) HashUtils.hashFile(org.jboss.as.patching.HashUtils.hashFile) 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)

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