9

Before the update my MacBook Pro to MacOs Sierra, the command:

mvn clean install -U

took about 40 sec to run, with several hundreds of tests in several maven sub-modules.

After the update to MacOS Sierra, with no changes to the code, the same command takes over 12 minutes. It looks to me that the when the Surefire plugin is going to print the result of the current module, it hangs for 2-3 minutes before continuing. The speed of the test-execution up to this point is as fast as before the update to MacOS Sierra.

Example of a TestNG result printout from on of the modules:

Tests run: 101, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 167.854 sec

Results :

Tests run: 101, Failures: 0, Errors: 0, Skipped: 0

Does anyone know the reasons behind this?

Johan
  • 143
  • 1
  • 6
  • I am having everything in Java related to networking slower after updating. Launching a Spring app went from 26 seconds to 75 seconds. Another one went from 15 seconds to 150 seconds. My guess is it is related to networking based on what I am seeing, but not sure yet. – haskovec Sep 27 '16 at 20:26
  • 4
    The fix is here: http://stackoverflow.com/a/33289897/387927 – David Dossot Sep 28 '16 at 17:20
  • That does not solve it for me, the comment from David Dossot. Will come back with more info after I have done some more testing. – Johan Oct 03 '16 at 06:52

2 Answers2

35

I've had this exact problem (and spent the last 6 hours trying to solve it). My problem was that my HostName wasn't set.

Check that:

sudo scutil --get LocalHostName

Matches:

sudo scutil --get HostName

And if they don't, use:

sudo scutil --set HostName [YOUR_HOST_NAME]

To fix it.

Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157
Rich Riley
  • 366
  • 3
  • 5
  • Yes this solved my problem. But you made a slight typo. It should be "sudo scutil --set HostName [YOUR_HOST_NAME]" – Johan Oct 11 '16 at 05:57
  • 3
    This has been bugging me for months. THANKS! I'd love to know how you figured this out if you ever have time to write down your approach to troubleshooting this. – SkipKent Mar 13 '17 at 14:48
  • Thank you so much! Had a lot of struggles with this one! – Øystein W. Mar 22 '17 at 16:53
  • Thank you! So much wasted time waiting on tests could have been averted if I found this sooner.. – cjackson Jan 19 '18 at 23:00
  • Thank you so much! You can't imagine how much time this fix is going to save me :-D – Daniel Pecos Dec 28 '18 at 20:13
  • Thanks this just caught me up on a recent combination of surefire/testng. I'd be interested to know how you came across this solution as well. – Joseph Yaduvanshi Jan 12 '19 at 13:23
  • Thanks a lot for this, incredible difference after upgrade to MacOS 10.14 (Mojave) no HostName set `Running TestSuite Tests run: 332, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 192.406 sec - in TestSuite` HostName set `Running TestSuite Tests run: 332, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.23 sec - in TestSuite` I really need to dig into this. This seems like some major bug. – Bernhard Thalmayr Mar 01 '19 at 14:40
  • Weird stuff, just ran into this with a project I have been working on for 5 month. Suddenly 9min build time instead of 50secs. Thanks!! – kuhnroyal Mar 01 '21 at 21:55
0

In my case both LocalHostName and HostName were matching already. Also, I tried adding hostname in /etc/hosts as suggested in this thread http://stackoverflow.com/a/33289897/387927. Both have no impact on the time taken for the maven build.

The following was the output of mvn -version

Apache Maven 3.8.6
Maven home: /opt/homebrew/Cellar/maven/3.8.6/libexec
Java version: 11.0.12, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "11.6.x", arch: "aarch64", family: "mac"

But my os version is 12.5.1

I uninstalled and reinstalled java version 11.0.16. After this, the output of mvn -versionis as follows

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /opt/homebrew/Cellar/maven/3.8.6/libexec
Java version: 11.0.16, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.16.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "12.5.1", arch: "aarch64", family: "mac"

Then the build time was reduced from 9 minutes to 2 minutes.