-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set default reporting start time to billing start date (#27379)
* Apply oss patch * Added changelog
- Loading branch information
Showing
4 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```release-note:change | ||
activity: The startTime will be set to the start of the current billing period by default. | ||
The endTime will be set to the end of the current month. This applies to /sys/internal/counters/activity, | ||
/sys/internal/counters/activity/export, and the vault operator usage command that utilizes /sys/internal/counters/activity. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package activity | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/hashicorp/vault/api" | ||
"github.com/hashicorp/vault/vault" | ||
"github.com/mitchellh/mapstructure" | ||
) | ||
|
||
type QueryResponse struct { | ||
StartTime string `json:"start_time" mapstructure:"start_time"` | ||
EndTime string `json:"end_time" mapstructure:"end_time"` | ||
ByNamespace []*vault.ResponseNamespace `json:"by_namespace"` | ||
Total *vault.ResponseCounts `json:"total"` | ||
} | ||
|
||
func expectEndTime(t *testing.T, expected time.Time, resp *api.Secret) { | ||
t.Helper() | ||
|
||
qr := QueryResponse{} | ||
mapstructure.Decode(resp.Data, &qr) | ||
parsedTime, err := time.Parse(time.RFC3339, qr.EndTime) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !expected.Equal(parsedTime) { | ||
t.Errorf("wrong end time, expected %v actual %v", expected, parsedTime) | ||
} | ||
} | ||
|
||
func expectStartTime(t *testing.T, expected time.Time, resp *api.Secret) { | ||
t.Helper() | ||
|
||
var qr QueryResponse | ||
mapstructure.Decode(resp.Data, &qr) | ||
parsedTime, err := time.Parse(time.RFC3339, qr.StartTime) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !expected.Equal(parsedTime) { | ||
t.Errorf("wrong start time, expected %v actual %v", expected, parsedTime) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters