[archivist] Fix tests for CTF

This test has been mysteriously failing in CTF but passing at HEAD for
the last few API rolls, and we now know why.

At API level HEAD we default the format for Inspect reads to CBOR which
is more efficient, but not yet formally stabilized. At levels < HEAD,
however, we default to JSON which is less space efficient.

The truncation test sets the maximum byte size to 4000 bytes, which
gives 1333 bytes for each of the 3 components that are being read. This
happens to fit the CBOR content, but not the JSON content. Whenever we
roll a new API level we create a version of this test that requests the
JSON content which becomes fully truncated (similar to the case where we
set the maximum size to 1 byte).

This change creates a new method on the ArchiveReader to set the read
format. If that method is not called we revert to the default FORMAT as
before. The test now includes a new read that checks that whatever
number we pick can fit a JSON response too, and we set the maximum
aggregated size to 8000 instead of 4000 since that is enough to fit
either JSON or CBOR.

Fixed: 383560524
Change-Id: Ibe75ce0532f0c4dc161d1c2ae0a723d416ef4b29
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1609930
Reviewed-by: Brian Bosak <bbosak@google.com>
3 files changed