Skip to content

Commit

Permalink
Support release notes for PMM versions
Browse files Browse the repository at this point in the history
This adds support for PMM release notes by fetching the correct markdown
files from github.

It also includes fixes for api tests by accepting v3 prefixes in
versions.
  • Loading branch information
idoqo committed Jun 25, 2024
1 parent 0b405e8 commit 6cc2711
Show file tree
Hide file tree
Showing 13 changed files with 474 additions and 388 deletions.
28 changes: 12 additions & 16 deletions api-tests/server/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,29 @@ func TestCheckUpdates(t *testing.T) {
require.NoError(t, err)

require.NotEmpty(t, res.Payload.Installed)
assert.True(t, strings.HasPrefix(res.Payload.Installed.Version, "2."),
"installed.version = %q should have '2.' prefix", res.Payload.Installed.Version)
assert.True(t, strings.HasPrefix(res.Payload.Installed.Version, "2.") || strings.HasPrefix(res.Payload.Installed.Version, "3."),
"installed.version = %q should have '2.' or '3.' prefix", res.Payload.Installed.Version)
assert.NotEmpty(t, res.Payload.Installed.FullVersion)
require.NotEmpty(t, res.Payload.Installed.Timestamp)
ts := time.Time(res.Payload.Installed.Timestamp)
hour, min, _ := ts.Clock()
assert.Zero(t, hour, "installed.timestamp should contain only date")
assert.Zero(t, min, "installed.timestamp should contain only date")

require.NotEmpty(t, res.Payload.Latest)
assert.True(t, strings.HasPrefix(res.Payload.Latest.Version, "2."),
"latest.version = %q should have '2.' prefix", res.Payload.Latest.Version)
require.NotEmpty(t, res.Payload.Latest.Timestamp)
ts = time.Time(res.Payload.Latest.Timestamp)
hour, min, _ = ts.Clock()
assert.Zero(t, hour, "latest.timestamp should contain only date")
assert.Zero(t, min, "latest.timestamp should contain only date")

if res.Payload.UpdateAvailable {
require.NotEmpty(t, res.Payload.Latest)
assert.True(t, strings.HasPrefix(res.Payload.Latest.Version, "2.") || strings.HasPrefix(res.Payload.Installed.Version, "3."),
"latest.version = %q should have '2.' or '3.' prefix", res.Payload.Latest.Version)
require.NotEmpty(t, res.Payload.Latest.Timestamp)
ts = time.Time(res.Payload.Latest.Timestamp)
hour, min, _ = ts.Clock()
assert.Zero(t, hour, "latest.timestamp should contain only date")
assert.Zero(t, min, "latest.timestamp should contain only date")

assert.NotEmpty(t, res.Payload.Latest.Tag)
assert.NotEqual(t, res.Payload.Installed.FullVersion, res.Payload.Latest.Version)
assert.NotEqual(t, res.Payload.Installed.Timestamp, res.Payload.Latest.Timestamp)
assert.True(t, strings.HasPrefix(res.Payload.LatestNewsURL, "https://per.co.na/pmm/2."), "latest_news_url = %q", res.Payload.LatestNewsURL)
} else {
assert.Equal(t, res.Payload.Installed.Timestamp, res.Payload.Latest.Timestamp)
assert.Empty(t, res.Payload.Installed.FullVersion, res.Payload.Latest.Version)
assert.Empty(t, res.Payload.LatestNewsURL, "latest_news_url should be empty")
assert.True(t, strings.HasPrefix(res.Payload.Latest.ReleaseNotesURL, "https://per.co.na/pmm/2."), "latest_news_url = %q", res.Payload.Latest.ReleaseNotesURL)
}
assert.NotEmpty(t, res.Payload.LastCheck)

Expand Down
9 changes: 6 additions & 3 deletions api/serverpb/json/client/server/check_updates_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions api/serverpb/json/serverpb.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,21 @@
"description": "Last check time.",
"type": "string",
"format": "date-time",
"x-order": 4
"x-order": 3
},
"latest": {
"type": "object",
"properties": {
"release_notes_text": {
"description": "Release notes text for the version (if available).",
"type": "string",
"x-order": 4
},
"release_notes_url": {
"description": "Release notes URL for the version (if available).",
"type": "string",
"x-order": 3
},
"tag": {
"description": "Docker image tag.",
"type": "string",
Expand All @@ -741,11 +751,6 @@
},
"x-order": 1
},
"latest_news_url": {
"description": "Latest available PMM Server release announcement URL.",
"type": "string",
"x-order": 3
},
"update_available": {
"description": "True if there is a PMM Server update available.",
"type": "boolean",
Expand Down
Loading

0 comments on commit 6cc2711

Please sign in to comment.