Skip to content

feat: add prometheus metrics to database.Store #7713

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

Merged
merged 11 commits into from
May 31, 2023
Prev Previous commit
Next Next commit
chore: fix flaky TestLicensesListFake/Mainline
  • Loading branch information
johnstcn committed May 31, 2023
commit 0ecd6aa095daef546f675458fed19979cbecfdb8
9 changes: 8 additions & 1 deletion enterprise/cli/licenses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func TestLicensesListFake(t *testing.T) {
// so instead we have to fake the HTTP interaction.
t.Run("Mainline", func(t *testing.T) {
t.Parallel()
var expectedLicenseExpires = time.Date(2024, 4, 6, 16, 53, 35, 0, time.UTC)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
inv := setupFakeLicenseServerTest(t, "licenses", "list")
Expand All @@ -158,7 +159,13 @@ func TestLicensesListFake(t *testing.T) {
assert.Equal(t, "claim1", licenses[0].Claims["h1"])
assert.Equal(t, int32(5), licenses[1].ID)
assert.Equal(t, "claim2", licenses[1].Claims["h2"])
assert.Equal(t, "2024-04-06T16:53:35Z", licenses[0].Claims["license_expires"])
Copy link
Member Author

Choose a reason for hiding this comment

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

review: this unit test breaks if your timezone is different 😛

Copy link
Member

Choose a reason for hiding this comment

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

Is this an underlying bug we should fix instead or working as expected?

Copy link
Member Author

@johnstcn johnstcn May 31, 2023

Choose a reason for hiding this comment

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

I think showing the expiry in the user's local timezone is probably fine.
EDIT: we used to show the expiry as a UNIX timestamp; it was changed to show RFC3339 in #7687. I think showing with local timezone is in line with this change.

expiresClaim := licenses[0].Claims["license_expires"]
expiresString, ok := expiresClaim.(string)
require.True(t, ok, "license_expires claim is not a string")
assert.NotEmpty(t, expiresClaim)
expiresTime, err := time.Parse(time.RFC3339, expiresString)
require.NoError(t, err)
require.Equal(t, expectedLicenseExpires, expiresTime.UTC())
})
}

Expand Down