javiertuya/selema

Regression: All Java updates fail a test when reading log file

Closed this issue · 2 comments

Failure trace is the same for all builds, at the first test

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running test4giis.selema.junit5.TestLifecycle5WithoutManager
Error:  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.096 s <<< FAILURE! -- in test4giis.selema.junit5.TestLifecycle5WithoutManager
Error:  test4giis.selema.junit5.TestLifecycle5WithoutManager -- Time elapsed: 0.096 s <<< ERROR!
giis.portable.util.PortableException: Error reading file /home/runner/work/selema/selema/java/target/selema/selema-log.html
	at giis.portable.util.FileUtil.fileReadLines(FileUtil.java:54)
	at test4giis.selema.core.LogReader.getLogSize(LogReader.java:29)
	at test4giis.selema.junit5.TestLifecycle5WithoutManager.setUpClass(TestLifecycle5WithoutManager.java:22)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	Suppressed: giis.portable.util.PortableException: Error reading file /home/runner/work/selema/selema/java/target/selema/selema-log.html
		at giis.portable.util.FileUtil.fileReadLines(FileUtil.java:54)
		at test4giis.selema.core.LogReader.getLogSize(LogReader.java:29)
		at test4giis.selema.junit5.TestLifecycle5WithoutManager.afterTearDown(TestLifecycle5WithoutManager.java:35)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
		at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085)
		... 1 more
	Caused by: java.nio.file.NoSuchFileException: /home/runner/work/selema/selema/java/target/selema/selema-log.html
		at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
		at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
		at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
		at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
		at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
		at java.base/java.nio.file.Files.newByteChannel(Files.java:422)
		at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
		at java.base/java.nio.file.Files.newInputStream(Files.java:156)
		at java.base/java.nio.file.Files.newBufferedReader(Files.java:28[39](https://github.com/javiertuya/selema/actions/runs/6583512096/job/17886666891#step:10:40))
		at java.base/java.nio.file.Files.readAllLines(Files.java:3330)
		at org.apache.commons.io.FileUtils.readLines(FileUtils.java:2668)
		at org.apache.commons.io.FileUtils.readLines(FileUtils.java:2686)
		at giis.portable.util.FileUtil.fileReadLines(FileUtil.java:[52](https://github.com/javiertuya/selema/actions/runs/6583512096/job/17886666891#step:10:53))
		... 6 more

No changes in code and dependencies from last run. The only uncontrolled version is the OS:

  • The runner image (ubuntu-latest) changed from latest build: actions/runner-images#8577.
  • Still using ubuntu 22.04.3 LTS buth kernel was updated from 6.2.0-1012-azure to 6.2.0-1014-azure
  • Checkked that running with ubuntu-20.04 works and with ubuntu-latest doesn't. What is the root cause?

I guess that there is anything introduced by the OS tha triggers the issue.

Root cause found:

  • The new ubuntu image leads to a different test order that sets `TestLifecycle5WithoutManager' as the first test
  • This is the only test that the only that does is to check that no lines have been added to the selema log
  • But because is the firts test, the log file has not been created yet and raises the exception

Solution:

  • Check the exception to assume that log is empty when the log file does not exist