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

DBPW - Add test helpers for DB v5 interface #9948

Merged
merged 2 commits into from
Sep 15, 2020
Merged

Conversation

pcman312
Copy link
Contributor

Overview

This PR is part of a larger feature adding support for password policies into the combined database engine. This feature is being split into multiple PRs to make for smaller reviews & earlier feedback.

Adds some test helper functions to call the various functions on the v5 Database interface with common assertions (no error, NewUser gives a non-empty username). These do not preclude calling the functions directly in a test if needed. These are made available for the common testing use cases.

Related PRs

Original password policies PR
1/X - Database interface & gRPC
2/X - Middleware
3/X - Plugin management
4/X - Database engine

func AssertInitialize(t *testing.T, db newdbplugin.Database, req newdbplugin.InitializeRequest) newdbplugin.InitializeResponse {
t.Helper()

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this a tunable value? It may be sufficient for certain cases such as mocked databases, but 2 seconds might not be enough if operations end up taking longer than this duration for certain databases which can happen on CI (depending on load, machine type/size, etc.) and result in flaky tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm hesitant to add too much configurability to these as these are meant for the common use case. If they don't work for a specific database, those tests can fall back to calling the database functions directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the ability to change the timeouts via env variable with a default of 2s.

@pcman312 pcman312 merged commit 281a09f into master Sep 15, 2020
@pcman312 pcman312 deleted the dbpw-test-helpers branch September 15, 2020 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants