Improve message unit-tests #48
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-api-go#48
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We use
v2
types like this that can be converted to grpc or from grpc.To check unmarshalling from/marshalling to protobuf or json formats we use message_test.go on generated instances.
The problem is that we may forget to set new added field within
Generate*
method and as the result - the bug cannot be revealed.We need to reconsider the way we generate
v2
type instances to make sure that new added fields are set and unit-tests pass wellThis could be useful https://pkg.go.dev/testing/quick#Value
(there's also https://pkg.go.dev/pgregory.net/rapid, which is supposed to be better and it's not frozen)
edit: but I don't see how property-based testing helps much with this issue. Seems to be a problem of proper automation rather than bug discovery.
We added a new field in the protobuf, we check
To -> From
grpc roundtrip.Here we a also forgot to add a generator for the value, so if it could've been set automatically (at random), the bug would've been catched.
Seems a lot easier to me to e.g. lint it, use proto reflection, or automate/detect it in other ways. Property-based testing seems like a huge overkill for this and it's not even guaranteed to find it.
It looks quite powerful at the first glance, especially with
MakeFuzz
We also currently do not fuzz our
StableMarshal
(we should not panic on any message andMarshal()
->StableMarshal()
->Marshal()
roundtrip should be a no-op).