inmanta / nfv-test-api

API for testing network functions using network namespaces (archived)
https://code.inmanta.com/solutions/tools/nfv-test-api
3 stars 0 forks source link

[V2] Ping raise 500 if no ping went through #30

Closed edvgui closed 3 years ago

edvgui commented 3 years ago

This error happen when no ping can go though

Failed to parse ping response: {'destination': '7.2.138.2', 'packet_transmit': 4, 'packet_receive': 0, 'packet_loss_count': 4, 'packet_loss_rate': 100.0, 'rtt_min': None, 'rtt_avg': None, 'rtt_max': None, 'rtt_mdev': None, 'packet_duplicate_count': 0, 'packet_duplicate_rate': None}
[2021-10-19 09:20:20,370] ERROR in app: Exception on /api/v2/actions/ping [POST]
Traceback (most recent call last):
  File "/home/user/nfv-test-api/env/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/user/nfv-test-api/env/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/user/nfv-test-api/env/lib/python3.6/site-packages/flask_restplus/api.py", line 325, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/user/nfv-test-api/env/lib/python3.6/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/user/nfv-test-api/env/lib/python3.6/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/user/nfv-test-api/src/nfv_test_api/v2/controllers/actions.py", line 73, in post
    return self.get_service(ns_name).ping(request_form).json_dict(), HTTPStatus.OK
  File "/home/user/nfv-test-api/src/nfv_test_api/v2/services/actions.py", line 54, in ping
    raise e
  File "/home/user/nfv-test-api/src/nfv_test_api/v2/services/actions.py", line 51, in ping
    return Ping(**ping_result)
  File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 5 validation errors for Ping
packetduplicaterate
  none is not an allowed value (type=type_error.none.not_allowed)
rttavg
  none is not an allowed value (type=type_error.none.not_allowed)
rttmax
  none is not an allowed value (type=type_error.none.not_allowed)
rttmdev
  none is not an allowed value (type=type_error.none.not_allowed)
rttmin
  none is not an allowed value (type=type_error.none.not_allowed)

We should accept None values for rttavg, rttmax, rttmdev, rttmin and packetduplicaterate