'Helper method to solve automated testing issues within Jenkins.
Officially patched under the 2.0 branch through
17998ef72a2fe2e67d27dd602b6ced33a58ad8ef, but left as is for the
1.0 branch due to possible regressions for fixing an
automated testing edge-case.'

def get_connection(self, timeout=5):

    conn = None
    e = None
    for i in range(5):
        try:
            contact_point = CASSANDRA_IP
            conn = self.klass.factory(host=contact_point, timeout=timeout, protocol_version=PROTOCOL_VERSION)
            break
        except (OperationTimedOut, NoHostAvailable, ConnectionShutdown) as e:
            continue
    if conn:
        return conn
    else:
        raise e
