Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run unit tests in Bluemix Build & Deploy Pipeline because the servers can't connect to ClearDB MySQL

SOLVED!

Looks like the pipeline service in Bluemix has been updated, the connection to ClearDB works beautifully now! Thanks to whoever pushed that change! :)

--

I am running the code within the Bluemix build & Deploy pipeline, NOT inside the Liberty Profile app server (the application works fine there), the problem lies on the BUILD Stage of the Pipeline (mvn clean install) while running my Unit Tests, here's the error message

Building new Hibernate SessionFactory 2015-04-11 15:04:49 [main] ERROR o.h.util.JDBCExceptionReporter - Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

The Unit Test classes can't connect to the database.

My code doesn't have anything special, you can create any standard JDBC Connection in a JUnit Test class and try to establish connection with the db, but if you want to easily confirm this connectivity limitation, here's how you can test this without any Java code:

  • Create a Liberty Profile app with some Starter Code
  • Create and bind the "ClearDB MySQL" service to it
  • In the App Overview page, expand the ClearDB box by clicking on "Show Credentials" and copy the hostname (e.g., us-cdbr-test-west-07.cleardb.net).
  • Add GIT, back to the App Overview, click on EDIT CODE, Click on "Build & Deploy", click on the configuration icon of the "BUILD Stage", select "Configure Stage" and add the following code to the command box:

code

REMOTEHOST=us-cdbr-test-west-07.cleardb.net
REMOTEPORT=3306
TIMEOUT=1
    
if nc -w $TIMEOUT -z $REMOTEHOST $REMOTEPORT; then
    echo "I was able to connect to ${REMOTEHOST}:${REMOTEPORT}"
else
    echo "Connection to ${REMOTEHOST}:${REMOTEPORT} failed; exit code from netcat was $?"
fi
  • Start the BUILD Stage and check if this message shows up:
[86d18f86-4ade-4e02-8282-171dc9757272] $ /bin/bash /tmp/hudson5506792757013948518.sh
Connection to us-cdbr-test-west-07.cleardb.net:3306 failed; exit code from netcat was 1

Please let know if there's a way to configure the pipeline so it can communicate with ClearDB.

like image 840
the_marcelo_r Avatar asked Apr 13 '15 13:04

the_marcelo_r


1 Answers

There has been an update to the pipeline service in Bluemix, which has fixed this bug. Connections to the "ClearDB" service should now be working.

like image 139
James Thomas Avatar answered Oct 03 '22 05:10

James Thomas