Suppressed: java.nio.file.FileSystemException: C:\Users\Cliff\AppData\Local\Temp\junit1581269591057766963\TestingComplexObsSaving_9064e534-7f4b-45be-b266-a78bd131b7fb.mp3: The process cannot access the file because it is being used by another process.
that something is holding on to the file/stream in these 2 tests that are failing. So either its our test that needs to close them or the implementation has a bug that hasn’t been detected. I will investigate further. I will ask @gcliff to try again as soon as I have changed things. Thank you for letting us know
Out of curiosity whats in the temp dir that cannot be deleted by JUnit? The one it shows when the test fails C:\Users\Cliff\AppData\Local\Temp\junit3772331837415344270
And is there any difference when you run this from your IDE?
with FileCopyUtils.copy(in, out); with import import org.springframework.util.FileCopyUtils;
The FileCopyUtils from Spring closes the in and outputstream.
I would be interested if that is solving it. Then we should have closed all stream/handles on the files JUnit wants to delete. At least that is my hope
if anyone has a good idea how we can figure out what is holding a reference to these temporary files that are created during the tests. please let me know
@gcliff I meant what is inside the folders. I am assuming the mp3 files created during the test.
I will disable the tests on Windows using @achilep proposal for now. The tests will still run in all our pipelines which ensures the behavior of the code will not change. In the meantime I will try to replicate your environment and the errors you are seeing. So that I can investigate more easily and look for a fix
This will be hard
So @gcliff my research tells me you run Windows 7, correct?
I was able to run the tests inside a Microsoft provided docker image with JDK8 https://hub.docker.com/_/microsoft-java-jdk but I assume that was naive since that is most likely very different from actual Windows since its meant for deploying things to Azure.
for the curious this is what you do
docker pull mcr.microsoft.com/java/maven:8-zulu-debian9
docker run -it --name windows -v ~/.m2:/root/.m2 -v ~/code/openmrs/openmrs-core:/code --workdir /code mcr.microsoft.com/java/maven:8-zulu-debian9 sh
mvn clean test -Dtest=BinaryStreamHandlerTest,MediaHandlerTest
I will most likely need to setup a VM. Not sure yet if I can get a Windows 7.
Just to point this out, you’ve actually pulled a Microsoft-provided Debian image, which really doesn’t help with the Windows-specific file handling issue. The minimal Windows image seems to be called 8-zulu-windowsservercore…
They’re generated here in the BaseContextSensitiveTest class which means that we generate probably 200ish directories per Maven build. They should be deleted on exit, but apparently some aren’t. Although I don’t get the exception you’re reporting on my machine (I use a Mac), I do see a number of those appdir-for-unit-tests- directories piled up in my temporary files location. When I clean the temp directory and re-run the tests, I end up with 11 hanging appdir-for-unit-tests- directories.
Thanks at @ibacher, if you remove the @DisabledOnOs(WINDOWS) flag on for example the MediaHandlerTest does it fail telling you the Jupiter Extension could not delete the temp dir because some other process was holding on to things in there (like in @gcliff logs)?
Can you @ibacher and @gcliff please run the MediaHandlerTest and BinaryStreamHandlerTest (remove the @DisabledOn) and let me know if that changes anything?