Search in sources :

Example 1 with DirectoryStructure

use of org.jboss.as.patching.DirectoryStructure in project wildfly-core by wildfly.

the class PatchStepAssertions method assertNotApplied.

static void assertNotApplied(final Patch.PatchType patchType, final String patchId, final PatchableTarget.TargetInfo targetInfo) {
    if (patchType == Patch.PatchType.CUMULATIVE) {
        Assert.assertNotEquals(patchId, targetInfo.getCumulativePatchID());
    } else {
        Assert.assertFalse(targetInfo.getPatchIDs().contains(patchId));
    }
    final DirectoryStructure structure = targetInfo.getDirectoryStructure();
    assertDoesNotExists(structure.getBundlesPatchDirectory(patchId));
    assertDoesNotExists(structure.getModulePatchDirectory(patchId));
}
Also used : DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Example 2 with DirectoryStructure

use of org.jboss.as.patching.DirectoryStructure in project wildfly-core by wildfly.

the class PatchStepAssertions method assertIsApplied.

static void assertIsApplied(final Patch.PatchType patchType, final String patchId, final PatchableTarget.TargetInfo targetInfo) {
    if (patchType == Patch.PatchType.CUMULATIVE) {
        Assert.assertEquals(patchId, targetInfo.getCumulativePatchID());
        Assert.assertTrue(targetInfo.getPatchIDs().isEmpty());
    } else {
        Assert.assertTrue(targetInfo.getPatchIDs().contains(patchId));
    }
    final DirectoryStructure structure = targetInfo.getDirectoryStructure();
    assertExists(structure.getBundlesPatchDirectory(patchId));
    assertExists(structure.getModulePatchDirectory(patchId));
}
Also used : DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Example 3 with DirectoryStructure

use of org.jboss.as.patching.DirectoryStructure in project wildfly-core by wildfly.

the class PatchingOverlayDirArtifact method process.

@Override
public boolean process(PatchableTargetsArtifact.PatchableTargetState parent, PatchingArtifactProcessor processor) {
    if (bundles && !parent.isCheckBundles()) {
        return true;
    } else if (!parent.isCheckModules()) {
        return true;
    }
    final String patchID = parent.getPatchID();
    final DirectoryStructure structure = parent.getStructure();
    final File overlay = bundles ? structure.getBundlesPatchDirectory(patchID) : structure.getModulePatchDirectory(patchID);
    final PatchingFileArtifact.DirectoryArtifactState state = new PatchingFileArtifact.DirectoryArtifactState(overlay, this);
    return processor.process(this, state);
}
Also used : File(java.io.File) DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Example 4 with DirectoryStructure

use of org.jboss.as.patching.DirectoryStructure in project wildfly-core by wildfly.

the class AddOnTestCase method installedAddOn.

@Test
public void installedAddOn() throws Exception {
    String addOnName = randomString();
    installAddOn(env.getModuleRoot(), addOnName);
    TestUtils.tree(env.getInstalledImage().getJbossHome());
    InstalledIdentity installedIdentity = loadInstalledIdentity();
    Collection<AddOn> addOns = installedIdentity.getAddOns();
    assertEquals(1, addOns.size());
    AddOn addOn = addOns.iterator().next();
    assertEquals(addOnName, addOn.getName());
    PatchableTarget.TargetInfo targetInfo = addOn.loadTargetInfo();
    assertEquals(BASE, targetInfo.getCumulativePatchID());
    assertTrue(targetInfo.getPatchIDs().isEmpty());
    DirectoryStructure directoryStructure = targetInfo.getDirectoryStructure();
    assertEquals(newFile(env.getModuleRoot(), "system", ADD_ONS, addOnName), directoryStructure.getModuleRoot());
    assertNull(directoryStructure.getBundleRepositoryRoot());
}
Also used : TestUtils.randomString(org.jboss.as.patching.runner.TestUtils.randomString) DirectoryStructure(org.jboss.as.patching.DirectoryStructure) Test(org.junit.Test)

Example 5 with DirectoryStructure

use of org.jboss.as.patching.DirectoryStructure in project wildfly-core by wildfly.

the class LayerTestCase method patchLayer.

@Test
public void patchLayer() throws Exception {
    // add a layer
    // randomString();
    String layerName = "mylayer";
    installLayers(layerName);
    InstalledIdentity installedIdentity = loadInstalledIdentity();
    // build a one-off patch for the layer with 1 added module
    // and 1 add file
    String patchID = randomString();
    File patchDir = mkdir(tempDir, patchID);
    // randomString();
    String layerPatchId = "mylayerPatchID";
    String moduleName = randomString();
    ContentModification moduleAdded = ContentModificationUtils.addModule(patchDir, layerPatchId, moduleName);
    ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh");
    Patch patch = PatchBuilder.create().setPatchId(patchID).oneOffPatchIdentity(installedIdentity.getIdentity().getName(), installedIdentity.getIdentity().getVersion()).getParent().oneOffPatchElement(layerPatchId, layerName, false).addContentModification(moduleAdded).getParent().addContentModification(fileAdded).build();
    createPatchXMLFile(patchDir, patch);
    File zippedPatch = createZippedPatchFile(patchDir, patchID);
    // apply patch
    PatchingResult result = executePatch(zippedPatch);
    assertPatchHasBeenApplied(result, patch);
    InstalledIdentity patchedInstalledIdentity = loadInstalledIdentity();
    assertInstallationIsPatched(patch, patchedInstalledIdentity.getIdentity().loadTargetInfo());
    assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName());
    DirectoryStructure layerDirStructure = installedIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure();
    File modulesPatchDir = layerDirStructure.getModulePatchDirectory(layerPatchId);
    assertDirExists(modulesPatchDir);
    assertDefinedModule(modulesPatchDir, moduleName, moduleAdded.getItem().getContentHash());
}
Also used : PatchingResult(org.jboss.as.patching.tool.PatchingResult) TestUtils.randomString(org.jboss.as.patching.runner.TestUtils.randomString) IoUtils.newFile(org.jboss.as.patching.IoUtils.newFile) TestUtils.createPatchXMLFile(org.jboss.as.patching.runner.TestUtils.createPatchXMLFile) File(java.io.File) TestUtils.createZippedPatchFile(org.jboss.as.patching.runner.TestUtils.createZippedPatchFile) ContentModification(org.jboss.as.patching.metadata.ContentModification) Patch(org.jboss.as.patching.metadata.Patch) DirectoryStructure(org.jboss.as.patching.DirectoryStructure) Test(org.junit.Test)

Aggregations

DirectoryStructure (org.jboss.as.patching.DirectoryStructure)16 File (java.io.File)8 Test (org.junit.Test)8 TestUtils.randomString (org.jboss.as.patching.runner.TestUtils.randomString)7 Patch (org.jboss.as.patching.metadata.Patch)6 IoUtils.newFile (org.jboss.as.patching.IoUtils.newFile)5 ContentModification (org.jboss.as.patching.metadata.ContentModification)5 TestUtils.createPatchXMLFile (org.jboss.as.patching.runner.TestUtils.createPatchXMLFile)5 TestUtils.createZippedPatchFile (org.jboss.as.patching.runner.TestUtils.createZippedPatchFile)5 PatchingResult (org.jboss.as.patching.tool.PatchingResult)5 InstalledImage (org.jboss.as.patching.installation.InstalledImage)2 LayerInfo (org.jboss.as.patching.installation.LayerInfo)2 PatchElement (org.jboss.as.patching.metadata.PatchElement)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)1 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)1 PatchElementProvider (org.jboss.as.patching.metadata.PatchElementProvider)1