Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-409

Random failing unit test NQueensBenchmarkTest vs BrokenNQueensBenchmarkTest

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 6.3.0.CR2
    • 6.2.0.Final
    • optaplanner-examples
    • None
    • NEW
    • NEW

      This happens if those 2 tests are run in the exact same second:
      BrokenNQueensBenchmarkTest
      NQueensBenchmarkTest
      because they want to create the exact same benchmark directory (which uses a timestamp by default) and the second on fails because it already exists.

      java.lang.IllegalArgumentException: The benchmarkReportDirectory (target/test/data/nqueens/2015-08-21_115205) creation failed. It probably already exists.
      	at org.optaplanner.benchmark.impl.result.PlannerBenchmarkResult.initBenchmarkReportDirectory(PlannerBenchmarkResult.java:233)
      	at org.optaplanner.benchmark.impl.PlannerBenchmarkRunner.initBenchmarkDirectoryAndSubdirs(PlannerBenchmarkRunner.java:126)
      	at org.optaplanner.benchmark.impl.PlannerBenchmarkRunner.benchmarkingStarted(PlannerBenchmarkRunner.java:110)
      	at org.optaplanner.benchmark.impl.PlannerBenchmarkRunner.benchmark(PlannerBenchmarkRunner.java:93)
      	at org.optaplanner.examples.common.app.PlannerBenchmarkTest.runBenchmarkTest(PlannerBenchmarkTest.java:53)
      	at org.optaplanner.examples.nqueens.app.NQueensBenchmarkTest.benchmark64queens(NQueensBenchmarkTest.java:37)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
      

      Solution proposal A:
      PlannerBenchmarkResult#initBenchmarkReportDirectory must not fail if a directory already exists, instead it must suffix it with "_1" and try that. If that also already exists, it must try "_2" etc etc.
      Pitfall: make sure to understand the difference between mkdir() and mkdirs().

            oskopek Ondrej Skopek (Inactive)
            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: