]
Gerhard Poul updated ARQ-2180:
------------------------------
Status: Resolved (was: Pull Request Sent)
Fix Version/s: was_1.0.0.next
Resolution: Done
Copy across undeploy's deleteIfExists+deleteOnExit to
!isDeployTypeXml (Dropins deployment)
-------------------------------------------------------------------------------------------
Key: ARQ-2180
URL:
https://issues.jboss.org/browse/ARQ-2180
Project: Arquillian
Issue Type: Bug
Components: WebSphere Containers
Affects Versions: 1.4.0.Final
Environment: Websphere Liberty FAT test buckets such as
https://github.com/OpenLiberty/open-liberty/tree/integration/dev/com.ibm....
Reporter: Gordon Hutchison
Assignee: Gerhard Poul
Priority: Minor
Fix For: was_1.0.0.next
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.)