Skip to content

Commit

Permalink
PMM-13077 list change log for PMM server version (#3045)
Browse files Browse the repository at this point in the history
* Support release notes for PMM versions

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.

* use separate endpoint for listing versions

* replace dockerhub/github with version service endpoints

* fix tests

* use better naming for rpc

* drop todo

* use check dev for version service

* fix method name for changelogs

* include release notes text in response
  • Loading branch information
idoqo authored Sep 11, 2024
1 parent 4242f0b commit 5561f58
Show file tree
Hide file tree
Showing 19 changed files with 2,291 additions and 468 deletions.
36 changes: 36 additions & 0 deletions api-tests/server/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ func TestCheckUpdates(t *testing.T) {
assert.NotEmpty(t, res.Payload.Installed.FullVersion)

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)
require.NotEmpty(t, res.Payload.Latest.Timestamp)
ts = time.Time(res.Payload.Latest.Timestamp)
Expand All @@ -81,6 +90,7 @@ func TestCheckUpdates(t *testing.T) {
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)
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 Expand Up @@ -110,6 +120,32 @@ func TestCheckUpdates(t *testing.T) {
})
}

func TestListUpdates(t *testing.T) {
const fast, slow = 5 * time.Second, 60 * time.Second

if !pmmapitests.RunUpdateTest {
t.Skip("skipping PMM Server check update test")
}

version, err := serverClient.Default.ServerService.Version(server.NewVersionParamsWithTimeout(fast))
require.NoError(t, err)
if version.Payload.Server == nil || version.Payload.Server.Version == "" {
t.Skip("skipping test in developer's environment")
}

params := &server.ListChangeLogsParams{
Context: pmmapitests.Context,
}
params.SetTimeout(slow)
res, err := serverClient.Default.ServerService.ListChangeLogs(params)
require.NoError(t, err)

if len(res.Payload.Updates) > 0 {
assert.True(t, strings.HasPrefix(res.Payload.Updates[0].Version, "3."),
"installed.version = %q should have '3.' prefix", res.Payload.Updates[0].Version)
}
}

func TestUpdate(t *testing.T) {
// do not run this test in parallel with other tests

Expand Down
Binary file modified api/descriptor.bin
Binary file not shown.

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

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

Loading

0 comments on commit 5561f58

Please sign in to comment.