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

feat(orm): gRPC codes for save errors #11386

Merged
merged 9 commits into from
Mar 17, 2022
Merged

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Mar 15, 2022

Description

Ref: #11088. First PR of several to add gRPC error codes and make sure that errors are a well-defined part of the API.

Also introduces Cucumber-style BDD acceptance tests into the SDK via https://github.com/regen-network/gocuke.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added the C:orm label Mar 15, 2022
@@ -9,22 +9,29 @@ require (
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.7
github.com/iancoleman/strcase v0.2.0
github.com/regen-network/gocuke v0.6.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't introduce new testing frameworks to the project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason for it. Everything here is equally well expressed as conventional table-based Go unit tests.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each new dependency added to go.mod must be default deny. The onus is on the author to justify its value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is readability. We've decided internally to try this type of testable documentation. If it doesn't provide value, we won't continue with it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to get an ADR on testing up and which way things are going. We all understand there is an issue with testing in the cosmos-sdk that leads to messed up ci pipelines and not having full coverage.

I thought there was agreement on this from the Regen side, but seems there are conflicting opinions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have clearly misunderstood the purpose of PRs in this project. My apologies. I'll refrain from commenting or contributing any further.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. https://github.com/regen-network/gocuke is a repo of 62 (non-reviewed?) commits by Aaron. If we add this to the SDK, we need to reduce the bus factor first audit it (or at least understand it).

Folks on the regen ledger side have looked into this more and that is where our devs are more aligned around this approach @marbar3778. We can prepare something a bit more formal if that helps. Although the reality is we don't usually do too thorough of an audit of 3rd party test dependencies as is...

  1. The acceptance tests should test that code matches spec, where "spec" is generally an agreed-upon document in English language. We don't have this doc yet for ORM (Marko and I will try to work with Aaron on that), it seems now that these tests almost are the spec itself, is that what BDD precognizes?

That's the point. There is no English language spec. That's precisely what this introduces

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marbar3778 let's continue discussion in #11356. This has two approvals but I will hold off on merging until I get your approval @AmauryM. Will be in touch with both of you around how we want to move forward

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the matter of the fact: most of the Cosmos SDK tests are not readable. Cucumber style tests are way more readable (few orders of magnitude +1).

@aaronc aaronc marked this pull request as ready for review March 16, 2022 17:13
@aaronc aaronc requested a review from alexanderbez as a code owner March 16, 2022 17:13
@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #11386 (05dddf0) into master (4081bc3) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11386      +/-   ##
==========================================
- Coverage   66.03%   65.99%   -0.05%     
==========================================
  Files         719      713       -6     
  Lines       73920    72871    -1049     
==========================================
- Hits        48813    48091     -722     
+ Misses      22053    21807     -246     
+ Partials     3054     2973      -81     
Impacted Files Coverage Δ
orm/model/ormtable/table_impl.go 59.92% <100.00%> (+2.24%) ⬆️
orm/model/ormtable/unique.go 44.09% <100.00%> (+2.36%) ⬆️
db/memdb/db.go
db/rocksdb/iterator.go
db/badgerdb/db.go
db/memdb/iterator.go
db/prefix/prefix.go
db/rocksdb/db.go
db/rocksdb/batch.go
db/version_manager.go
... and 8 more

orm/go.mod Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving an putting automerge! Let's 🥒

I think the english spec -> acceptance tests -> code process is too optimistic, and I agree with Aaron we've been more doing in practice in the past months: code -> tests -> spec/ADR. Probably gocuke will help here with the latter process.

I think this PR a good case study to see if it's useful. I still have doubts about gocuke, i'll need to see it more in action. But I also encourage other people to give feedback. The ideal feedback would be from users of the ORM (once we release it). If it's useful to them, then it's a win. If not, then let's discuss again.

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 17, 2022
@mergify mergify bot merged commit 872d924 into master Mar 17, 2022
@mergify mergify bot deleted the aaronc/11088-orm-save-errors branch March 17, 2022 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:orm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants