Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal workflow client test improvements #1331

Merged
merged 2 commits into from
Apr 5, 2024
Merged

Conversation

Groxx
Copy link
Contributor

@Groxx Groxx commented Apr 3, 2024

Followups from #1327:

  1. simplifying the memo/search-attr encoding tests
  2. making sure the dataconverter tests can detect correct vs incorrect encoder use

1 is pretty simple: memos and search attrs are ALWAYS JSON because the server must interpret them, so the exact bytes should not change in the future. A hardcoded string is easy to verify, and strengthens the guarantee that "this should not change even if other encoding changes".

2 is more interesting: as originally written, the test would still pass if the custom dataconverter was not saved and used.
The type-assertion to check the internal field somewhat prevents that, but it's unnecessary and a disjointed check.
So it has been rewritten: now the serialized request bytes must clearly come from the test encoder, not the default encoder, and they must be detectably different.

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Merging #1331 (4ce7834) into master (08b284a) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08b284a...4ce7834. Read the comment docs.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 018ea615-a43f-4541-b127-5eb050337a74

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 13 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.05%) to 64.697%

Files with Coverage Reduction New Missed Lines %
internal/compatibility/thrift/enum.go 4 21.2%
internal/compatibility/thrift/types.go 9 48.42%
Totals Coverage Status
Change from base Build 018e9ff9-d8ed-403a-8c3a-5ffe0c57f644: -0.05%
Covered Lines: 13378
Relevant Lines: 20678

💛 - Coveralls

@Groxx Groxx merged commit 3ca6328 into uber-go:master Apr 5, 2024
13 checks passed
@Groxx Groxx deleted the test-fixes branch April 5, 2024 20:55
Groxx added a commit that referenced this pull request Jun 7, 2024
)

Apparently these also failed on the original PR, but due to missing a `\` in #1303 it wasn't failing in CI because the env var was gone by the time `exit` ran.
I should really take that as a hint to finally rewrite that chunk of the makefile, so it just does a normal `go test ./...` :\  but not today.

Thankfully this seems to be the only set of tests that snuck past, and they were just incorrect.
I'm not sure why I apparently didn't run them or something while writing them in #1331 but it seems pretty clear I didn't since the old pre-merge SHA fails too.  Bleh.

---

To correct the tests' original flaws:
1. memos *are* supposed to be encoded by custom dataconverters, and they are.  we don't search them so they're not JSON like search attrs are, they're just blobs we expose in list APIs (and in workflow metadata).
2. `Equal(string, []byte)` just doesn't work, and the default dataconverter adds a trailing newline to separate args.
3. the `[]byte`-heavy copypasta meant the Input-checking tests were odd, so I changed them, and fixed the args to the dataconverter.  Internally we splat the args in here, so it's not `[]interface{..}`-packed: https://github.com/uber-go/cadence-client/blob/6decfc78571a9d91d943815ae3a445a3bc115fa8/internal/internal_worker.go#L573-L579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants