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-7 fix updates test #3050

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions api-tests/server/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ 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)
Expand All @@ -65,23 +65,21 @@ func TestCheckUpdates(t *testing.T) {
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")
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)

if res.Payload.UpdateAvailable {
assert.NotEmpty(t, res.Payload.Latest.Tag)
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.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.NotEmpty(t, res.Payload.LastCheck)

Expand Down
4 changes: 2 additions & 2 deletions managed/services/server/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ func TestUpdater(t *testing.T) {
})

t.Run("TestLatest", func(t *testing.T) {
// Used PMM 2, because PMM 3 is not released yet.
version.Version = "2.41.0"
u := NewUpdater(watchtowerURL, gRPCMessageMaxSize)
latest, err := u.latest(context.Background())
require.NoError(t, err)
assert.NotNil(t, latest)
assert.True(t, strings.HasPrefix(latest.Version.String(), "2.41."), "latest version of PMM 2 should have prefix 2.41.")
assert.True(t, strings.HasPrefix(latest.Version.String(), "2.") || strings.HasPrefix(latest.Version.String(), "3."),
"latest version of PMM 2 should have prefix 2.")
})

t.Run("TestParseFile", func(t *testing.T) {
Expand Down
Loading