Skip to content

Commit

Permalink
fix: support version compatibility check for pre-release versions (#2069
Browse files Browse the repository at this point in the history
)

Signed-off-by: Keran Yang <[email protected]>
  • Loading branch information
KeranYang authored Sep 19, 2024
1 parent 6914341 commit ed543ad
Show file tree
Hide file tree
Showing 5 changed files with 677 additions and 150 deletions.
6 changes: 3 additions & 3 deletions pkg/sdkclient/serverinfo/serverinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func checkNumaflowCompatibility(numaflowVersion string, minNumaflowVersion strin
numaflowConstraint := fmt.Sprintf(">= %s", minNumaflowVersion)
if err = checkConstraint(numaflowVersionSemVer, numaflowConstraint); err != nil {
return fmt.Errorf("numaflow version %s must be upgraded to at least %s, in order to work with current SDK version: %w",
numaflowVersionSemVer.String(), minNumaflowVersion, err)
numaflowVersionSemVer.String(), humanReadable(minNumaflowVersion), err)
}
return nil
}
Expand All @@ -193,7 +193,7 @@ func checkSDKCompatibility(sdkVersion string, sdkLanguage Language, minSupported

if !c.Check(sdkVersionPEP440) {
return fmt.Errorf("SDK version %s must be upgraded to at least %s, in order to work with current numaflow version: %w",
sdkVersionPEP440.String(), sdkRequiredVersion, err)
sdkVersionPEP440.String(), humanReadable(sdkRequiredVersion), err)
}
} else {
sdkVersionSemVer, err := semver.NewVersion(sdkVersion)
Expand All @@ -203,7 +203,7 @@ func checkSDKCompatibility(sdkVersion string, sdkLanguage Language, minSupported

if err := checkConstraint(sdkVersionSemVer, sdkConstraint); err != nil {
return fmt.Errorf("SDK version %s must be upgraded to at least %s, in order to work with current numaflow version: %w",
sdkVersionSemVer.String(), sdkRequiredVersion, err)
sdkVersionSemVer.String(), humanReadable(sdkRequiredVersion), err)
}
}
}
Expand Down
234 changes: 210 additions & 24 deletions pkg/sdkclient/serverinfo/serverinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,57 @@ func Test_CheckNumaflowCompatibility(t *testing.T) {
errMessage string
}{
{
name: "Test with incompatible numaflow version",
name: "Test with incompatible numaflow version, min is a stable version 1.1.7",
numaflowVersion: "v1.1.6",
minNumaflowVersion: "1.1.7",
minNumaflowVersion: "1.1.7-z",
shouldErr: true,
errMessage: "numaflow version 1.1.6 must be upgraded to at least 1.1.7, in order to work with current SDK version",
},
{
name: "Test with compatible numaflow version - min is a stable version 1.1.6",
numaflowVersion: "1.1.7",
minNumaflowVersion: "1.1.6-z",
shouldErr: false,
},
{
name: "Test with incompatible numaflow version - min is a stable version 1.1.7, numaflow version is a pre-release version",
numaflowVersion: "v1.1.7-rc1",
minNumaflowVersion: "1.1.7-z",
shouldErr: true,
errMessage: "numaflow version 1.1.7-rc1 must be upgraded to at least 1.1.7, in order to work with current SDK version",
},
{
name: "Test with compatible numaflow version - min is a stable version 1.1.6, numaflow version is a pre-release version",
numaflowVersion: "1.1.7-rc1",
minNumaflowVersion: "1.1.6-z",
shouldErr: false,
},
{
name: "Test with incompatible numaflow version, min is a rc version 1.1.7-rc1",
numaflowVersion: "v1.1.6",
minNumaflowVersion: "1.1.7-rc1",
shouldErr: true,
errMessage: "numaflow version 1.1.6 must be upgraded to at least 1.1.7-rc1, in order to work with current SDK version",
},
{
name: "Test with compatible numaflow version - min is a rc version 1.1.6-rc1",
numaflowVersion: "1.1.7",
minNumaflowVersion: "1.1.6-rc1",
shouldErr: false,
},
{
name: "Test with incompatible numaflow version - min is a rc version 1.1.7-rc2, numaflow version is a pre-release version",
numaflowVersion: "v1.1.7-rc1",
minNumaflowVersion: "1.1.7-rc2",
shouldErr: true,
errMessage: "numaflow version 1.1.7-rc1 must be upgraded to at least 1.1.7-rc2, in order to work with current SDK version",
},
{
name: "Test with compatible numaflow version - min is a rc version 1.1.6-rc2, numaflow version is a pre-release version",
numaflowVersion: "1.1.6-rc2",
minNumaflowVersion: "1.1.6-rc2",
shouldErr: false,
},
{
name: "Test with empty MinimumNumaflowVersion field",
numaflowVersion: "1.1.7",
Expand All @@ -111,10 +156,17 @@ func Test_CheckNumaflowCompatibility(t *testing.T) {
errMessage: "server info does not contain minimum numaflow version. Upgrade to newer SDK version",
},
{
name: "Test with compatible numaflow version",
numaflowVersion: "1.1.7",
minNumaflowVersion: "1.1.6",
shouldErr: false,
name: "Test with invalid numaflow version",
numaflowVersion: "",
minNumaflowVersion: "1.1.7",
shouldErr: true,
errMessage: "error parsing numaflow version: Invalid Semantic Version",
},
{
name: "Test with empty min numaflow version",
numaflowVersion: "1.1.7",
shouldErr: true,
errMessage: "server info does not contain minimum numaflow version. Upgrade to newer SDK version",
},
}
for _, tt := range tests {
Expand All @@ -130,12 +182,13 @@ func Test_CheckNumaflowCompatibility(t *testing.T) {
}
}

func Test_CheckSDKCompatibility(t *testing.T) {
// this test suite is to test SDK compatibility check when all the minimum-supported versions are stable releases
func Test_CheckSDKCompatibility_MinimumBeingStableReleases(t *testing.T) {
var testMinimumSupportedSDKVersions = sdkConstraints{
Go: "0.6.0-0",
Python: "0.6.0a",
Java: "0.6.0-0",
Rust: "0.1.0",
Python: "0.6.0rc100",
Go: "0.6.0-z",
Java: "0.6.0-z",
Rust: "0.1.0-z",
}
tests := []struct {
name string
Expand All @@ -146,50 +199,183 @@ func Test_CheckSDKCompatibility(t *testing.T) {
errMessage string
}{
{
name: "Test with incompatible Python version",
name: "python pre-release version is lower than minimum supported version",
sdkVersion: "v0.5.3a1",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.5.3a1 must be upgraded to at least 0.6.0a, in order to work with current numaflow version",
errMessage: "SDK version 0.5.3a1 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
{
name: "Test with compatible Python version",
sdkVersion: "v0.6.0a2",
name: "python pre-release version is compatible with minimum supported version",
sdkVersion: "v0.6.3a1",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "Test with incompatible Java version",
sdkVersion: "v0.4.3",
sdkLanguage: Java,
name: "python stable release version is compatible with minimum supported version",
sdkVersion: "v0.6.0",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "python stable release version is lower than minimum supported version",
sdkVersion: "v0.5.3",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.4.3 must be upgraded to at least 0.6.0-0, in order to work with current numaflow version",
errMessage: "SDK version 0.5.3 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
{
name: "java release version is compatible with minimum supported version",
sdkVersion: "v0.7.3",
sdkLanguage: Java,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "Test with compatible Go version",
sdkVersion: "v0.6.0-rc2",
name: "golang rc release version is compatible with minimum supported version",
sdkVersion: "v0.6.2-rc2",
sdkLanguage: Go,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
}, {
name: "rust pre-release version is compatible with minimum supported version",
sdkVersion: "v0.1.2-0.20240913163521-4910018031a7",
sdkLanguage: Rust,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "Test with incompatible Rust version",
name: "rust release version is lower than minimum supported version",
sdkVersion: "v0.0.3",
sdkLanguage: Rust,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.0.3 must be upgraded to at least 0.1.0, in order to work with current numaflow version",
},
{
name: "Test with compatible Rust version",
sdkVersion: "v0.1.1",
name: "java rc release version is lower than minimum supported version",
sdkVersion: "v0.6.0-rc1",
sdkLanguage: Java,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.6.0-rc1 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
{
name: "golang pre-release version is lower than minimum supported version",
sdkVersion: "v0.6.0-0.20240913163521-4910018031a7",
sdkLanguage: Go,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.6.0-0.20240913163521-4910018031a7 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := checkSDKCompatibility(tt.sdkVersion, tt.sdkLanguage, tt.minimumSupportedSDKVersions)
if tt.shouldErr {
assert.Error(t, err, "Expected error")
assert.Contains(t, err.Error(), tt.errMessage)
} else {
assert.NoError(t, err, "Expected no error")
}
})
}
}

// this test suite is to test SDK compatibility check when all the minimum-supported versions are pre-releases
func Test_CheckSDKCompatibility_MinimumBeingPreReleases(t *testing.T) {
var testMinimumSupportedSDKVersions = sdkConstraints{
Python: "0.6.0b1",
Go: "0.6.0-rc2",
Java: "0.6.0-rc2",
Rust: "0.1.0-rc3",
}
tests := []struct {
name string
sdkVersion string
sdkLanguage Language
minimumSupportedSDKVersions sdkConstraints
shouldErr bool
errMessage string
}{
{
name: "python pre-release version is lower than minimum supported version",
sdkVersion: "v0.5.3a1",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.5.3a1 must be upgraded to at least 0.6.0b1, in order to work with current numaflow version",
},
{
name: "python pre-release version is compatible with minimum supported version",
sdkVersion: "v0.6.3a1",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "python stable release version is compatible with minimum supported version",
sdkVersion: "v0.6.0",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "python stable release version is lower than minimum supported version",
sdkVersion: "v0.5.3",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.5.3 must be upgraded to at least 0.6.0b1, in order to work with current numaflow version",
},
{
name: "java release version is compatible with minimum supported version",
sdkVersion: "v0.7.3",
sdkLanguage: Java,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "golang rc release version is compatible with minimum supported version",
sdkVersion: "v0.6.2-rc2",
sdkLanguage: Go,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
}, {
name: "rust pre-release version is compatible with minimum supported version",
sdkVersion: "v0.1.2-0.20240913163521-4910018031a7",
sdkLanguage: Rust,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "rust release version is lower than minimum supported version",
sdkVersion: "v0.0.3",
sdkLanguage: Rust,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.0.3 must be upgraded to at least 0.1.0-rc3, in order to work with current numaflow version",
},
{
name: "java rc release version is lower than minimum supported version",
sdkVersion: "v0.6.0-rc1",
sdkLanguage: Java,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.6.0-rc1 must be upgraded to at least 0.6.0-rc2, in order to work with current numaflow version",
},
{
name: "golang pre-release version is lower than minimum supported version",
sdkVersion: "v0.6.0-0.20240913163521-4910018031a7",
sdkLanguage: Go,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.6.0-0.20240913163521-4910018031a7 must be upgraded to at least 0.6.0-rc2, in order to work with current numaflow version",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading

0 comments on commit ed543ad

Please sign in to comment.