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

VAULT-14735: generate mock clients for activity log #20252

Merged
merged 6 commits into from
May 23, 2023

Conversation

miagilepner
Copy link
Contributor

This is the first PR for a set of changes to support writing activity log segments with generated clients. This PR introduces some types and methods to help generate clients. Note that these methods are not called, except in tests. A later PR will call these methods from the data generation endpoint.

Copy link
Contributor

@mpalmi mpalmi left a comment

Choose a reason for hiding this comment

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

Looks good. Just one pedantic nit, but we can also just merge as-is IMO.

One thing I thought of while testing: would it make sense to create a wiki or update the README with some general guidance for using this?

That might be a good place to indicate the need for thetestonly build flag and possibly provide guidance for doing this on GoLand/VSCode. It took me a minute to recall how to do add the build flag to my workspace.

vault/logical_system_activity_write_testonly.go Outdated Show resolved Hide resolved
@miagilepner
Copy link
Contributor Author

One thing I thought of while testing: would it make sense to create a wiki or update the README with some general guidance for using this?

Definitely, that's a great idea. I'll add that and link it here.

Copy link
Contributor

@hghaf099 hghaf099 left a comment

Choose a reason for hiding this comment

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

Lot of good stuff in the PR. I have some clarifying questions and a couple of nit comments.

vault/logical_system_activity_write_testonly.go Outdated Show resolved Hide resolved

mountAccessor := defaultMount
if clients.Namespace != "" {
mountAccessor = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: There is a lot of variable overwriting for mountAccessor. I wonder if there is a way to avoid that or make it more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reworked the code to make it (hopefully) a bit clearer

}
addingTo := m.months[month.GetMonthsAgo()]

for _, clients := range month.GetAll().Clients {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confused, is clients a single client? Shall we use client instead if it is indeed a single client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clients is a single description of how to generate some number of clients. for example:

&Client{
	Count: 10,
	Namespace: "root",
	Mount: "kv",
}

could be the value, and it means generate 10 distinct clients with namespace "root" and mount "kv".

I can change the variable to client, if that's clearer

vault/logical_system_activity_write_testonly.go Outdated Show resolved Hide resolved
vault/logical_system_activity_write_testonly.go Outdated Show resolved Hide resolved
@miagilepner miagilepner marked this pull request as draft April 20, 2023 16:31
@miagilepner miagilepner force-pushed the miagilepner/VAULT-14735-segment-writing-0 branch from acd915f to db6a19b Compare May 16, 2023 12:00
@miagilepner miagilepner marked this pull request as ready for review May 16, 2023 12:17
@miagilepner miagilepner removed this from the 1.14 milestone May 19, 2023
ClientID: c.Id,
NamespaceID: c.Namespace,
NonEntity: c.NonEntity,
MountAccessor: mountAccessor,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can add the new ClientType field here, or do you think that's more deserving of a separate PR?

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 can add it here

Comment on lines +175 to +180
clients: &generation.Data{
Clients: &generation.Data_All{All: &generation.Clients{Clients: []*generation.Client{{
Namespace: namespace.RootNamespaceID,
Mount: "identity/",
}}}},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it makes sense to create a constructor for generation.Data for future users, since there's a lot of decoration around a small set of actual data? If this is an uncommon pattern, I'm fine with leaving it as-is. Just thinking out loud.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there will be, that's another ticket in the epic

@miagilepner miagilepner force-pushed the miagilepner/VAULT-14735-segment-writing-0 branch from 1e0bc25 to c212cc3 Compare May 23, 2023 09:17
@miagilepner miagilepner added this to the 1.14 milestone May 23, 2023
@miagilepner miagilepner merged commit 5b23dd5 into main May 23, 2023
@miagilepner miagilepner deleted the miagilepner/VAULT-14735-segment-writing-0 branch May 23, 2023 09:58
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.

4 participants