use of org.jboss.as.patching.metadata.Patch in project wildfly-core by wildfly.
the class FileTaskTestCase method testRemoveFile.
@Test
public void testRemoveFile() throws Exception {
// start from a base installation
// with a file in it
String fileName = "standalone.sh";
File standaloneShellFile = touch(env.getInstalledImage().getJbossHome(), "bin", fileName);
dump(standaloneShellFile, "original script to run standalone AS7");
// build a one-off patch for the base installation
// with 1 removed file
ContentModification fileRemoved = ContentModificationUtils.removeMisc(standaloneShellFile, "bin", fileName);
Patch patch = PatchBuilder.create().setPatchId(randomString()).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(fileRemoved).build();
// create the patch
File patchDir = mkdir(tempDir, patch.getPatchId());
createPatchXMLFile(patchDir, patch);
File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId());
PatchingResult result = executePatch(zippedPatch);
assertPatchHasBeenApplied(result, patch);
// / file has been removed from the AS7 installation
assertFileDoesNotExist(standaloneShellFile);
// but it's been backed up
assertFileExists(env.getInstalledImage().getPatchHistoryDir(patch.getPatchId()), "misc", "bin", fileName);
}
use of org.jboss.as.patching.metadata.Patch in project wildfly-core by wildfly.
the class ModuleTaskTestCase method testAddModule.
@Test
public void testAddModule() throws Exception {
// build a one-off patch for the base installation
// with 1 added module
String patchID = randomString();
File patchDir = mkdir(tempDir, patchID);
String baseLayerPatchID = randomString();
String moduleName = randomString();
ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, baseLayerPatchID, moduleName);
Patch patch = PatchBuilder.create().setPatchId(patchID).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().oneOffPatchElement(baseLayerPatchID, 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(baseLayerPatchID);
assertDirExists(modulePatchDirectory);
assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash());
}
use of org.jboss.as.patching.metadata.Patch in project wildfly-core by wildfly.
the class AbstractPatchingTest method apply.
protected PatchingResult apply(final PatchingTestStepBuilder builder, final ContentVerificationPolicy verificationPolicy, final PatchStepAssertions assertions) 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);
}
// Write patch
writePatch(builder.getPatchDir(), patch);
// Create the patch tool and apply the patch
final PatchTool patchTool = PatchTool.Factory.create(installationManager);
final PatchingResult result = patchTool.applyPatch(builder.getPatchDir(), verificationPolicy);
result.commit();
final InstalledIdentity identity = ((InstallationManagerImpl) installationManager).getInstalledIdentity(patch.getIdentity().getName(), null);
Assert.assertTrue(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.metadata.Patch 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.metadata.Patch in project wildfly-core by wildfly.
the class PatchMergeUnitTestCase method createRollbackInfo.
static RollbackInfo createRollbackInfo(String id, byte[] oih, byte[] oth, byte[] rih, byte[] rth) {
//
final MiscContentItem oi = new MiscContentItem(name, path, oih);
final MiscContentItem ri = new MiscContentItem(name, path, rih);
//
final Patch o = createPatch(id, Patch.PatchType.ONE_OFF, new ContentModification(oi, oth, ModificationType.MODIFY));
final Patch r = createPatch(id, Patch.PatchType.ONE_OFF, new ContentModification(ri, rth, ModificationType.MODIFY));
//
return new RollbackInfo(o, r);
}
Aggregations