Skip to content

Commit

Permalink
add new clients to namespace counts (#27549)
Browse files Browse the repository at this point in the history
  • Loading branch information
miagilepner authored Jun 20, 2024
1 parent 36affc2 commit 9af5c5c
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 38 deletions.
4 changes: 2 additions & 2 deletions vault/activity/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ func (q *PrecomputedQuery) CombineWithCurrentMonth(currentMonth *MonthRecord) {
existingNamespaceMounts[monthlyNamespaceRecord.NamespaceID] = monthlyNamespaceRecord
}

// Get the counts of each mount per namespace in the current month, and increment
// Get the counts of new clients each mount per namespace in the current month, and increment
// its total count in the precomputed query. These total values will be visible in the
// by_namespace grouping in the final response data
for _, nsRecord := range currentMonth.Namespaces {
for _, nsRecord := range currentMonth.NewClients.Namespaces {
namespaceId := nsRecord.NamespaceID

// If the namespace already exists in the previous months, iterate through the mounts and increment the counts
Expand Down
163 changes: 127 additions & 36 deletions vault/activity/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,86 +388,177 @@ func TestCombineWithCurrentMonth(t *testing.T) {
{
NamespaceID: "ns1",
Counts: &CountsRecord{
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
EntityClients: 4,
NonEntityClients: 4,
SecretSyncs: 4,
ACMEClients: 4,
},
Mounts: []*MountRecord{
{
MountPath: "m1",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
},
{
MountPath: "m2",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
},
},
},
{
NamespaceID: "ns2",
Counts: &CountsRecord{
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
EntityClients: 4,
NonEntityClients: 4,
SecretSyncs: 4,
ACMEClients: 4,
},
Mounts: []*MountRecord{
{
MountPath: "m1",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
},
{
MountPath: "m3",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
},
},
},
{
NamespaceID: "ns3",
Counts: &CountsRecord{
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
EntityClients: 4,
NonEntityClients: 4,
SecretSyncs: 4,
ACMEClients: 4,
},
Mounts: []*MountRecord{
{
MountPath: "m1",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
},
{
MountPath: "m2",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
},
},
},
},
NewClients: &NewClientRecord{
Namespaces: []*MonthlyNamespaceRecord{
{
NamespaceID: "ns1",
Counts: &CountsRecord{
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
Mounts: []*MountRecord{
{
MountPath: "m1",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
},
},
{
MountPath: "m2",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
},
},
},
},
{
NamespaceID: "ns2",
Counts: &CountsRecord{
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
Mounts: []*MountRecord{
{
MountPath: "m1",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
},
},
{
MountPath: "m3",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
},
},
},
},
{
NamespaceID: "ns3",
Counts: &CountsRecord{
EntityClients: 2,
NonEntityClients: 2,
SecretSyncs: 2,
ACMEClients: 2,
},
Mounts: []*MountRecord{
{
MountPath: "m1",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
},
},
{
MountPath: "m2",
Counts: &CountsRecord{
EntityClients: 1,
NonEntityClients: 1,
SecretSyncs: 1,
ACMEClients: 1,
},
},
},
},
Expand Down

0 comments on commit 9af5c5c

Please sign in to comment.