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

Add database and tests #32

Merged
merged 28 commits into from
Sep 14, 2023
Merged

Add database and tests #32

merged 28 commits into from
Sep 14, 2023

Conversation

didrocks
Copy link
Member

This cover creation/additions/getting users and groups from the database.

This will be hooked into PAM and NSS for respectively adding and getting informations to return them in the expected form there.

UDENG-1367

Copy link
Member

@denisonbarbosa denisonbarbosa left a comment

Choose a reason for hiding this comment

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

Wow, this is a big one. Nice work! Some comments, but definitely nothing blocking.

internal/cache/db_test.go Outdated Show resolved Hide resolved
didrocks and others added 21 commits September 14, 2023 13:00
The cache package is responsible for handling a database of users/groups
cached for nss.
This allows preventing calling the broker for each nss requests.
Handle update/get different modules, while keeping the database small
and performant.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
This is only for tests to allow loading/unloading with known time in
advance.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
…iles

We were basically allowing cleaning up dirty while db transaction were
in progress. Prevent from this possibility by having all database
transactions are read ones, and changing the files/reopening the database
is write.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
We want to avoid a race between Close() and cleaning up the associated
database goroutine.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
We only remove one file, let’s remove it directly and ignore unexisting
ones.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
This we be reused and exported in the tests.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Co-authored-by: Jean-Baptiste Lallement <[email protected]>
* Export needed arguments.
* First set of subtests, including cleaning.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Ensure that we treat invalid database content right away, clearing as
necessary.
Factor out cleaning code in the goroutine, ensuring that we are giving
it some retry period.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
We had the case where the new cache was returned, then an update is
called BEFORE the cleanup goroutine was started, resulting in any
invalid entries triggering the cleanup process but dropping the request.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
This will be shared across tests.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Thanks to the tests!

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Illustrate cases where we can recover and those were we can’t.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
We are using slog

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
This will be reused across tests.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Let’s ensure the database only contains expected and known buckets.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
didrocks and others added 4 commits September 14, 2023 13:35
Buckets are automatically added to existing database, add a test case
for this.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Add tests for getting users by id/name/all.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Tests for getting them by gid/name/all.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
didrocks and others added 3 commits September 14, 2023 13:35
Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Supports go 1.21.0.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
Co-authored-by: Jean-Baptiste Lallement <[email protected]>
@didrocks
Copy link
Member Author

Forced pushed as you approved (the clean -> clear change has been an interesting long rebase fight :))!

@didrocks didrocks merged commit 34025c3 into main Sep 14, 2023
3 checks passed
@didrocks didrocks deleted the add-db branch September 14, 2023 11:59
@didrocks didrocks restored the add-db branch September 14, 2023 11:59
@didrocks didrocks deleted the add-db branch September 14, 2023 12:00
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.

2 participants