Skip to content

Commit cf6ade1

Browse files
PBM-1597 update version check for 5.0, 6.0 and rapid (minor) releases (#1193)
PBM-1597 update version check for 5.0, 6.0 and rapid (minor) releases
1 parent 40b4f13 commit cf6ade1

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

pbm/version/version.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (f FeatureSupport) PBMSupport() error {
230230
}
231231

232232
// Supported MongoDB major versions for PBM
233-
supportedMajors := []int{5, 6, 7, 8}
233+
supportedMajors := []int{7, 8}
234234

235235
// Happy path: supported major within range and minor is 0
236236
if (v.Version[0] >= supportedMajors[0] &&
@@ -250,15 +250,22 @@ func (f FeatureSupport) PBMSupport() error {
250250
// If MongoDB is older than the minimum supported, suggest upgrading MongoDB
251251
if v.Version[0] < supportedMajors[0] {
252252
return errors.Errorf(
253-
"This PBM works with %s and you are running %s. Please upgrade your MongoDB to a supported version",
254-
strings.Join(supported, ", "),
255-
current,
253+
"This PBM works with MongoDB and PSMDB %s and you are running %s. "+
254+
"Please upgrade your MongoDB to a supported version.",
255+
strings.Join(supported, ", "), current,
256256
)
257257
}
258258

259-
// Otherwise, MongoDB is newer or uses an unsupported minor → suggest upgrading PBM
259+
// If MongoDB major is supported but uses an unsupported minor version
260+
if v.Version[0] <= supportedMajors[len(supportedMajors)-1] && v.Version[1] != 0 {
261+
return errors.Errorf("This PBM works with MongoDB and PSMDB %s and you are running %s."+
262+
"PBM does not support minor versions of MongoDB.",
263+
strings.Join(supported, ", "), current)
264+
}
265+
266+
// Otherwise, MongoDB is newer → suggest upgrading PBM
260267
return errors.Errorf(
261-
"This PBM works with %s and you are running %s. Please upgrade your PBM package",
268+
"This PBM works with MongoDB and PSMDB %s and you are running %s. Please upgrade your PBM package.",
262269
strings.Join(supported, ", "),
263270
current,
264271
)

pbm/version/version_test.go

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,45 @@ func TestPBMSupport(t *testing.T) {
127127
wantErr bool
128128
contains string
129129
}{
130-
{name: "supported 5.0.0", ver: []int{5, 0, 0}, wantErr: false},
131-
{name: "supported 5.0.x", ver: []int{5, 0, 14}, wantErr: false},
132-
{name: "supported 6.0.x", ver: []int{6, 0, 5}, wantErr: false},
130+
{name: "supported 7.0.x", ver: []int{7, 0, 1}, wantErr: false},
133131
{name: "supported 8.0.x", ver: []int{8, 0, 1}, wantErr: false},
134132

135-
{name: "too old 4.4.18", ver: []int{4, 4, 18}, wantErr: true, contains: "upgrade your MongoDB"},
136-
{name: "unsupported minor 5.1.0", ver: []int{5, 1, 0}, wantErr: true, contains: "upgrade your PBM"},
137-
{name: "newer major 9.0.0", ver: []int{9, 0, 0}, wantErr: true, contains: "upgrade your PBM"},
138-
{name: "unsupported minor 7.2.3", ver: []int{7, 2, 3}, wantErr: true, contains: "upgrade your PBM"},
139-
{name: "incomplete version array", ver: []int{7}, wantErr: true, contains: "incomplete versionArray"},
133+
{
134+
name: "too old 4.4.18", ver: []int{4, 4, 18},
135+
wantErr: true, contains: "upgrade your MongoDB",
136+
},
137+
{
138+
name: "too old 5.0.0", ver: []int{5, 0, 0},
139+
wantErr: true, contains: "upgrade your MongoDB",
140+
},
141+
{
142+
name: "too old 5.0.x", ver: []int{5, 0, 14},
143+
wantErr: true, contains: "upgrade your MongoDB",
144+
},
145+
{
146+
name: "too old 6.0.x", ver: []int{6, 0, 5},
147+
wantErr: true, contains: "upgrade your MongoDB",
148+
},
149+
{
150+
name: "too old 6.1.x", ver: []int{6, 1, 0},
151+
wantErr: true, contains: "upgrade your MongoDB",
152+
},
153+
{
154+
name: "unsupported minor 7.2.3", ver: []int{7, 2, 3},
155+
wantErr: true, contains: "does not support minor versions of MongoDB",
156+
},
157+
{
158+
name: "unsupported minor 8.3.0", ver: []int{8, 3, 0},
159+
wantErr: true, contains: "does not support minor versions of MongoDB",
160+
},
161+
{
162+
name: "newer major 9.0.0", ver: []int{9, 0, 0},
163+
wantErr: true, contains: "upgrade your PBM package",
164+
},
165+
{
166+
name: "incomplete version array", ver: []int{7},
167+
wantErr: true, contains: "incomplete versionArray",
168+
},
140169
}
141170

142171
for _, tc := range cases {
@@ -150,7 +179,7 @@ func TestPBMSupport(t *testing.T) {
150179
t.Fatalf("unexpected error message: %q does not contain %q", err.Error(), tc.contains)
151180
}
152181
if tc.contains == "" || !strings.Contains(tc.contains, "incomplete versionArray") {
153-
if !strings.Contains(err.Error(), "This PBM works with v5.0, v6.0, v7.0, v8.0") {
182+
if !strings.Contains(err.Error(), "This PBM works with MongoDB and PSMDB v7.0, v8.0") {
154183
t.Fatalf("error should list supported versions, got: %q", err.Error())
155184
}
156185
}

0 commit comments

Comments
 (0)