HW2 unit tests and some tips

HW2 unit tests and some tips

by Kirill Nikitin -
Number of replies: 0

Dear students,

You should find the unit tests for Homework 2 in the master branch of your repositories. The tests validate the correctness of the download and search behavior of your implementations. Let us know if you spot any errors!

In addition, we have made a few changes required for the tests and these changes are also in the commit. Specifically, we have

  1. Added the `RemoveChunkFromLocal` method to the interface which you need to implement. It is supposed to remove file chunks from the index of your gossiper, and we need it to verify that your gossiper downloads correctly when a file is split among multiple nodes.
  2. Removed the logic of substituting zero budget of a search query with budget of 2 in the controller. This logic should exist in the backend, instead.

A couple of tips that can save you debugging time:

  1. If, when running tests, you get the error that your gossiper is unable to write to the connection, you might be hitting the limit of the UDP buffer size on your OS. We have observed this issue on macOS. The fix is to increase your connection's buffer size from your gossiper by using the `SetWriteBuffer()` command from the Go net package.
  2. Similarly, if you get an error of invalid JSON encoding when processing gossip packets, it is likely that the buffer you are using to read from the connection is too small and the packets get chopped.
  3. Whenever there is a hash value declared as a string, we expect the hexadecimal encoding of the value bytes. If you do not mix it with the regular string conversion, you will not have an opportunity to confuse it!

We will release the integration tests later this week. As with the previous homeworks, these will be mostly the same tests but run against our reference implementation.

Happy debugging!

The CS-438 Team