Failed to establish a connection to the test generation service

When I try and use the “write tests” menu item, all I get is the following output in the event log:

12:24	4 private methods found: Tests cannot be generated for <REDACTED>

12:24	Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:createMockableJar, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources, :app:compileDebugSources] in project C:\code\work\<REDACTED>

12:25	Gradle build finished in 30 s 718 ms

12:25	Commencing test creation: Analyzing 5 methods in total

12:25	Failed to establish a connection to the test generation service.: Please submit an error report with a detailed description of what you were doing before the error

Thanks @evaluser could you give us a few more details about your environment? i.e. what version of IntelliJ, Java, what version of windows, are you behind a firewall?
Many thanks! Andy

Hi @evaluser one thing to check - we talk to the test generation service on localhost are you able to ping localhost on your machine?

Windows 10
Java --version from the command line returns me openjdk 14.0.1 2020-04-14 - I have no idea if IntelliJ uses a different version
IntelliJ Community 2020.2, clean install installed just to try out DiffBlue (I normally use Android Studio)
Project is an Android app, set to compile for Java 8

Ping to localhost works fine from a command line -

Reply from ::1: time=1ms
Reply from ::1: time<1ms
Reply from ::1: time=1ms
Reply from ::1: time=1ms

Ping statistics for ::1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

I’m sure there are numerous firewalls in the network setup, but none should affect localhost. PC has an always on VPN.

Thanks for the update!
I suspect this is something to do with the networking setup - I have seen VPNs cause loopback issues for instance. I’ll have to consult the team and figure out how to move you forward as it’s not obvious (to me at least) how we can diagnose this.

Thanks for your feedback and updates @evaluser - I notice that your ping command and/or network stack has picked an IPv6 loopback address - do you also have an IPv4 loopback address (typically 127.0.0.1), or is your machine IPv6 only?

Hi, are you able to run the following java program on your machine and tell us what it returns?

import java.net.*;

public class SocketTest {
  public static void main(String args[]) {
    InetSocketAddress isa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
    System.out.println(isa);
  }
}

Thanks!

C:\temp>java -cp . SocketTest
localhost/127.0.0.1:0

C:\temp>ping localhost

Pinging <REDACTED> [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\temp>ping -4 localhost

Pinging <REDACTED> [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

None of the last set of output I submitted changes if I turn off my VPN.

Many thanks for the extra information @evaluser - we really appreciate this feedback. You mentioned that the ping tests don’t change if you turn off your VPN - does Cover give you the same “Failed to establish a connection to the test generation service” if your VPN is turned off? I’m just wondering if your VPN is re-routing/blocking traffic for localhost…

Sure I replied to this before, but can’t see the post now.

There is no difference to the behaviour I see whether my VPN is active or not - I still get told “Failed to establish a connection to the test generation service”

Hi @evaluser. Would it be possible for you to join a Zoom call so that we can investigate this further? If so, please suggest some times and I will arrange it for a mutually suitable time. Thanks

What are you hoping to achieve in a Zoom call? If what you mean is can you take control of my machine, to try and debug it whilst I just wait around, then no. I normally run Android Studio - it is a considerable inconvenience to switch to plain IntelliJ. Does the system not write any diags to allow you to see what is happening, or is the “Failed to establish a connection to the test generation service” the only output that you have to go on?

@evaluser the aim for a Zoom call was to hopefully get you a quicker resolution to the issue you’ve seen. With the information you’ve provided already, it has been possible to reproduce this behaviour. Our developers are currently working on a fix for that, and will upload a new version when it becomes available.

1 Like

Thanks for the explanation - that sounds more promissing than the “zoom call so we can investigate this further” lead me to believe. I’ll hang on for the new version.

I see that you have released an updated version of the plugin, where the release note claims to have fixed the problem about contacting the test generation service.

I’ve updated the plugin, and restarted the IDE. The plugins page reports that I now have version 2020.090.02-eval installed.

However trying to create some tests still gives me the same error:

16:31 Commencing test creation: Analyzing 50 methods in total

16:32 Failed to establish a connection to the test generation service.: Please submit an error report with a detailed description of what you were doing before the error

Seeing as you think this is something to do with ipv6, I have reconfigured my system so that it prefers ipv4 over ipv6. Now localhost resolves to 127.0.0.1, but I still get the same unable to connect message.

Do you run the plugin on WIndows, or am I trying something you have never tested before?

A quick question: You seem to be running IntelliJ using Java 14 JDK? This would be an untested and unsupported configuration. Would you be able to retry with Java 11?

Many thanks for your continued help with debugging this! We do indeed run the plugin on Windows (several of our developers are Windows-only, as well as some of our commercial users) so we are trying to determine what is different between your environment and other Windows environments where we successfully run.

Do you run any kind of firewalling/security/intrusion detection software on your Windows computer, and if so, do you know if it is configured to block connections over the loopback addresses?

Hello.

I have the same problem. It gives the same message in IDEA after hanging for a while.

I am using 1.8 jdk and latest IDEA
java -version
java version “1.8.0_221”
Java™ SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot™ Client VM (build 25.221-b11, mixed mode)

loopback address set to 127.0.0.1 no extra firewalls or anything no VPN as well.