Skip to content

Commit

Permalink
fix: version compatibility check issue
Browse files Browse the repository at this point in the history
Signed-off-by: Keran Yang <[email protected]>
  • Loading branch information
KeranYang committed Sep 17, 2024
1 parent 692fbee commit 44372d9
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 32 deletions.
131 changes: 103 additions & 28 deletions pkg/sdkclient/serverinfo/serverinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,64 @@ 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",
errMessage: "numaflow version 1.1.6 must be upgraded to at least 1.1.7-z, in order to work with current SDK version",
},
{
name: "Test with empty MinimumNumaflowVersion field",
name: "Test with compatible numaflow version - min is a stable version 1.1.6",
numaflowVersion: "1.1.7",
minNumaflowVersion: "",
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: "server info does not contain minimum numaflow version. Upgrade to newer SDK version",
errMessage: "numaflow version 1.1.7-rc1 must be upgraded to at least 1.1.7-z, 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 compatible numaflow version",
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",
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",
minNumaflowVersion: "",
shouldErr: true,
errMessage: "server info does not contain minimum numaflow version. Upgrade to newer SDK version",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -132,10 +171,10 @@ func Test_CheckNumaflowCompatibility(t *testing.T) {

func Test_CheckSDKCompatibility(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,49 +185,85 @@ 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.0rc100, 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 release version is compatible with minimum supported version",
sdkVersion: "v0.6.0",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "python pre-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.0rc100, in order to work with current numaflow version",
},
{
name: "python release version is compatible with minimum supported version",
sdkVersion: "v0.6.0",
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
},
{
name: "Test with compatible Go version",
sdkVersion: "v0.6.0-rc2",
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: "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",
errMessage: "SDK version 0.0.3 must be upgraded to at least 0.1.0-z, in order to work with current numaflow version",
},
{
name: "Test with compatible Rust version",
sdkVersion: "v0.1.1",
sdkLanguage: Rust,
name: "java rc release version is lower than minimum supported version",
sdkVersion: "v0.6.0-rc1",
sdkLanguage: Java,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: false,
shouldErr: true,
errMessage: "SDK version 0.6.0-rc1 must be upgraded to at least 0.6.0-z, 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-z, in order to work with current numaflow version",
},
}
for _, tt := range tests {
Expand Down
46 changes: 42 additions & 4 deletions pkg/sdkclient/serverinfo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,49 @@ const (

type sdkConstraints map[Language]string

/*
minimumSupportedSDKVersions is the minimum supported version of each SDK for the current numaflow version.
It is used to check if the SDK is compatible with the current numaflow version.
Python SDK versioning follows PEP 440 (https://www.python.org/dev/peps/pep-0440/).
The other SDKs follow the semver versioning scheme (https://semver.org/).
How to update this map:
There are two types of releases, one is the stable release and the other is the pre-release.
Below are the typical formats of the versioning scheme:
+------------------+-------------------------+-----------------------------+
| | PEP 440 | semver |
+------------------+-------------------------+-----------------------------+
| stable | 0.8.0 | 0.8.0 |
+------------------+-------------------------+-----------------------------+
| pre-release | 0.8.0a1, | 0.8.0-rc1, |
| | 0.8.0b3, | 0.8.0-0.20240913163521, |
| | or 0.8.0rc1 | etc. |
+------------------+-------------------------+-----------------------------+
There are two cases to consider when updating the map:
1. The minimum supported version is a pre-release version.
In this case, directly put the exact pre-release version in the map.E.g.,
if the minimum supported version for java is "0.8.0-rc1", then put "0.8.0-rc1" for java.
"0.8.0b1", "0.8.0b1" for python.
2. The minimum supported version is a stable version.
In this case, put (almost) the largest available pre-release version of the stable version in the map.
E.g., if the minimum supported version is "0.8.0", then put "0.8.0-z" for java, go, rust, "0.8.0rc100" for python.
More details about version comparison can be found in the PEP 440 and semver documentation.
*/
var minimumSupportedSDKVersions = sdkConstraints{
Go: "0.8.0",
Python: "0.8.0",
Java: "0.8.0",
Rust: "0.1.0",
// meaning the minimum supported python SDK version is 0.8.0
Python: "0.8.0rc100",
// meaning the minimum supported go SDK version is 0.8.0
Go: "0.8.0-z",
// meaning the minimum supported java SDK version is 0.8.0
Java: "0.8.0-z",
// meaning the minimum supported rust SDK version is 0.8.0
Rust: "0.1.0-z",
}

type Protocol string
Expand Down

0 comments on commit 44372d9

Please sign in to comment.