use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class MergingPatchContentTestCase method assertCP2State.
private void assertCP2State(PatchingResult result) throws Exception {
assertPatchHasBeenApplied(result, cp2);
assertFileExists(standaloneSh);
assertFileContent(cp2StandaloneModified.getItem().getContentHash(), standaloneSh);
assertFileExists(addedByCP1);
assertFileContent(cp1AddedByCP1Added.getItem().getContentHash(), addedByCP1);
assertFileExists(addedByCP1RemovedByCP3);
assertFileExists(addedByCP2);
assertFileContent(cp2AddedByCp2Added.getItem().getContentHash(), addedByCP2);
final InstalledIdentity installedIdentity = loadInstalledIdentity();
File modulePatchDiry = installedIdentity.getLayer(BASE).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(baseCP2ID);
assertDirExists(modulePatchDiry);
assertDefinedModule(modulePatchDiry, moduleName, cp2BaseModuleModified.getItem().getContentHash());
assertDefinedAbsentModule(modulePatchDiry, moduleName + "2");
modulePatchDiry = installedIdentity.getLayer("layer1").loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(layer1CP1ID);
assertDirExists(modulePatchDiry);
assertDefinedModule(modulePatchDiry, moduleName, cp1Layer1ModuleAdded.getItem().getContentHash());
modulePatchDiry = installedIdentity.getLayer("layer2").loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(layer2CP2ID);
assertDirExists(modulePatchDiry);
assertDefinedAbsentModule(modulePatchDiry, moduleName);
assertDefinedModule(modulePatchDiry, moduleName + "2", cp1Layer2Module2Added.getItem().getContentHash());
assertDefinedModule(modulePatchDiry, moduleName + "3", cp2Layer2Module3Added.getItem().getContentHash());
}
use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class PatchStepAssertions method assertApplied.
static void assertApplied(final Patch patch, InstallationManager manager) throws IOException {
final String patchID = patch.getPatchId();
InstalledIdentity installedIdentity = null;
try {
installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), null);
} catch (PatchingException e) {
Assert.fail(e.getLocalizedMessage());
}
final PatchableTarget target = installedIdentity.getIdentity();
final PatchableTarget.TargetInfo identity = target.loadTargetInfo();
assertIsApplied(patch.getIdentity().getPatchType(), patchID, identity);
assertExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patchID));
assertContentItems(patchID, target, patch.getModifications());
for (final PatchElement element : patch.getElements()) {
final PatchElementProvider provider = element.getProvider();
final PatchableTarget targetElement = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName());
assertIsApplied(provider.getPatchType(), element.getId(), targetElement.loadTargetInfo());
assertContentItems(element.getId(), targetElement, element.getModifications());
}
}
use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class PatchUndoTestCase method testWrongMiscContent.
@Test
public void testWrongMiscContent() throws Exception {
final PatchingTestBuilder builder = createDefaultBuilder();
ContentModificationUtils.addMisc(builder.getRoot(), "oo2", "test-content", "wrong-content");
final MiscContentItem item = new MiscContentItem("wrong-content", new String[0], WRONG_HASH);
final ContentModification wrongModification = new ContentModification(item, IoUtils.NO_CONTENT, ModificationType.ADD);
final PatchingTestStepBuilder step1 = builder.createStepBuilder();
step1.oneOffPatchIdentity(PRODUCT_VERSION).setPatchId("oo2").oneOffPatchElement("base-patch-002", "base", false).addModuleWithRandomContent("other.test", null).getParent().addFileWithRandomContent(null, "test", "content").addContentModification(wrongModification);
//
try {
apply(step1);
Assert.fail("should have failed");
} catch (PatchingException e) {
Assert.assertFalse(builder.hasFile("test", "content"));
Assert.assertFalse(builder.hasFile("wrong-content"));
final InstalledIdentity identity = loadInstallationManager().getDefaultIdentity();
final PatchableTarget base = identity.getLayer("base");
Assert.assertFalse(base.getDirectoryStructure().getModulePatchDirectory("base-patch-002").exists());
Assert.assertFalse(identity.getInstalledImage().getPatchHistoryDir("oo2").exists());
}
}
use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class ConfigurationBackupTestCase method testOneOffPatch.
@Test
public void testOneOffPatch() throws Exception {
// build a one-off 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).setPatchId(patchID).setDescription(randomString()).oneOffPatchIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion()).getParent().oneOffPatchElement(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 testApplyReleasePatch.
@Test
public void testApplyReleasePatch() throws Exception {
// build a Release 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();
Patch patch = PatchBuilder.create().setPatchId(patchID).setDescription(randomString()).upgradeIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion(), productConfig.getProductVersion() + "-Release1").getParent().upgradeElement(layerPatchID, BASE, false).addContentModification(moduleAdded).getParent().build();
createPatchXMLFile(patchDir, patch);
File zippedPatch = createZippedPatchFile(patchDir, patchID);
PatchingResult result = executePatch(zippedPatch);
assertPatchHasBeenApplied(result, patch);
InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity();
File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(layerPatchID);
assertDirExists(modulePatchDirectory);
assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash());
}
Aggregations