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(pubsublite): Mock server and utils for unit tests #3092

Merged
merged 8 commits into from Nov 3, 2020

Conversation

@tmdiep
Copy link
Contributor

@tmdiep tmdiep commented Oct 27, 2020

Introduces MockLiteServer, which tests can use to register expected server requests and configure fake responses or errors. It handles unary RPCs, as well as unique bidi stream connections. It initially implements enough to test publishing, and will be extended for other unit tests.

There are also miscellaneous utils for comparing errors and a fake rand source for use in unit tests.

@tmdiep tmdiep requested a review from as a code owner Oct 27, 2020
@google-cla google-cla bot added the cla: yes label Oct 27, 2020
@tmdiep tmdiep requested a review from hongalex Oct 27, 2020
@tmdiep
Copy link
Contributor Author

@tmdiep tmdiep commented Oct 27, 2020

@tmdiep
Copy link
Contributor Author

@tmdiep tmdiep commented Nov 2, 2020

Friendly ping on this review.

Sorry for the large patch. It's just the beginnings of a mock server for Pub/Sub Lite APIs, inspired by the testing strategy I saw in some of the other libraries (e.g. https://github.com/googleapis/google-cloud-go/blob/master/firestore/mock_test.go). But I had to abstract it for Lite due to the numerous streaming RPCs that we have.

Example usage:
https://github.com/tmdiep/google-cloud-go/blob/f14e1ee0d3b586874025c72858ba3b1415ae5c40/pubsublite/internal/wire/publisher_test.go#L938

Thank you!

pubsublite/internal/test/verifier.go Show resolved Hide resolved
pubsublite/internal/test/verifier.go Show resolved Hide resolved
pubsublite/internal/test/verifier.go Outdated Show resolved Hide resolved
@tmdiep
Copy link
Contributor Author

@tmdiep tmdiep commented Nov 2, 2020

Thanks Alex, comments addressed. PTAL.

@tmdiep tmdiep requested a review from hongalex Nov 2, 2020
@tmdiep tmdiep merged commit 586592e into googleapis:master Nov 3, 2020
3 checks passed
@tmdiep tmdiep deleted the mockserver branch Nov 3, 2020
gcf-merge-on-green bot pushed a commit that referenced this issue Nov 10, 2020
🤖 I have created a release \*beep\* \*boop\* 
---
## [0.3.0](https://www.github.com/googleapis/google-cloud-go/compare/pubsublite/v0.2.0...v0.3.0) (2020-11-10)


### Features

* **pubsublite:** Added Pub/Sub Lite clients and routing headers ([#3105](https://www.github.com/googleapis/google-cloud-go/issues/3105)) ([98668fa](https://www.github.com/googleapis/google-cloud-go/commit/98668fa5457d26ed34debee708614f027020e5bc))
* **pubsublite:** Flow controller and offset tracker for the subscriber ([#3132](https://www.github.com/googleapis/google-cloud-go/issues/3132)) ([5899bdd](https://www.github.com/googleapis/google-cloud-go/commit/5899bdd7d6d5eac96e42e1baa1bd5e905e767a17))
* **pubsublite:** Mock server and utils for unit tests ([#3092](https://www.github.com/googleapis/google-cloud-go/issues/3092)) ([586592e](https://www.github.com/googleapis/google-cloud-go/commit/586592ef5875667e65e19e3662fe532b26293172))
* **pubsublite:** Move internal implementation details to internal/wire subpackage ([#3123](https://www.github.com/googleapis/google-cloud-go/issues/3123)) ([ed3fd1a](https://www.github.com/googleapis/google-cloud-go/commit/ed3fd1aed7dbc9396aecc70622ccfd302bbb4265))
* **pubsublite:** Periodic background task ([#3152](https://www.github.com/googleapis/google-cloud-go/issues/3152)) ([58c12cc](https://www.github.com/googleapis/google-cloud-go/commit/58c12ccba01cfe3b320e2e83d7ca1145f1e310d7))
* **pubsublite:** Test utils for streams ([#3153](https://www.github.com/googleapis/google-cloud-go/issues/3153)) ([5bb2b02](https://www.github.com/googleapis/google-cloud-go/commit/5bb2b0218d355bc558b03f24db1a0786a3489cac))
* **pubsublite:** Trackers for acks and commit cursor ([#3137](https://www.github.com/googleapis/google-cloud-go/issues/3137)) ([26599a0](https://www.github.com/googleapis/google-cloud-go/commit/26599a0995d9b108bbaaceca775457ffc331dcb2))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants