mqtt_cpp icon indicating copy to clipboard operation
mqtt_cpp copied to clipboard

Enhanced testing

Open jonesmz opened this issue 5 years ago • 5 comments

I wanted to write down some of the problems that I've noticed we've had over the last several months. I think so far all of them have been fixed, but these are things that we never wrote additional tests for:

  1. Verifying that incoming packets are still processed after each packet type is sent, and each type is received. (e.g. #402)
  2. Verifying that all of the error cases that the mqtt_cpp codebase explicitly checks for behave as expected (e.g. boost asio claims X bytes are available, but then we only receive Y), in addition to all of the possible ways for malformed packets to be misinterpreted (though, I think there are several tests for this already).
  3. Various behaviors related to interrupted connections. For this we might use a "mock" boost::asio socket implementation. https://stackoverflow.com/questions/11254169/unit-testing-and-boostasio

Can you think of anything else that's not being handled by the current test coverage?

jonesmz avatar Oct 01 '19 20:10 jonesmz

  1. Call force_disconnect() from client/server side during the receiving packet is processing (for all state).
    • State means process_*() for MQTT packet and underlying TCP/TLS/WS state.
  2. MQTT reserved bit (they should be zero) might be not checked perfectly. (This might be a part of 2)

BTW, writing "mock" with Boost.Test, http://turtle.sourceforge.net/ https://github.com/mat007/turtle might be useful.

redboltz avatar Oct 01 '19 22:10 redboltz

Related to No.4,

https://github.com/redboltz/mqtt_cpp/blob/master/include/mqtt/endpoint.hpp#L6850-L6863 implementation is a result of many times try and error.

redboltz avatar Oct 01 '19 22:10 redboltz

I've used Turtle / Boost mock before. I enjoyed it. I think it would be a good tool to use.

jonesmz avatar Oct 01 '19 22:10 jonesmz

Nice! http://turtle.sourceforge.net/turtle/acknowledgements.html Takatoshi Kondo is me ;)

redboltz avatar Oct 01 '19 22:10 redboltz

Huh. You've been involved in a lot of stuff I've worked with over the years. Awesome :-)

jonesmz avatar Oct 01 '19 23:10 jonesmz