protected void rollbackAllPatches() throws Exception {
   // rollback all installed patches
   final boolean success = CliUtilsForPatching.rollbackAll();
   boolean ok = false;
   try {
     if (!success) {
       Assert.fail("failed to rollback all patches " + CliUtilsForPatching.info(false));
     }
     assertPatchElements(new File(MODULES_PATH), null);
     ok = true;
   } finally {
     if (!ok) {
       // Reset installation state
       final File home = new File(PatchingTestUtil.AS_DISTRIBUTION);
       PatchingTestUtil.resetInstallationState(home, BASE_MODULE_DIRECTORY);
     }
   }
 }
Example #2
0
  /**
   * creates 4 CPs creates bundle containing 4 CPs applies bundle rollbacks CP one by one
   *
   * @throws Exception
   */
  @Test
  public void testApplyBundle() throws Exception {
    final String bundleName = "bundle_" + randomString();
    File patchBundleDir = mkdir(tempDir, bundleName);

    final String cpPatchID = randomString();
    final String cpPatchID2 = randomString();
    final String cpPatchID3 = randomString();
    final String cpPatchID4 = randomString();
    final String eapWithCP = "EAP with cp patch";
    final String eapWithCP2 = "EAP with cp patch 2";
    final String eapWithCP3 = "EAP with cp patch 3";
    final String eapWithCP4 = "EAP with cp patch 4";

    List<BundledPatch.BundledPatchEntry> patches = new ArrayList<BundledPatch.BundledPatchEntry>();

    File cpZip =
        createCumulativePatchAddingARandomModule(cpPatchID, AS_VERSION, eapWithCP, patchBundleDir);
    patches.add(new BundledPatch.BundledPatchEntry(cpPatchID, cpZip.getName()));
    File cpZip2 =
        createNextCumulativePatchAddingRandomModule(
            cpPatchID2, eapWithCP, cpPatchID, eapWithCP2, patchBundleDir);
    patches.add(new BundledPatch.BundledPatchEntry(cpPatchID2, cpZip2.getName()));
    File cpZip3 =
        createNextCumulativePatchModyfyingJbossModules(
            cpPatchID3, eapWithCP2, cpPatchID2, eapWithCP3, patchBundleDir);
    patches.add(new BundledPatch.BundledPatchEntry(cpPatchID3, cpZip3.getName()));
    File cpZip4 =
        createNextCumulativePatchAddingRandomModule(
            cpPatchID4, eapWithCP3, cpPatchID3, eapWithCP4, patchBundleDir);
    patches.add(new BundledPatch.BundledPatchEntry(cpPatchID4, cpZip4.getName()));

    createPatchBundleXMLFile(patchBundleDir, patches);
    File patchBundleZip = createZippedPatchFile(patchBundleDir, bundleName);

    // apply bundle
    controller.start(CONTAINER);
    Assert.assertTrue(
        "Patch should be accepted",
        CliUtilsForPatching.applyPatch(patchBundleZip.getAbsolutePath()));
    Assert.assertTrue(
        "server should be in restart-required mode",
        CliUtilsForPatching.doesServerRequireRestart());
    controller.stop(CONTAINER);

    // verify cp version and rollback cp4
    controller.start(CONTAINER);
    Assert.assertTrue(
        "The patch " + cpPatchID4 + " should be listed as installed",
        CliUtilsForPatching.getCumulativePatchId().equalsIgnoreCase(cpPatchID4));
    Assert.assertTrue(
        "Rollback should be accepted", CliUtilsForPatching.rollbackCumulativePatch(true));
    Assert.assertTrue(
        "server should be in restart-required mode",
        CliUtilsForPatching.doesServerRequireRestart());
    controller.stop(CONTAINER);

    // verify cp version and rollback cp4
    controller.start(CONTAINER);
    Assert.assertTrue(
        "The patch " + cpPatchID3 + " should be listed as installed",
        CliUtilsForPatching.getCumulativePatchId().equalsIgnoreCase(cpPatchID3));
    Assert.assertTrue(
        "Rollback should be accepted", CliUtilsForPatching.rollbackCumulativePatch(true));
    Assert.assertTrue(
        "server should be in restart-required mode",
        CliUtilsForPatching.doesServerRequireRestart());
    controller.stop(CONTAINER);

    // verify cp version and rollback cp2
    controller.start(CONTAINER);
    Assert.assertTrue(
        "The patch " + cpPatchID2 + " should be listed as installed",
        CliUtilsForPatching.getCumulativePatchId().equalsIgnoreCase(cpPatchID2));
    Assert.assertTrue(
        "Rollback should be accepted", CliUtilsForPatching.rollbackCumulativePatch(true));
    Assert.assertTrue(
        "server should be in restart-required mode",
        CliUtilsForPatching.doesServerRequireRestart());
    controller.stop(CONTAINER);

    // verify cp version and rollback cp
    controller.start(CONTAINER);
    Assert.assertTrue(
        "The patch " + cpPatchID + " should be listed as installed",
        CliUtilsForPatching.getCumulativePatchId().equalsIgnoreCase(cpPatchID));
    Assert.assertTrue(
        "Rollback should be accepted", CliUtilsForPatching.rollbackCumulativePatch(true));
    Assert.assertTrue(
        "server should be in restart-required mode",
        CliUtilsForPatching.doesServerRequireRestart());
    controller.stop(CONTAINER);

    // verify base
    controller.start(CONTAINER);
    Assert.assertTrue(
        "The patch " + Constants.BASE + " should be listed as installed",
        CliUtilsForPatching.getCumulativePatchId().equalsIgnoreCase(Constants.BASE));
    controller.stop(CONTAINER);
  }