def test_09_dig_consul_command(self): print "Test_09_dig_consul_command_Start:------------------" t0 = time.time() try: # start all containers print "Start all containers..." self._start_all_containers() print "Waiting for all containers to be ready ..." time.sleep(10) rc = verify_all_services_healthy(LOCAL_CONSUL) if not rc: print "Not all services are up" self.assertEqual(rc, True) # Get the IP address(es) for voltha's REST interface print "Get IP of Voltha REST interface..." cmd = command_defs['consul_get_voltha_rest_a_record'] out, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0) self.assertGreaterEqual(out.find("voltha-health.service.consul"), 0) # Get only the ip address cmd = command_defs['consul_get_voltha_rest_ip'] ip, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0) self.assertTrue(is_valid_ip(ip)) # Get the exposed service port print "Get Voltha exposed service port..." cmd = command_defs['consul_get_voltha_service_port'] port, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0) # Verify that we can connect to the port using the previously # acquired ip print "Verify connectivity with voltha ip and port..." self.assertTrue(is_open('{}:{}'.format(ip, port))) finally: print "Stopping all containers ..." # clean up all created containers for this test self._stop_and_remove_all_containers() print "Test_09_dig_consul_command_Start_End:------------------" \ "took {} secs \n\n".format(time.time() - t0)