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());
}
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);
}
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);
}
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());
}
Aggregations