Skip to content
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

PMM-13077 list change log for PMM server version #3045

Merged
merged 13 commits into from
Sep 11, 2024
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

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
Loading