use of org.jboss.as.patching.tool.PatchingResult in project wildfly-core by wildfly.
the class OneOffPatchTestCase method testApplyOneOffPatch.
@Test
public void testApplyOneOffPatch() throws Exception {
// build a one-off patch for the base installation
// with 1 added module
String oneOffPatchID = randomString();
String oneOffLayerPatchID = randomString();
File oneOffPatchDir = mkdir(tempDir, oneOffPatchID);
String moduleName = randomString();
ContentModification moduleAdded = ContentModificationUtils.addModule(oneOffPatchDir, oneOffLayerPatchID, moduleName);
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 zippedPatch = createZippedPatchFile(oneOffPatchDir, oneOffPatchID);
PatchingResult result = executePatch(zippedPatch);
assertPatchHasBeenApplied(result, oneOffPatch);
InstalledIdentity updatedInstalledIdentity = loadInstalledIdentity();
File modulePatchDirectory = updatedInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(oneOffLayerPatchID);
assertDirExists(modulePatchDirectory);
assertDefinedModule(modulePatchDirectory, moduleName, moduleAdded.getItem().getContentHash());
}
use of org.jboss.as.patching.tool.PatchingResult in project wildfly-core by wildfly.
the class AbstractTaskTestCase method rollback.
protected PatchingResult rollback(PatchTool tool, String patchId, boolean rollbackTo, ContentVerificationPolicy policy) throws IOException, PatchingException {
final PatchingResult result = tool.rollback(patchId, policy, rollbackTo, true);
result.commit();
return result;
}
use of org.jboss.as.patching.tool.PatchingResult in project wildfly-core by wildfly.
the class AbstractTaskTestCase method executePatch.
protected PatchingResult executePatch(final PatchTool tool, final File file) throws IOException, PatchingException {
final PatchingResult result = tool.applyPatch(file, ContentVerificationPolicy.STRICT);
result.commit();
return result;
}
use of org.jboss.as.patching.tool.PatchingResult 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());
}
use of org.jboss.as.patching.tool.PatchingResult in project wildfly-core by wildfly.
the class FileTaskTestCase method testAddDirectory.
@Test
public void testAddDirectory() throws Exception {
final ContentItem item = new MiscContentItem("dir", new String[] { "test" }, NO_CONTENT, true, false);
final ContentModification addDir = new ContentModification(item, NO_CONTENT, ModificationType.ADD);
final String patchID = randomString();
final Patch patch = PatchBuilder.create().setPatchId(patchID).setDescription(randomString()).oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()).getParent().addContentModification(addDir).build();
// create the patch
final File patchDir = mkdir(tempDir, patch.getPatchId());
createPatchXMLFile(patchDir, patch);
final File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId());
// Apply
PatchingResult result = executePatch(zippedPatch);
assertPatchHasBeenApplied(result, patch);
final File test = new File(env.getInstalledImage().getJbossHome(), "test");
assertTrue(test.exists());
assertTrue(test.isDirectory());
final File dir = new File(test, "dir");
assertTrue(dir.exists());
assertTrue(dir.isDirectory());
rollback(patchID);
}
Aggregations