mirror of https://github.com/apache/lucene.git
Remove legacy ant hacks - add conf to test sourceSet. Correct jvm options hack (don't apply to benchmarks run).
This commit is contained in:
parent
89024a466b
commit
f83c9462bb
|
@ -170,7 +170,6 @@ apply from: file('gradle/help.gradle')
|
|||
// Ant-compatibility layer. ALL OF THESE SHOULD BE GONE at some point. They are
|
||||
// here so that we can coexist with current ant build but they are indicative
|
||||
// of potential problems with the build conventions, dependencies, etc.
|
||||
apply from: file('gradle/ant-compat/misc.gradle')
|
||||
apply from: file('gradle/ant-compat/test-classes-cross-deps.gradle')
|
||||
|
||||
apply from: file('gradle/documentation/documentation.gradle')
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Resources from top-level project folder are looked up via getClass(). Strange.
|
||||
configure(project(":lucene:benchmark")) {
|
||||
plugins.withType(JavaPlugin) {
|
||||
task syncConf(type: Sync) {
|
||||
from('conf')
|
||||
into file("${sourceSets.test.java.outputDir}/conf")
|
||||
}
|
||||
processTestResources.dependsOn syncConf
|
||||
}
|
||||
}
|
|
@ -30,7 +30,12 @@ allprojects {
|
|||
|
||||
// Inject vm options into any JavaExec task... We could narrow it
|
||||
// down but I don't think there is any harm in keeping it broad.
|
||||
tasks.withType(JavaExec) {
|
||||
tasks.withType(JavaExec) { task ->
|
||||
// Skip tuning java exec for benchmarks.
|
||||
if (task.path == ":lucene:benchmark:run") {
|
||||
return
|
||||
}
|
||||
|
||||
jvmArgs += vmOpts
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ plugins {
|
|||
id "java"
|
||||
}
|
||||
|
||||
description = 'System for benchmarking Lucene'
|
||||
description = 'Lucene benchmarking module'
|
||||
|
||||
dependencies {
|
||||
implementation project(':lucene:core')
|
||||
|
@ -43,9 +43,15 @@ dependencies {
|
|||
testImplementation project(':lucene:test-framework')
|
||||
}
|
||||
|
||||
// We add 'conf' to resources because we validate *.alg script correctness in one of the tests.
|
||||
sourceSets {
|
||||
test.resources.srcDirs += ['conf']
|
||||
}
|
||||
|
||||
task run(type: JavaExec) {
|
||||
description "Run a perf test (optional: -PtaskAlg=conf/your-algorithm-file -PmaxHeapSize=1G)"
|
||||
main 'org.apache.lucene.benchmark.byTask.Benchmark'
|
||||
|
||||
classpath sourceSets.main.runtimeClasspath
|
||||
// allow these to be specified on the CLI via -PtaskAlg= for example
|
||||
args = [propertyOrDefault('taskAlg', 'conf/micro-standard.alg')]
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.benchmark.byTask;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
|
@ -35,6 +36,7 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
|
|||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
|
||||
import org.junit.Assert;
|
||||
|
||||
/** Test very simply that perf tasks are parsed as expected. */
|
||||
@SuppressSysoutChecks(bugUrl = "very noisy")
|
||||
|
@ -122,9 +124,14 @@ public class TestPerfTasksParse extends LuceneTestCase {
|
|||
/** Test the parsing of example scripts * */
|
||||
@SuppressWarnings("try")
|
||||
public void testParseExamples() throws Exception {
|
||||
// hackedy-hack-hack
|
||||
|
||||
// Locate the folder with *.alg resources. This is hacky - we look up
|
||||
// one of the resources and then assume it's an accessible path.
|
||||
URL resource = getClass().getClassLoader().getResource("addIndexes.alg");
|
||||
Assert.assertNotNull("Couldn't locate *.alg resources?", resource);
|
||||
|
||||
boolean foundFiles = false;
|
||||
final Path examplesDir = Paths.get(getClass().getResource("/conf").toURI());
|
||||
final Path examplesDir = Paths.get(resource.toURI()).getParent();
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(examplesDir, "*.alg")) {
|
||||
for (Path path : stream) {
|
||||
Config config = new Config(Files.newBufferedReader(path, StandardCharsets.UTF_8));
|
||||
|
@ -152,10 +159,12 @@ public class TestPerfTasksParse extends LuceneTestCase {
|
|||
config.set("query.maker", MockQueryMaker.class.getName());
|
||||
}
|
||||
PerfRunData data = new PerfRunData(config);
|
||||
try (Algorithm algo = new Algorithm(data)) {}
|
||||
new Algorithm(data).close();
|
||||
|
||||
foundFiles = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundFiles) {
|
||||
fail("could not find any .alg files!");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue