cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Add gofuzz tests to mapper functions

Open c-warren opened this issue 10 months ago • 3 comments

Is your feature request related to a problem? Please describe.

Frequently we encounter bugs with our mapping code from a request to an internal type. Our primary method of testing these mappers is to write a round trip test with hardcoded sanity values for the structs that are being tested. Whenever a new field is added to an external type, the corresponding test(s) need to be updated. However this only tests 1 of the 3 ways that things could fail:

Neither mapper implements the type (this is not tested - tests will pass) Only one mapper implements the type (round trip fails) Both mappers implement the type One mapper implements it incorrectly (round trip fails) Both mappers implement it in converse (round trip succeeds - tests will pass)

The most common type of error is in the differences between code generated from proto and thrift handling nil types differently.

Proposed Solution

To adequately test our mappers we should be able to test a wide range of data. Hardcoding the list of possible values is prohibitively difficult, particularly with the permutations of a given struct. We have solved this problem in the go-client by adding gofuzz tests. These tests randomly assign values to each member of the struct (including nils) and tests the conversion functions.

This should be added to tests of all of our mappers within the go server.

Additional context

N/A

c-warren avatar Jan 14 '26 20:01 c-warren

Thanks for opening this issue. To help us triage it, please provide the missing details: Missing required sections:

  • Description
  • Steps to Reproduce / How to Trigger
  • Expected Behavior
  • Actual Behavior
  • Logs / Screenshots
  • Environment Issue templates:
  • Bug report: https://github.com/cadence-workflow/cadence/issues/new?template=bug_report.md
  • Feature request (use for feature, improvement, refractoring): https://github.com/cadence-workflow/cadence/issues/new?template=feature_request.md

github-actions[bot] avatar Mar 20 '26 18:03 github-actions[bot]

Remaining tests are:

  • errors
  • helpers
  • history
  • matching
  • sharddistributor*

* shard distributor may not be necessary as it is moving to another repository.

c-warren avatar Mar 20 '26 18:03 c-warren

Hi! I'd like to pick up the fuzz tests for the thrift history mappers (common/types/mapper/thrift/history.go), following the pattern from #8560 (thrift matching). I see thrift errors/helpers (#8013) and replicator (#8582) are already in progress, so I'll stay out of those.

bhargavikvmpl-2001 avatar Oct 29 '26 17:10 bhargavikvmpl-2001