Skip to content

Commit 094cce8

Browse files
authored
Skip ML tests on later glibc for incompatible BWC versions (elastic#87476) (elastic#87484)
1 parent b5669c8 commit 094cce8

File tree

6 files changed

+69
-19
lines changed

6 files changed

+69
-19
lines changed

.ci/scripts/run-gradle.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ if pwd | grep -v -q ^/dev/shm ; then
1919
echo "Not running on a ramdisk, reducing number of workers"
2020
MAX_WORKERS=$(($MAX_WORKERS*2/3))
2121
fi
22+
23+
# Export glibc version as environment variable since some BWC tests are incompatible with later versions
24+
export GLIBC_VERSION=$(ldd --version | grep '^ldd' | sed 's/.* \([1-9]\.[0-9]*\).*/\1/')
25+
2226
set -e
2327
$GRADLEW -S --max-workers=$MAX_WORKERS $@

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcVersions.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.HashSet;
1919
import java.util.List;
2020
import java.util.Map;
21+
import java.util.Optional;
2122
import java.util.Set;
2223
import java.util.TreeMap;
2324
import java.util.TreeSet;
@@ -67,6 +68,7 @@ public class BwcVersions {
6768
"\\W+public static final Version V_(\\d+)_(\\d+)_(\\d+)(_alpha\\d+|_beta\\d+|_rc\\d+)? .*?LUCENE_(\\d+)_(\\d+)_(\\d+)\\);"
6869
);
6970
private static final Version MINIMUM_WIRE_COMPATIBLE_VERSION = Version.fromString("7.17.0");
71+
private static final String GLIBC_VERSION_ENV_VAR = "GLIBC_VERSION";
7072

7173
private final VersionPair currentVersion;
7274
private final List<VersionPair> versions;
@@ -308,4 +310,26 @@ public int compareTo(VersionPair o) {
308310
return this.elasticsearch.compareTo(o.elasticsearch);
309311
}
310312
}
313+
314+
/**
315+
* Determine whether the given version of Elasticsearch is compatible with ML features on the host system.
316+
*
317+
* @see <a href="https://github.com/elastic/elasticsearch/issues/86877">https://github.com/elastic/elasticsearch/issues/86877</a>
318+
*/
319+
public static boolean isMlCompatible(Version version) {
320+
Version glibcVersion = Optional.ofNullable(System.getenv(GLIBC_VERSION_ENV_VAR))
321+
.map(v -> Version.fromString(v, Version.Mode.RELAXED))
322+
.orElse(null);
323+
324+
// glibc version 2.35 introduced incompatibilities in ML syscall filters that were fixed in 7.17.5+ and 8.2.2+
325+
if (glibcVersion != null && glibcVersion.onOrAfter(Version.fromString("2.35", Version.Mode.RELAXED))) {
326+
if (version.before(Version.fromString("7.17.5"))) {
327+
return false;
328+
} else if (version.getMajor() > 7 && version.before(Version.fromString("8.2.2"))) {
329+
return false;
330+
}
331+
}
332+
333+
return true;
334+
}
311335
}

build-tools/src/main/java/org/elasticsearch/gradle/Version.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public enum Mode {
4141
private static final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(?:-(alpha\\d+|beta\\d+|rc\\d+|SNAPSHOT))?");
4242

4343
private static final Pattern relaxedPattern = Pattern.compile(
44-
"v?(\\d+)\\.(\\d+)\\.(\\d+)(?:[\\-+]+([a-zA-Z0-9_]+(?:-[a-zA-Z0-9]+)*))?"
44+
"v?(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:[\\-+]+([a-zA-Z0-9_]+(?:-[a-zA-Z0-9]+)*))?"
4545
);
4646

4747
public Version(int major, int minor, int revision) {
@@ -73,14 +73,12 @@ public static Version fromString(final String s, final Mode mode) {
7373
throw new IllegalArgumentException("Invalid version format: '" + s + "'. Should be " + expected);
7474
}
7575

76+
String major = matcher.group(1);
77+
String minor = matcher.group(2);
78+
String revision = matcher.group(3);
7679
String qualifier = matcher.group(4);
7780

78-
return new Version(
79-
Integer.parseInt(matcher.group(1)),
80-
Integer.parseInt(matcher.group(2)),
81-
Integer.parseInt(matcher.group(3)),
82-
qualifier
83-
);
81+
return new Version(Integer.parseInt(major), Integer.parseInt(minor), revision == null ? 0 : Integer.parseInt(revision), qualifier);
8482
}
8583

8684
@Override

build-tools/src/test/java/org/elasticsearch/gradle/VersionTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public void testRelaxedVersionParsing() {
4242
assertVersionEquals("6.1.2-foo-bar", 6, 1, 2, Version.Mode.RELAXED);
4343
assertVersionEquals("16.01.22", 16, 1, 22, Version.Mode.RELAXED);
4444
assertVersionEquals("20.10.10+dfsg1", 20, 10, 10, Version.Mode.RELAXED);
45+
assertVersionEquals("2.15", 2, 15, 0, Version.Mode.RELAXED);
4546
}
4647

4748
public void testCompareWithStringVersions() {

x-pack/plugin/build.gradle

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@ tasks.named("processYamlRestTestResources").configure {
6060
dependsOn("copyExtraResources")
6161
}
6262
def restTestBlacklist = []
63-
tasks.withType(RestIntegTestTask).configureEach {
64-
// TODO: fix this rest test to not depend on a hardcoded port!
65-
restTestBlacklist.addAll(['getting_started/10_monitor_cluster_health/*'])
66-
if (BuildParams.isSnapshotBuild() == false) {
67-
// these tests attempt to install basic/internal licenses signed against the dev/public.key
68-
// Since there is no infrastructure in place (anytime soon) to generate licenses using the production
69-
// private key, these tests are blacklisted in non-snapshot test runs
70-
restTestBlacklist.addAll(['xpack/15_basic/*', 'license/20_put_license/*', 'license/30_enterprise_license/*'])
71-
}
63+
// TODO: fix this rest test to not depend on a hardcoded port!
64+
restTestBlacklist.addAll(['getting_started/10_monitor_cluster_health/*'])
65+
if (BuildParams.isSnapshotBuild() == false) {
66+
// these tests attempt to install basic/internal licenses signed against the dev/public.key
67+
// Since there is no infrastructure in place (anytime soon) to generate licenses using the production
68+
// private key, these tests are blacklisted in non-snapshot test runs
69+
restTestBlacklist.addAll(['xpack/15_basic/*', 'license/20_put_license/*', 'license/30_enterprise_license/*'])
7270
}
7371

7472
tasks.named("yamlRestTest").configure {

x-pack/qa/rolling-upgrade/build.gradle

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import org.elasticsearch.gradle.Version
2-
import org.elasticsearch.gradle.VersionProperties
2+
import org.elasticsearch.gradle.internal.BwcVersions
33
import org.elasticsearch.gradle.internal.info.BuildParams
44
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
55

@@ -121,6 +121,12 @@ BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
121121
systemProperty 'tests.path.searchable.snapshots.repo', searchableSnapshotRepository
122122
nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c->c.allHttpSocketURI.join(",")))
123123
nonInputProperties.systemProperty('tests.clustername', baseName)
124+
125+
// Disable ML tests for incompatible systems
126+
if (BwcVersions.isMlCompatible(bwcVersion) == false) {
127+
exclude '**/MlJobSnapshotUpgradeIT.class', '**/MlMappingsUpgradeIT.class', '**/MLModelDeploymentsUpgradeIT.class', '**/MlTrainedModelsUpgradeIT.class'
128+
systemProperty 'tests.rest.blacklist', ['old_cluster/30_ml_jobs_crud/*', 'old_cluster/40_ml_datafeed_crud/*', 'old_cluster/90_ml_data_frame_analytics_crud'].join(',')
129+
}
124130
}
125131

126132
tasks.register("${baseName}#oneThirdUpgradedTest", StandaloneRestIntegTestTask) {
@@ -136,7 +142,7 @@ BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
136142
systemProperty 'tests.upgrade_from_version', oldVersion
137143
systemProperty 'tests.path.searchable.snapshots.repo', searchableSnapshotRepository
138144
// We only need to run these tests once so we may as well do it when we're two thirds upgraded
139-
systemProperty 'tests.rest.blacklist', [
145+
def excludeList = [
140146
'mixed_cluster/10_basic/Start scroll in mixed cluster on upgraded node that we will continue after upgrade',
141147
'mixed_cluster/30_ml_jobs_crud/Create a job in the mixed cluster and write some data',
142148
'mixed_cluster/40_ml_datafeed_crud/Put job and datafeed in mixed cluster',
@@ -149,7 +155,14 @@ BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
149155
'mixed_cluster/120_api_key/Test API key authentication will work in a mixed cluster',
150156
'mixed_cluster/120_api_key/Create API key with metadata in a mixed cluster',
151157
'mixed_cluster/130_operator_privileges/Test operator privileges will work in the mixed cluster'
152-
].join(',')
158+
]
159+
160+
// Disable ML tests for incompatible systems
161+
if (BwcVersions.isMlCompatible(bwcVersion) == false) {
162+
exclude '**/MlJobSnapshotUpgradeIT.class', '**/MlMappingsUpgradeIT.class', '**/MLModelDeploymentsUpgradeIT.class', '**/MlTrainedModelsUpgradeIT.class'
163+
excludeList.addAll(['mixed_cluster/30_ml_jobs_crud/*', 'mixed_cluster/40_ml_datafeed_crud/*', 'mixed_cluster/90_ml_data_frame_analytics_crud'])
164+
}
165+
systemProperty 'tests.rest.blacklist', excludeList.join(',')
153166
}
154167

155168
tasks.register("${baseName}#twoThirdsUpgradedTest", StandaloneRestIntegTestTask) {
@@ -164,6 +177,12 @@ BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
164177
systemProperty 'tests.first_round', 'false'
165178
systemProperty 'tests.upgrade_from_version', oldVersion
166179
systemProperty 'tests.path.searchable.snapshots.repo', searchableSnapshotRepository
180+
181+
// Disable ML tests for incompatible systems
182+
if (BwcVersions.isMlCompatible(bwcVersion) == false) {
183+
exclude '**/MlJobSnapshotUpgradeIT.class', '**/MlMappingsUpgradeIT.class', '**/MLModelDeploymentsUpgradeIT.class', '**/MlTrainedModelsUpgradeIT.class'
184+
systemProperty 'tests.rest.blacklist', ['mixed_cluster/30_ml_jobs_crud/*', 'mixed_cluster/40_ml_datafeed_crud/*', 'mixed_cluster/90_ml_data_frame_analytics_crud'].join(',')
185+
}
167186
}
168187

169188
tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) {
@@ -177,6 +196,12 @@ BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
177196
systemProperty 'tests.rest.suite', 'upgraded_cluster'
178197
systemProperty 'tests.upgrade_from_version', oldVersion
179198
systemProperty 'tests.path.searchable.snapshots.repo', searchableSnapshotRepository
199+
200+
// Disable ML tests for incompatible systems
201+
if (BwcVersions.isMlCompatible(bwcVersion) == false) {
202+
exclude '**/MlJobSnapshotUpgradeIT.class', '**/MlMappingsUpgradeIT.class', '**/MLModelDeploymentsUpgradeIT.class', '**/MlTrainedModelsUpgradeIT.class'
203+
systemProperty 'tests.rest.blacklist', ['upgraded_cluster/30_ml_jobs_crud/*', 'upgraded_cluster/40_ml_datafeed_crud/*', 'upgraded_cluster/90_ml_data_frame_analytics_crud'].join(',')
204+
}
180205
}
181206

182207
tasks.register(bwcTaskName(bwcVersion)) {

0 commit comments

Comments
 (0)