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

Fix BWC test suite #1426

Merged
merged 4 commits into from
Oct 4, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
import static org.opensearch.ml.common.input.parameter.clustering.KMeansParams.DistanceType.COSINE;

import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.apache.http.HttpEntity;
Expand Down Expand Up @@ -312,8 +318,26 @@ private String getModelIdWithFunctionName(FunctionName functionName) throws IOEx
return modelIdSet.iterator().next().toString();
}

/**
* This method compares our current ML plugin version
* to the older ML plugin version used in the BWC test,
* which is 2.4.0 at this time.
*/
private boolean isNewerVersion(String osVersion) {
return (Integer.parseInt(osVersion.substring(2, 3)) > 4) || (Integer.parseInt(osVersion.substring(0, 1)) > 2);
Integer olderMajorVersion = 2;
Integer olderMinorVersion = 4;
Pattern pattern = Pattern.compile("\\d+(?=\\.)");
Matcher matcher = pattern.matcher(osVersion);
// e.g. If current OS Version is "2.11.0", the osVersionArrayList will be like [2, 11].
ArrayList<Integer> osVersionArrayList = new ArrayList<>();
while (matcher.find()) {
osVersionArrayList.add(Integer.parseInt(matcher.group()));
}
if (osVersionArrayList.size() >= 2) {
return (osVersionArrayList.get(0) > olderMajorVersion || osVersionArrayList.get(1) > olderMinorVersion);
} else {
throw new IllegalArgumentException("osVersion is not valid, osVersion is: " + osVersion);
}
}

private void verifyMlResponse(String uri) throws Exception {
Expand Down
Loading