Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-2180

Copy across undeploy's deleteIfExists+deleteOnExit to !isDeployTypeXml (Dropins deployment)

XMLWordPrintable

    • Hide

      Lots and lots and lots of undeploys of dropped in applications using the Arquillian Liberty container in the Open Liberty Simplicity Test Framework.

      Show
      Lots and lots and lots of undeploys of dropped in applications using the Arquillian Liberty container in the Open Liberty Simplicity Test Framework.

      We sometimes see a timing issue with undeploy which looks like it has already been addressed if isDeployTypeXml==true but most of our tests use the dropin deploy method. I mirrored the code over with:

      public void undeploy(final Archive<?> archive) throws DeploymentException {
      if (log.isLoggable(Level.FINER))

      { log.entering(className, "undeploy"); }

      String archiveName = archive.getName();
      String deployName = createDeploymentName(archiveName);
      String deployDir = null;

      // IBM expedient patch for FAT test problems this was just done to prevent it
      // having to be added to each arquillian.xml it would not be part of the PR
      containerConfiguration.setFailSafeUndeployment(true);

      try {
      // If deploy type is xml, then remove the application from the xml file, which
      // causes undeploy
      if (containerConfiguration.isDeployTypeXML())

      { // Read the server.xml file into Memory Document document = readServerXML(); // Remove the archive from the server.xml file removeApplication(document, deployName); removeActivationSpecJmsQueueJmsTopic(document); // Update server.xml on file system writeServerXML(document); // Wait until the application is undeployed waitForApplicationTargetState(deployName, false, this.containerConfiguration.getAppUndeployTimeout()); }

      // Now we can proceed and delete the archive for either deploy type
      if (containerConfiguration.isDeployTypeXML())

      { deployDir = getAppDirectory(); }

      else

      { deployDir = getDropInDirectory(); }

      // Remove the deployed archive
      File exportedArchiveLocation = new File(deployDir, archiveName);
      if (!containerConfiguration.isFailSafeUndeployment()) {
      try {
      if (!Files.deleteIfExists(exportedArchiveLocation.toPath()))

      { throw new DeploymentException("Archive already deleted from deployment directory"); }

      } catch (IOException e)

      { throw new DeploymentException("Unable to delete archive from deployment directory", e); }

      } else {
      try

      { Files.deleteIfExists(exportedArchiveLocation.toPath()); }

      catch (IOException e)

      { log.log(Level.WARNING, "Unable to delete archive from deployment directory -> failsafe -> file marked for delete on exit", e); exportedArchiveLocation.deleteOnExit(); }

      }

      // If it was the archive deletion that caused the undeploy we wait for the
      // correct state
      if (!containerConfiguration.isDeployTypeXML())

      { // Wait until the application is undeployed waitForApplicationTargetState(deployName, false, this.containerConfiguration.getAppUndeployTimeout()); }

      } catch (Exception e)

      { throw new DeploymentException("Exception while undeploying application.", e); }

      if (log.isLoggable(Level.FINER))

      { log.exiting(className, "undeploy"); }

      }

      I will now do a PR with the above (minus the containerConfiguration.setFailSafeUndeployment(true);
      line.)

              gpoul_jira Gerhard Poul (Inactive)
              GordonHutchison Gordon Hutchison (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: