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