Skip to content

Conversation

@Wumpf
Copy link
Member

@Wumpf Wumpf commented Aug 1, 2023

What

Adds a test dependency to the Catch2 testing framework in order to start testing all the new RecordingStream features added here.

C++ tests can be conveniently run via ./rerun_cpp/build_and_run_tests.sh now!

For quick api overview start with the rerun.h and recording_stream.h headers.

Fixes a range of compiler warnings as a consequence of improving some of the CMake setup, more to do there!
Adds lots more documentation to RecordingStream as well.

Next steps:

  • Add C++ to ci (linting, running this test suite)
  • Add roundtrip tests
  • Add codegen custom code injection
    • Improve API usability in varous places, including
  • Don't leak arrow headers into Rerun C++ API headers #2873
  • add other tests
  • serialize unions
  • serialize datatypes nested in unions, structs and lists
  • more testing & roundtripping

Checklist

@Wumpf Wumpf added the sdk-cpp C/C++ API specific label Aug 1, 2023
@Wumpf Wumpf force-pushed the andreas/cpp-api/better-recording-stream branch from 07edbc1 to 6a4e00b Compare August 1, 2023 14:14
@teh-cmc teh-cmc self-requested a review August 2, 2023 07:18
@teh-cmc
Copy link
Member

teh-cmc commented Aug 2, 2023

The tests fail for me:
image

Text version:

-------------------------------------------------------------------------------
Scenario: RecordingStream can log to file
       When: setting a global RecordingStream and then discarding it
      Given: the current recording stream
       Then: Saving the stream to a filebuild/test_output/test.rrd
       When: logging a component and then flushing
       Then: the file got bigger
-------------------------------------------------------------------------------
/home/cmc/dev/rerun-io/rerun/rerun_cpp/tests/recording_stream.cpp:177
...............................................................................

/home/cmc/dev/rerun-io/rerun/rerun_cpp/tests/recording_stream.cpp:178: FAILED:
  CHECK( fs::file_size(test_rrd) > file_size_before )
with expansion:
  232 > 232

-------------------------------------------------------------------------------
Scenario: RecordingStream can log to file
       When: setting a global RecordingStream and then discarding it
      Given: the current recording stream
       Then: Saving the stream to a filebuild/test_output/test.rrd
       When: logging an archetype and then flushing
       Then: the file got bigger
-------------------------------------------------------------------------------
/home/cmc/dev/rerun-io/rerun/rerun_cpp/tests/recording_stream.cpp:192
...............................................................................

/home/cmc/dev/rerun-io/rerun/rerun_cpp/tests/recording_stream.cpp:193: FAILED:
  CHECK( fs::file_size(test_rrd) > file_size_before )
with expansion:
  232 > 232

[2023-08-02T07:51:49Z WARN  re_sdk_comms::buffered_client] Dropping messages because tcp client has timed out.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::buffered_client] Dropping messages because tcp client has timed out.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::buffered_client] Dropping messages because tcp client has timed out or quitting.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.
===============================================================================
test cases:  5 | 4 passed | 1 failed
assertions: 10 | 8 passed | 2 failed

[2023-08-02T07:51:49Z WARN  re_sdk_comms::tcp_client] Tried to flush while TCP stream was still Pending. Data was possibly dropped.

@Wumpf
Copy link
Member Author

Wumpf commented Aug 2, 2023

uhoh. May or may not be file system delay. I left a comment in there that the test may be dangerous
We'll need to look into it

@Wumpf Wumpf added the do-not-merge Do not merge this PR label Aug 2, 2023
Copy link
Member

@teh-cmc teh-cmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely based 🙇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of expect() calls all over this module 😬

I know this was done so in the interest of development speed, but it feels like it's time to address this before it gets more complicated.
Most of those can probably be replaced by a simple error!(blabla); return void; kinda thing (and I guess we need a constant for RERUN_REC_STREAM_INIT_FAILED?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think we want a large error enum in the API. I'll do a follow-up with that!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what emil prototyped so far he added a log library to C++, but I find it less and less useful actually. I'd rather have everything return an error instead of relying on an extra library.
That's somewhat related to not leaking arrow stuff too much: C++ should get its own result type where we use our own "Rerun C++ error"-type

@Wumpf Wumpf force-pushed the andreas/cpp-api/better-recording-stream branch from 6a4e00b to dbe2724 Compare August 2, 2023 14:33
Copy link
Member

@teh-cmc teh-cmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

👍 Really like the new testing approach.

I do not like that we rely on fs metadata to compare file sizes though, but 🤷‍♂️

THEN("after destruction, the second stream produced a bigger file") {
stream0.reset();
stream1.reset();
CHECK(fs::file_size(test_rrd0) < fs::file_size(test_rrd1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using file metadata is asking for flakiness imo

@Wumpf Wumpf removed the do-not-merge Do not merge this PR label Aug 2, 2023
@Wumpf Wumpf force-pushed the andreas/cpp-api/better-recording-stream branch from c626ee7 to 6bdbd12 Compare August 2, 2023 15:57
@Wumpf Wumpf merged commit 09653f0 into main Aug 2, 2023
@Wumpf Wumpf deleted the andreas/cpp-api/better-recording-stream branch August 2, 2023 16:14
Wumpf added a commit that referenced this pull request Aug 3, 2023
* Fixes  #2662

### What

* Runs clang-format to check for unformatted files
* Builds and runs the minimal example
* Builds and runs rerun_sdk tests

Docker image script was in a broken state, fixed it and updated the
image everywhere.

Do not under any circumstances review commit per commit 😉 (srsly the
history is messed up)

TODO:
* [x] check if overall ci goes green
* [x] break both ci jobs on purpose (already did compile failures, try
actual test failure instead
* [x] fix it again (duh ;))

Future todo:
* #2903
* todos from #2890
* cache C++ build results?


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2901) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2901)
- [Docs preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp%2Fci/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp%2Fci/examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk-cpp C/C++ API specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants