mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -04:00
Apply precommit checks for non productive projects (#85533)
Ensure projects with only yaml, java or cluster tests also apply precommit checks. We only apply testingconventions now for projects with existing src test folder as the TestingConventionsTask is incompatible with projects with no test sourceSet. This is a prerequisite to port more projects away from using StandaloneRestTestPlugin and RestTestPlugin in favor of yaml, java or cluster tests with dedicated sourceSets. Also we fix deprecation warnings for forbiddenPattern and filePermissions tasks about implicit non declared dependencies on resources tasks
This commit is contained in:
parent
8d21fe9d9f
commit
718a241449
20 changed files with 161 additions and 128 deletions
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.gradle.internal;
|
package org.elasticsearch.gradle.internal;
|
||||||
|
|
||||||
|
import org.elasticsearch.gradle.internal.precommit.TestingConventionsPrecommitPlugin;
|
||||||
import org.elasticsearch.gradle.internal.precommit.TestingConventionsTasks;
|
import org.elasticsearch.gradle.internal.precommit.TestingConventionsTasks;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
|
@ -17,15 +18,22 @@ public class InternalPluginBuildPlugin implements InternalPlugin {
|
||||||
project.getPluginManager().apply(BuildPlugin.class);
|
project.getPluginManager().apply(BuildPlugin.class);
|
||||||
project.getPluginManager().apply(BaseInternalPluginBuildPlugin.class);
|
project.getPluginManager().apply(BaseInternalPluginBuildPlugin.class);
|
||||||
|
|
||||||
project.getTasks().withType(TestingConventionsTasks.class).named("testingConventions").configure(t -> {
|
project.getPlugins()
|
||||||
t.getNaming().clear();
|
.withType(
|
||||||
t.getNaming()
|
TestingConventionsPrecommitPlugin.class,
|
||||||
.create("Tests", testingConventionRule -> testingConventionRule.baseClass("org.apache.lucene.tests.util.LuceneTestCase"));
|
plugin -> project.getTasks().withType(TestingConventionsTasks.class).named("testingConventions").configure(t -> {
|
||||||
t.getNaming().create("IT", testingConventionRule -> {
|
t.getNaming().clear();
|
||||||
testingConventionRule.baseClass("org.elasticsearch.test.ESIntegTestCase");
|
t.getNaming()
|
||||||
testingConventionRule.baseClass("org.elasticsearch.test.rest.ESRestTestCase");
|
.create(
|
||||||
testingConventionRule.baseClass("org.elasticsearch.test.ESSingleNodeTestCase");
|
"Tests",
|
||||||
});
|
testingConventionRule -> testingConventionRule.baseClass("org.apache.lucene.tests.util.LuceneTestCase")
|
||||||
});
|
);
|
||||||
|
t.getNaming().create("IT", testingConventionRule -> {
|
||||||
|
testingConventionRule.baseClass("org.elasticsearch.test.ESIntegTestCase");
|
||||||
|
testingConventionRule.baseClass("org.elasticsearch.test.rest.ESRestTestCase");
|
||||||
|
testingConventionRule.baseClass("org.elasticsearch.test.ESSingleNodeTestCase");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,16 +32,19 @@ public class FilePermissionsPrecommitPlugin extends PrecommitPlugin implements I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskProvider<? extends Task> createTask(Project project) {
|
public TaskProvider<? extends Task> createTask(Project project) {
|
||||||
return project.getTasks()
|
return project.getTasks().register(FILEPERMISSIONS_TASK_NAME, FilePermissionsTask.class, t -> {
|
||||||
.register(
|
t.getSources()
|
||||||
FILEPERMISSIONS_TASK_NAME,
|
.addAll(
|
||||||
FilePermissionsTask.class,
|
providerFactory.provider(
|
||||||
filePermissionsTask -> filePermissionsTask.getSources()
|
() -> GradleUtils.getJavaSourceSets(project).stream().map(s -> s.getAllSource()).collect(Collectors.toList())
|
||||||
.addAll(
|
|
||||||
providerFactory.provider(
|
|
||||||
() -> GradleUtils.getJavaSourceSets(project).stream().map(s -> s.getAllSource()).collect(Collectors.toList())
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
);
|
||||||
|
t.dependsOn(
|
||||||
|
GradleUtils.getJavaSourceSets(project)
|
||||||
|
.stream()
|
||||||
|
.map(sourceSet -> sourceSet.getProcessResourcesTaskName())
|
||||||
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,12 @@ public class ForbiddenPatternsPrecommitPlugin extends PrecommitPlugin implements
|
||||||
() -> GradleUtils.getJavaSourceSets(project).stream().map(s -> s.getAllSource()).collect(Collectors.toList())
|
() -> GradleUtils.getJavaSourceSets(project).stream().map(s -> s.getAllSource()).collect(Collectors.toList())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
forbiddenPatternsTask.dependsOn(
|
||||||
|
GradleUtils.getJavaSourceSets(project)
|
||||||
|
.stream()
|
||||||
|
.map(sourceSet -> sourceSet.getProcessResourcesTaskName())
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
forbiddenPatternsTask.getRootDir().set(project.getRootDir());
|
forbiddenPatternsTask.getRootDir().set(project.getRootDir());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ public abstract class ForbiddenPatternsTask extends DefaultTask {
|
||||||
.exclude("**/*.zip")
|
.exclude("**/*.zip")
|
||||||
.exclude("**/*.jks")
|
.exclude("**/*.jks")
|
||||||
.exclude("**/*.crt")
|
.exclude("**/*.crt")
|
||||||
|
.exclude("**/*.p12")
|
||||||
.exclude("**/*.keystore")
|
.exclude("**/*.keystore")
|
||||||
.exclude("**/*.png")
|
.exclude("**/*.png")
|
||||||
// vim swap file - included here to stop the build falling over if you happen to have a file open :-|
|
// vim swap file - included here to stop the build falling over if you happen to have a file open :-|
|
||||||
|
|
|
@ -25,13 +25,22 @@ public class InternalPrecommitTasks {
|
||||||
project.getPluginManager().apply(ForbiddenPatternsPrecommitPlugin.class);
|
project.getPluginManager().apply(ForbiddenPatternsPrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(LicenseHeadersPrecommitPlugin.class);
|
project.getPluginManager().apply(LicenseHeadersPrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(FilePermissionsPrecommitPlugin.class);
|
project.getPluginManager().apply(FilePermissionsPrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(TestingConventionsPrecommitPlugin.class);
|
|
||||||
project.getPluginManager().apply(LoggerUsagePrecommitPlugin.class);
|
project.getPluginManager().apply(LoggerUsagePrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(JarHellPrecommitPlugin.class);
|
|
||||||
|
// TestingConventionsPlugin is incompatible with projects without
|
||||||
|
// test source sets. We wanna remove this plugin once we moved away from
|
||||||
|
// StandaloneRestTest plugin and RestTestPlugin. For apply this plugin only
|
||||||
|
// when tests are available.
|
||||||
|
// Long Term we want remove the need for most of this plugins functionality
|
||||||
|
// and not rely on multiple test tasks against a sourceSet.
|
||||||
|
if (project.file("src/test").exists()) {
|
||||||
|
project.getPluginManager().apply(TestingConventionsPrecommitPlugin.class);
|
||||||
|
}
|
||||||
|
|
||||||
// tasks with just tests don't need certain tasks to run, so this flag makes adding
|
// tasks with just tests don't need certain tasks to run, so this flag makes adding
|
||||||
// the task optional
|
// the task optional
|
||||||
if (withProductiveCode) {
|
if (withProductiveCode) {
|
||||||
|
project.getPluginManager().apply(JarHellPrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(ThirdPartyAuditPrecommitPlugin.class);
|
project.getPluginManager().apply(ThirdPartyAuditPrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(DependencyLicensesPrecommitPlugin.class);
|
project.getPluginManager().apply(DependencyLicensesPrecommitPlugin.class);
|
||||||
project.getPluginManager().apply(SplitPackagesAuditPrecommitPlugin.class);
|
project.getPluginManager().apply(SplitPackagesAuditPrecommitPlugin.class);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin;
|
||||||
import org.elasticsearch.gradle.internal.ElasticsearchTestBasePlugin;
|
import org.elasticsearch.gradle.internal.ElasticsearchTestBasePlugin;
|
||||||
import org.elasticsearch.gradle.internal.FixtureStop;
|
import org.elasticsearch.gradle.internal.FixtureStop;
|
||||||
import org.elasticsearch.gradle.internal.InternalTestClustersPlugin;
|
import org.elasticsearch.gradle.internal.InternalTestClustersPlugin;
|
||||||
|
import org.elasticsearch.gradle.internal.precommit.InternalPrecommitTasks;
|
||||||
import org.elasticsearch.gradle.test.SystemPropertyCommandLineArgumentProvider;
|
import org.elasticsearch.gradle.test.SystemPropertyCommandLineArgumentProvider;
|
||||||
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
|
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
|
||||||
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask;
|
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask;
|
||||||
|
@ -48,6 +49,7 @@ public class RestTestBasePlugin implements Plugin<Project> {
|
||||||
project.getPluginManager().apply(ElasticsearchJavaBasePlugin.class);
|
project.getPluginManager().apply(ElasticsearchJavaBasePlugin.class);
|
||||||
project.getPluginManager().apply(ElasticsearchTestBasePlugin.class);
|
project.getPluginManager().apply(ElasticsearchTestBasePlugin.class);
|
||||||
project.getPluginManager().apply(InternalTestClustersPlugin.class);
|
project.getPluginManager().apply(InternalTestClustersPlugin.class);
|
||||||
|
InternalPrecommitTasks.create(project, false);
|
||||||
project.getTasks().withType(RestIntegTestTask.class).configureEach(restIntegTestTask -> {
|
project.getTasks().withType(RestIntegTestTask.class).configureEach(restIntegTestTask -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
|
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
|
||||||
|
|
|
@ -138,6 +138,7 @@ public class PluginBuildPlugin implements Plugin<Project> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final var buildProperties = project.getTasks().register("pluginProperties", Copy.class, copy -> {
|
final var buildProperties = project.getTasks().register("pluginProperties", Copy.class, copy -> {
|
||||||
copy.dependsOn(copyPluginPropertiesTemplate);
|
copy.dependsOn(copyPluginPropertiesTemplate);
|
||||||
copy.from(templateFile);
|
copy.from(templateFile);
|
||||||
|
|
|
@ -20,7 +20,4 @@ dependencies {
|
||||||
compileOnly project(':modules:lang-painless:spi')
|
compileOnly project(':modules:lang-painless:spi')
|
||||||
api project(':libs:elasticsearch-grok')
|
api project(':libs:elasticsearch-grok')
|
||||||
api project(':libs:elasticsearch-dissect')
|
api project(':libs:elasticsearch-dissect')
|
||||||
}
|
}
|
||||||
|
|
||||||
//this plugin is here only for the painless extension, there are no unit tests
|
|
||||||
tasks.named("testingConventions").configure { enabled = false }
|
|
|
@ -40,7 +40,6 @@ testClusters.configureEach {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("test").configure { enabled = false }
|
tasks.named("test").configure { enabled = false }
|
||||||
tasks.named("jarHell").configure { enabled = false }
|
|
||||||
|
|
||||||
tasks.named("yamlRestTestV7CompatTransform").configure { task ->
|
tasks.named("yamlRestTestV7CompatTransform").configure { task ->
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,6 @@ tasks.named("dependencyLicenses").configure { enabled = false }
|
||||||
tasks.named("dependenciesInfo").configure { enabled = false }
|
tasks.named("dependenciesInfo").configure { enabled = false }
|
||||||
tasks.named("dependenciesGraph").configure { enabled = false }
|
tasks.named("dependenciesGraph").configure { enabled = false }
|
||||||
|
|
||||||
// no tests of the tests, yet
|
|
||||||
tasks.named("testingConventions").configure { enabled = false }
|
|
||||||
|
|
||||||
tasks.named("thirdPartyAudit").configure {
|
tasks.named("thirdPartyAudit").configure {
|
||||||
ignoreMissingClasses(
|
ignoreMissingClasses(
|
||||||
// classes are missing
|
// classes are missing
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
|
* 2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.eql;
|
package org.elasticsearch.xpack.eql;
|
||||||
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
|
|
||||||
createComposableTemplate(
|
createComposableTemplate(
|
||||||
client(),
|
client(),
|
||||||
randomAlphaOfLengthBetween(5, 10).toLowerCase(),
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
dataStream,
|
dataStream,
|
||||||
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null)
|
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null)
|
||||||
);
|
);
|
||||||
|
@ -125,7 +125,12 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
||||||
createNewSingletonPolicy(client(), policy, "cold", new SearchableSnapshotAction(snapshotRepo, true));
|
createNewSingletonPolicy(client(), policy, "cold", new SearchableSnapshotAction(snapshotRepo, true));
|
||||||
|
|
||||||
createComposableTemplate(client(), randomAlphaOfLengthBetween(5, 10).toLowerCase(), dataStream, new Template(null, null, null));
|
createComposableTemplate(
|
||||||
|
client(),
|
||||||
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
|
dataStream,
|
||||||
|
new Template(null, null, null)
|
||||||
|
);
|
||||||
|
|
||||||
for (int i = 0; i < randomIntBetween(5, 10); i++) {
|
for (int i = 0; i < randomIntBetween(5, 10); i++) {
|
||||||
indexDocument(client(), dataStream, true);
|
indexDocument(client(), dataStream, true);
|
||||||
|
@ -199,7 +204,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
|
|
||||||
createComposableTemplate(
|
createComposableTemplate(
|
||||||
client(),
|
client(),
|
||||||
randomAlphaOfLengthBetween(5, 10).toLowerCase(),
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
dataStream,
|
dataStream,
|
||||||
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null)
|
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null)
|
||||||
);
|
);
|
||||||
|
@ -289,7 +294,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
|
|
||||||
createComposableTemplate(
|
createComposableTemplate(
|
||||||
client(),
|
client(),
|
||||||
randomAlphaOfLengthBetween(5, 10).toLowerCase(),
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
dataStream,
|
dataStream,
|
||||||
new Template(
|
new Template(
|
||||||
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5).put(LifecycleSettings.LIFECYCLE_NAME, policy).build(),
|
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5).put(LifecycleSettings.LIFECYCLE_NAME, policy).build(),
|
||||||
|
@ -368,7 +373,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
|
|
||||||
createComposableTemplate(
|
createComposableTemplate(
|
||||||
client(),
|
client(),
|
||||||
randomAlphaOfLengthBetween(5, 10).toLowerCase(),
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
dataStream,
|
dataStream,
|
||||||
new Template(
|
new Template(
|
||||||
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5).put(LifecycleSettings.LIFECYCLE_NAME, policy).build(),
|
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5).put(LifecycleSettings.LIFECYCLE_NAME, policy).build(),
|
||||||
|
@ -628,7 +633,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
|
|
||||||
createComposableTemplate(
|
createComposableTemplate(
|
||||||
client(),
|
client(),
|
||||||
randomAlphaOfLengthBetween(5, 10).toLowerCase(),
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
dataStream,
|
dataStream,
|
||||||
new Template(
|
new Template(
|
||||||
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(LifecycleSettings.LIFECYCLE_NAME, policy).build(),
|
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(LifecycleSettings.LIFECYCLE_NAME, policy).build(),
|
||||||
|
@ -675,7 +680,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
||||||
|
|
||||||
createComposableTemplate(
|
createComposableTemplate(
|
||||||
client(),
|
client(),
|
||||||
randomAlphaOfLengthBetween(5, 10).toLowerCase(),
|
randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT),
|
||||||
dataStream,
|
dataStream,
|
||||||
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null)
|
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null)
|
||||||
);
|
);
|
||||||
|
|
|
@ -241,89 +241,89 @@ public class TrainedModelIT extends ESRestTestCase {
|
||||||
|
|
||||||
private void putRegressionModel(String modelId) throws IOException {
|
private void putRegressionModel(String modelId) throws IOException {
|
||||||
String modelConfig = """
|
String modelConfig = """
|
||||||
{
|
{
|
||||||
"definition": {
|
"definition": {
|
||||||
"trained_model": {
|
"trained_model": {
|
||||||
"ensemble": {
|
"ensemble": {
|
||||||
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
||||||
"trained_models": [{
|
"trained_models": [{
|
||||||
"tree": {
|
"tree": {
|
||||||
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
||||||
"tree_structure": [{
|
"tree_structure": [{
|
||||||
"threshold": 0.5,
|
"threshold": 0.5,
|
||||||
"split_feature": 0,
|
"split_feature": 0,
|
||||||
"node_index": 0,
|
"node_index": 0,
|
||||||
"left_child": 1,
|
"left_child": 1,
|
||||||
"right_child": 2
|
"right_child": 2
|
||||||
}, {
|
}, {
|
||||||
"node_index": 1,
|
"node_index": 1,
|
||||||
"leaf_value": [0.3]
|
"leaf_value": [0.3]
|
||||||
}, {
|
}, {
|
||||||
"threshold": 0.0,
|
"threshold": 0.0,
|
||||||
"split_feature": 3,
|
"split_feature": 3,
|
||||||
"node_index": 2,
|
"node_index": 2,
|
||||||
"left_child": 3,
|
"left_child": 3,
|
||||||
"right_child": 4
|
"right_child": 4
|
||||||
}, {
|
}, {
|
||||||
"node_index": 3,
|
"node_index": 3,
|
||||||
"leaf_value": [0.1]
|
"leaf_value": [0.1]
|
||||||
}, {
|
}, {
|
||||||
"node_index": 4,
|
"node_index": 4,
|
||||||
"leaf_value": [0.2]
|
"leaf_value": [0.2]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"tree": {
|
"tree": {
|
||||||
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
||||||
"tree_structure": [{
|
"tree_structure": [{
|
||||||
"threshold": 1.0,
|
"threshold": 1.0,
|
||||||
"split_feature": 2,
|
"split_feature": 2,
|
||||||
"node_index": 0,
|
"node_index": 0,
|
||||||
"left_child": 1,
|
"left_child": 1,
|
||||||
"right_child": 2
|
"right_child": 2
|
||||||
}, {
|
}, {
|
||||||
"node_index": 1,
|
"node_index": 1,
|
||||||
"leaf_value": [1.5]
|
"leaf_value": [1.5]
|
||||||
}, {
|
}, {
|
||||||
"node_index": 2,
|
"node_index": 2,
|
||||||
"leaf_value": [0.9]
|
"leaf_value": [0.9]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"tree": {
|
"tree": {
|
||||||
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
"feature_names": ["field.foo", "field.bar", "animal_cat", "animal_dog"],
|
||||||
"tree_structure": [{
|
"tree_structure": [{
|
||||||
"threshold": 0.2,
|
"threshold": 0.2,
|
||||||
"split_feature": 1,
|
"split_feature": 1,
|
||||||
"node_index": 0,
|
"node_index": 0,
|
||||||
"left_child": 1,
|
"left_child": 1,
|
||||||
"right_child": 2
|
"right_child": 2
|
||||||
}, {
|
}, {
|
||||||
"node_index": 1,
|
"node_index": 1,
|
||||||
"leaf_value": [1.5]
|
"leaf_value": [1.5]
|
||||||
}, {
|
}, {
|
||||||
"node_index": 2,
|
"node_index": 2,
|
||||||
"leaf_value": [0.9]
|
"leaf_value": [0.9]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"aggregate_output": {
|
"aggregate_output": {
|
||||||
"weighted_sum": {
|
"weighted_sum": {
|
||||||
"weights": [0.5, 0.5, 0.5]
|
"weights": [0.5, 0.5, 0.5]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"target_type": "regression"
|
"target_type": "regression"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"preprocessors": []
|
"preprocessors": []
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
"field_names": ["col1", "col2", "col3"]
|
"field_names": ["col1", "col2", "col3"]
|
||||||
},
|
},
|
||||||
"inference_config": {
|
"inference_config": {
|
||||||
"regression": {}
|
"regression": {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
Request model = new Request("PUT", "_ml/trained_models/" + modelId);
|
Request model = new Request("PUT", "_ml/trained_models/" + modelId);
|
||||||
|
|
|
@ -12,5 +12,3 @@ archivesBaseName = 'preallocate'
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly project(":server")
|
compileOnly project(":server")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("testingConventions").configure { enabled = false }
|
|
||||||
|
|
|
@ -47,6 +47,4 @@ subprojects {
|
||||||
nonInputProperties.systemProperty 'tests.audit.yesterday.logfile',
|
nonInputProperties.systemProperty 'tests.audit.yesterday.logfile',
|
||||||
"${-> testClusters.integTest.singleNode().getAuditLog().getParentFile()}/integTest_audit-${new Date().format('yyyy-MM-dd')}.json"
|
"${-> testClusters.integTest.singleNode().getAuditLog().getParentFile()}/integTest_audit-${new Date().format('yyyy-MM-dd')}.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("testingConventions").configure { enabled = false }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,5 +53,4 @@ subprojects {
|
||||||
"${-> testClusters.integTest.singleNode().getAuditLog().getParentFile()}/integTest_audit-${new Date().format('yyyy-MM-dd')}-1.json.gz"
|
"${-> testClusters.integTest.singleNode().getAuditLog().getParentFile()}/integTest_audit-${new Date().format('yyyy-MM-dd')}-1.json.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("testingConventions").configure { enabled = false }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ import static java.util.Collections.singletonMap;
|
||||||
/** Runs rest tests against external cluster */
|
/** Runs rest tests against external cluster */
|
||||||
// TODO: Remove this timeout increase once this test suite is broken up
|
// TODO: Remove this timeout increase once this test suite is broken up
|
||||||
@TimeoutSuite(millis = 60 * TimeUnits.MINUTE)
|
@TimeoutSuite(millis = 60 * TimeUnits.MINUTE)
|
||||||
public class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
|
public abstract class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
|
||||||
private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue(
|
private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue(
|
||||||
"x_pack_rest_user",
|
"x_pack_rest_user",
|
||||||
SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING
|
SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING
|
||||||
|
|
|
@ -11,7 +11,7 @@ File keystoreDir = new File(project.buildDir, 'keystore')
|
||||||
File nodeKey = file("$keystoreDir/testnode.pem")
|
File nodeKey = file("$keystoreDir/testnode.pem")
|
||||||
File nodeCert = file("$keystoreDir/testnode.crt")
|
File nodeCert = file("$keystoreDir/testnode.crt")
|
||||||
// Add key and certs to test classpath: it expects it there
|
// Add key and certs to test classpath: it expects it there
|
||||||
tasks.register("copyKeyCerts", Copy) {
|
def copyKeyCerts = tasks.register("copyKeyCerts", Copy) {
|
||||||
from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) {
|
from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) {
|
||||||
include 'testnode.crt', 'testnode.pem'
|
include 'testnode.crt', 'testnode.pem'
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.elasticsearch.xpack.core.transform.transforms.latest.LatestConfig;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -140,7 +141,7 @@ public class LatestContinuousIT extends ContinuousTestCase {
|
||||||
String transformBucketKey = eventFieldValue != null
|
String transformBucketKey = eventFieldValue != null
|
||||||
// The bucket key in source can be either an ordinary field or a runtime field. When it is runtime field, simulate its
|
// The bucket key in source can be either an ordinary field or a runtime field. When it is runtime field, simulate its
|
||||||
// script ("toUpperCase()") here.
|
// script ("toUpperCase()") here.
|
||||||
? "event".equals(eventField) ? eventFieldValue : eventFieldValue.toUpperCase()
|
? "event".equals(eventField) ? eventFieldValue : eventFieldValue.toUpperCase(Locale.ROOT)
|
||||||
: MISSING_BUCKET_KEY;
|
: MISSING_BUCKET_KEY;
|
||||||
|
|
||||||
// Verify that the results from the aggregation and the results from the transform are the same.
|
// Verify that the results from the aggregation and the results from the transform are the same.
|
||||||
|
|
|
@ -375,7 +375,8 @@ public class TransformContinuousIT extends TransformRestTestCase {
|
||||||
.startObject("script")
|
.startObject("script")
|
||||||
.field(
|
.field(
|
||||||
"source",
|
"source",
|
||||||
"if (doc['metric-timestamp'].size()!=0) {emit(doc['metric-timestamp'].value.minus(5, ChronoUnit.MINUTES).toInstant().toEpochMilli())}"
|
"if (doc['metric-timestamp'].size()!=0) {emit(doc['metric-timestamp'].value"
|
||||||
|
+ ".minus(5, ChronoUnit.MINUTES).toInstant().toEpochMilli())}"
|
||||||
)
|
)
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -384,7 +385,8 @@ public class TransformContinuousIT extends TransformRestTestCase {
|
||||||
.startObject("script")
|
.startObject("script")
|
||||||
.field(
|
.field(
|
||||||
"source",
|
"source",
|
||||||
"if (doc['some-timestamp'].size()!=0) {emit(doc['some-timestamp'].value.minus(10, ChronoUnit.MINUTES).toInstant().toEpochMilli())}"
|
"if (doc['some-timestamp'].size()!=0) {emit(doc['some-timestamp'].value"
|
||||||
|
+ ".minus(10, ChronoUnit.MINUTES).toInstant().toEpochMilli())}"
|
||||||
)
|
)
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue