WebUI not passing unitary tests
Reporters
- Lluis Gifre (CTTC)
Description
WebUI not passing unitary tests with error DNS resolution failed for contextservice:1010
.
Seems issue with name resolution when running in Docker.
Try adding explicit environment variables in unitary test for Mock Context, Device, ... components.
___________________ TestWebUI.test_device_add_action_success ___________________
self = <context.client.ContextClient.ContextClient object at 0x7efc299285b0>
args = (,), kwargs = {}
prepare_method = <bound method ContextClient.connect of <context.client.ContextClient.ContextClient object at 0x7efc299285b0>>
num_try = 16, given_up = True, delay = 163.84
def wrapper(self, *args, **kwargs):
if prepare_method_name is not None:
prepare_method = getattr(self, prepare_method_name, None)
if prepare_method is None: raise Exception('Prepare Method ({}) not found'.format(prepare_method_name))
num_try, given_up = 0, False
while not given_up:
try:
> return func(self, *args, **kwargs)
common/tools/client/RetryDecorator.py:75:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <context.client.ContextClient.ContextClient object at 0x7efc299285b0>
request =
@RETRY_DECORATOR
def ListContextIds(self, request: Empty) -> ContextIdList:
LOGGER.debug('ListContextIds request: {:s}'.format(grpc_message_to_json_string(request)))
> response = self.stub.ListContextIds(request)
context/client/ContextClient.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <grpc._channel._UnaryUnaryMultiCallable object at 0x7efc287455e0>
request = , timeout = None, metadata = None, credentials = None
wait_for_ready = None, compression = None
def __call__(self,
request,
timeout=None,
metadata=None,
credentials=None,
wait_for_ready=None,
compression=None):
state, call, = self._blocking(request, timeout, metadata, credentials,
wait_for_ready, compression)
> return _end_unary_response_blocking(state, call, False, None)
../venv/lib/python3.9/site-packages/grpc/_channel.py:946:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
state = <grpc._channel._RPCState object at 0x7efc298afd60>
call = <grpc._cython.cygrpc.SegregatedCall object at 0x7efc28701680>
with_call = False, deadline = None
def _end_unary_response_blocking(state, call, with_call, deadline):
if state.code is grpc.StatusCode.OK:
if with_call:
rendezvous = _MultiThreadedRendezvous(state, call, None, deadline)
return state.response, rendezvous
else:
return state.response
else:
> raise _InactiveRpcError(state)
E grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
E status = StatusCode.UNAVAILABLE
E details = "DNS resolution failed for contextservice:1010: C-ares status is not ARES_SUCCESS qtype=A name=contextservice is_balancer=0: Could not contact DNS servers"
E debug_error_string = "{"created":"@1669214328.710536758","description":"DNS resolution failed for contextservice:1010: C-ares status is not ARES_SUCCESS qtype=A name=contextservice is_balancer=0: Could not contact DNS servers","file":"src/core/lib/transport/error_utils.cc","file_line":167,"grpc_status":14}"
E >
../venv/lib/python3.9/site-packages/grpc/_channel.py:849: _InactiveRpcError
The above exception was the direct cause of the following exception:
self = <webui.tests.test_unitary.TestWebUI testMethod=test_device_add_action_success>
client = <FlaskClient <Flask 'webui.service'>>
def test_device_add_action_success(self, client) -> None:
with client.session_transaction() as sess:
sess['context_uuid'] = 'admin'
DEVICE_EMU = {
'device_id': 'EMULATED',
'device_type': DeviceTypeEnum.EMULATED_PACKET_ROUTER.value,
'device_config': '',
'operational_status': 1,
'device_drivers': 0,
'device_endpoints': [],
}
> rv = client.post('/device/add', data=DEVICE_EMU, follow_redirects=True)