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

Integrate better with lucene test framework and mockfilesystems #10656

Merged
merged 58 commits into from
Apr 20, 2015
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6ac4d6d
contain filesystem access
rmuir Apr 15, 2015
fb481bc
Merge branch 'master' into mockfilesystem
rmuir Apr 15, 2015
4014526
ensure security manager is always on if it should be
rmuir Apr 16, 2015
e5a699f
cutover to lucenetestcase
rmuir Apr 16, 2015
4d44fa0
Fixed test using .getURI() for resource paths to use .getPath() inste…
rjernst Apr 16, 2015
93e591c
Enabled mockfs on base test class. All tests pass. Added suppressions
rjernst Apr 16, 2015
68267f4
these leaks are plugged
rmuir Apr 16, 2015
8ceb495
improve REPRODUCE WITH
rmuir Apr 16, 2015
370819a
Merge branch 'master' into mockfilesystem
rmuir Apr 16, 2015
bac99cc
note these test seeds for investigation
rmuir Apr 16, 2015
84b20c0
revert change to use .getPath(), it doens't work on windows
rjernst Apr 16, 2015
65367f5
fix many test bugs by minimizing URI handling
rmuir Apr 17, 2015
007e8f1
remove redundant confusing output
rmuir Apr 17, 2015
89b9f0e
Merge branch 'master' into mockfilesystem
rmuir Apr 17, 2015
c421948
upgrade to lucene 5.2 r1674278
rmuir Apr 17, 2015
2d9e5b4
fix FileSystemUtils failures
rmuir Apr 17, 2015
d08322e
disable WindowsFS for this test. unsure if its a problem on real wind…
rmuir Apr 17, 2015
7afa241
make stacktraces reasonable
rmuir Apr 17, 2015
5718e56
fail the build if you typo test name
rmuir Apr 17, 2015
57b5e06
disable extras for test, clean up some stragglers
rmuir Apr 17, 2015
b113fbd
fix nocommits
rmuir Apr 17, 2015
a985c97
suppress all filesystems here due to jimfs brokenness
rmuir Apr 17, 2015
c7c4045
speed up directory wrapping
rmuir Apr 17, 2015
e3e4c02
nobody wants to look at bytecode
rmuir Apr 17, 2015
e715535
remove tests.processors, this is a reproducibility nightmare
rmuir Apr 17, 2015
43b6cd2
Merge branch 'master' into mockfilesystem
rmuir Apr 17, 2015
0ff0a00
fix backwards test to not muck with URIs or get mad about extra clusters
rmuir Apr 17, 2015
84811a5
nuke ElasticsearchSingleNodeLuceneTestCase
rmuir Apr 18, 2015
aa381a2
fold ESTestCase into ElasticsearchTestCase
rmuir Apr 18, 2015
61b60da
nuke some unused stuff
rmuir Apr 18, 2015
a312098
nuke duplicate methods
rmuir Apr 18, 2015
52c4af6
remove these helpers
rmuir Apr 18, 2015
621f502
move bwc specific stuff to backcompat base class
rjernst Apr 18, 2015
96f08a3
parallelize rest tests
rmuir Apr 18, 2015
c7ce727
disable extras for this test
rmuir Apr 18, 2015
e4de0cb
removed jvm ordinal constant, only really needed now for test cluster
rjernst Apr 18, 2015
310e04b
Merge branch 'mockfilesystem' of github.com:elastic/elasticsearch int…
rjernst Apr 18, 2015
b27c7f0
suppress extrasfs from corrupted file test
rjernst Apr 18, 2015
d2854d7
mark slow tests with @Slow annotation
rmuir Apr 18, 2015
e91a7de
move rest and integration test annotations and sysprops to their resp…
rjernst Apr 18, 2015
d8a9294
removed some esoteric helper functions, shuffled methods around in ba…
rjernst Apr 18, 2015
ce6b377
move version related stuff to dedicated test utility
rjernst Apr 18, 2015
5bcd599
remove repo, latest randomizedtesting is on maven central now
rmuir Apr 18, 2015
d301567
let tests.verbose tell the story
rmuir Apr 18, 2015
06eee11
simplify version handling in rest tests, add tests for version utilities
rjernst Apr 18, 2015
c00f0ff
upgrade to lucene r1674576
rmuir Apr 18, 2015
b46df4d
suppress extrasfs from integ tests, fix bug in random version util
rjernst Apr 18, 2015
1378755
remove fixed seed for version util tests
rjernst Apr 18, 2015
b728772
more fine-grained @slow tuning, remove from many tests that got unluc…
rmuir Apr 18, 2015
22af0e6
cleanup order of before/after stuff, reorganize helper methods a bit
rjernst Apr 19, 2015
551d16f
[DOCS] Fix REST test execution line in testing documentation
s1monw Apr 19, 2015
c153772
ensure these two versions are always in sync
rmuir Apr 19, 2015
9e0a958
add more paranoia to PathUtils
rmuir Apr 19, 2015
68f75ea
simplified rest skip range version parsing more, ranges can now be open
rjernst Apr 19, 2015
b09d236
run tests with AssertingCodec to find bugs
rmuir Apr 19, 2015
2ed711f
mark just this method as @Slow, can easily take over a minute
rmuir Apr 19, 2015
069e11b
set heartbeat to 10s
rmuir Apr 19, 2015
a6c154a
Use dummy TermStatistics when term is not found Closes #10660
s1monw Apr 20, 2015
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
2 changes: 1 addition & 1 deletion TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The REST tests are run automatically when executing the maven test command. To r
REST tests use the following command:

---------------------------------------------------------------------------
mvn test -Dtests.class=org.elasticsearch.test.rest.ElasticsearchRestTests
mvn test -Dtests.filter="@Rest"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

---------------------------------------------------------------------------

`ElasticsearchRestTests` is the executable test class that runs all the
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/forbidden/all-signatures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ java.nio.file.Path#toFile()
@defaultMessage Don't use deprecated lucene apis
org.apache.lucene.index.DocsEnum
org.apache.lucene.index.DocsAndPositionsEnum

java.nio.file.Paths @ Use PathUtils.get instead.
java.nio.file.FileSystems#getDefault() @ use PathUtils.getDefault instead.
2 changes: 2 additions & 0 deletions dev-tools/forbidden/test-signatures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@

com.carrotsearch.randomizedtesting.RandomizedTest#globalTempDir() @ Use newTempDirPath() instead
com.carrotsearch.randomizedtesting.annotations.Seed @ Don't commit hardcoded seeds

org.apache.lucene.codecs.Codec#setDefault(org.apache.lucene.codecs.Codec) @ Use the SuppressCodecs("*") annotation instead
34 changes: 25 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@

<properties>
<lucene.version>5.2.0</lucene.version>
<lucene.maven.version>5.2.0-snapshot-1674183</lucene.maven.version>
<lucene.maven.version>5.2.0-snapshot-1674576</lucene.maven.version>
<testframework.version>2.1.14</testframework.version>
<tests.jvms>auto</tests.jvms>
<tests.shuffle>true</tests.shuffle>
<tests.output>onerror</tests.output>
<tests.client.ratio></tests.client.ratio>
<tests.bwc.path>${project.basedir}/backwards</tests.bwc.path>
<tests.locale>random</tests.locale>
<tests.timezone>random</tests.timezone>
<es.logger.level>INFO</es.logger.level>
<tests.slow>false</tests.slow>
<es.logger.level>ERROR</es.logger.level>
<tests.heap.size>512m</tests.heap.size>
<tests.heapdump.path>${basedir}/logs/</tests.heapdump.path>
<tests.topn>5</tests.topn>
Expand All @@ -66,7 +68,7 @@
<repository>
<id>lucene-snapshots</id>
<name>Lucene Snapshots</name>
<url>https://download.elastic.co/lucenesnapshots/1674183</url>
<url>https://download.elastic.co/lucenesnapshots/1674576</url>
</repository>
</repositories>

Expand All @@ -80,7 +82,7 @@
<dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
<version>2.1.13</version>
<version>${testframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -501,7 +503,7 @@
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
<version>2.1.13</version>
<version>${testframework.version}</version>
<executions>
<execution>
<id>tests</id>
Expand All @@ -510,9 +512,10 @@
<goal>junit4</goal>
</goals>
<configuration>
<heartbeat>20</heartbeat>
<heartbeat>10</heartbeat>
<jvmOutputAction>pipe,warn</jvmOutputAction>
<leaveTemporary>true</leaveTemporary>
<ifNoTests>fail</ifNoTests>
<listeners>
<report-ant-xml mavenExtensions="true"
dir="${project.build.directory}/surefire-reports"/>
Expand All @@ -525,7 +528,19 @@
showStatusFailure="true"
showStatusIgnored="true"
showSuiteSummary="true"
timestamps="false"/>
timestamps="false">
<filtertrace>
<!-- custom filters: we carefully only omit test infra noise here -->
<containsstring contains=".SlaveMain." />
<containsregex pattern="^(\s+at )(org\.junit\.)" />
<!-- also includes anonymous classes inside these two: -->
<containsregex pattern="^(\s+at )(com\.carrotsearch\.randomizedtesting.RandomizedRunner)" />
<containsregex pattern="^(\s+at )(com\.carrotsearch\.randomizedtesting.ThreadLeakControl)" />
<containsregex pattern="^(\s+at )(com\.carrotsearch\.randomizedtesting.rules\.)" />
<containsregex pattern="^(\s+at )(org\.apache\.lucene.util\.TestRule)" />
<containsregex pattern="^(\s+at )(org\.apache\.lucene.util\.AbstractBeforeAfterRule)" />
</filtertrace>
</report-text>
<report-execution-times historyLength="20" file="${basedir}/${execution.hint.file}"/>
</listeners>
<assertions>
Expand Down Expand Up @@ -561,7 +576,8 @@
<sysouts>${tests.verbose}</sysouts>
<seed>${tests.seed}</seed>
<haltOnFailure>${tests.failfast}</haltOnFailure>
<uniqueSuiteNames>false</uniqueSuiteNames>
<!-- enforce unique suite names, or reporting stuff can be screwed up -->
<uniqueSuiteNames>true</uniqueSuiteNames>
<systemProperties>
<!-- we use './temp' since this is per JVM and tests are forbidden from writing to CWD -->
<java.io.tmpdir>./temp</java.io.tmpdir>
Expand All @@ -570,7 +586,6 @@
<tests.bwc.path>${tests.bwc.path}</tests.bwc.path>
<tests.bwc.version>${tests.bwc.version}</tests.bwc.version>
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
<tests.processors>${tests.processors}</tests.processors>
<tests.appendseed>${tests.appendseed}</tests.appendseed>
<tests.iters>${tests.iters}</tests.iters>
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
Expand Down Expand Up @@ -1626,6 +1641,7 @@
<version>2.9</version>
<configuration>
<buildOutputDirectory>eclipse-build</buildOutputDirectory>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
</plugins>
Expand Down
19 changes: 11 additions & 8 deletions rest-api-spec/test/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ skipped, and the reason why the tests are skipped. For instance:
....
"Parent":
- skip:
version: "0 - 0.90.2"
version: "0.20.1 - 0.90.2"
reason: Delete ignores the parent param

- do:
Expand All @@ -75,14 +75,17 @@ skipped, and the reason why the tests are skipped. For instance:
All tests in the file following the skip statement should be skipped if:
`min <= current <= max`.

The `version` range should always have an upper bound. Versions should
either have each version part compared numerically, or should be converted
to a string with sufficient digits to allow string comparison, eg

0.90.2 -> 000-090-002
The `version` range can leave either bound empty, which means "open ended".
For instance:
....
"Parent":
- skip:
version: "1.0.0.Beta1 - "
reason: Delete ignores the parent param

Snapshot versions and versions of the form `1.0.0.Beta1` can be treated
as the rounded down version, eg `1.0.0`.
- do:
... test definitions ...
....

The skip section can also be used to list new features that need to be
supported in order to run a test. This way the up-to-date runners will
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/test/cluster.put_settings/10_basic.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
setup:
- skip:
version: 0 - 999
version: " - "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure this doesn't break the clients builds? @clintongormley WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javanna it does but we are on master we can do this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think " - " is an improvement over "0 - 999". I'd rather see some meaningful value, like all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question is if we want to have a "pending" test like this in the suite at all? Again, if yes, I'd like to have something semantic, like a pending: true flag, not a skip which needs to be deciphered?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karmi If you want a special all that is doable. I would rather have that then yet another flag like pending.

reason: leaves transient metadata behind, need to fix it
---
"Test put settings":
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/test/indices.get/10_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ setup:
"Should return test_index_3 if expand_wildcards=closed":

- skip:
version: "0 - 2.0.0"
version: " - 2.0.0"
reason: Requires fix for issue 7258

- do:
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/test/indices.get_aliases/10_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ setup:
"Getting alias on an non-existent index should return 404":

- skip:
version: 1 - 999
version: "1.0.0.Beta1 - "
reason: not implemented yet
- do:
catch: missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ setup:
---
"put settings in list of indices":
- skip:
version: 1 - 999
version: " - "
reason: list of indices not implemented yet
- do:
indices.put_settings:
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/test/update/85_fields_meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Metadata Fields":

- skip:
version: "0 - 999"
version: " - "
reason: "Update doesn't return metadata fields, waiting for #3259"

- do:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public static Version fromString(String version) {
}
String[] parts = version.split("\\.");
if (parts.length < 3 || parts.length > 4) {
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build");
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build: " + version);
}

try {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/elasticsearch/bootstrap/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.inject.CreationException;
import org.elasticsearch.common.inject.spi.Message;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.jna.Natives;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
Expand Down Expand Up @@ -153,7 +155,7 @@ public static void main(String[] args) {

if (pidFile != null) {
try {
PidFile.create(Paths.get(pidFile), true);
PidFile.create(PathUtils.get(pidFile), true);
} catch (Exception e) {
String errorMessage = buildErrorMessage("pid", e);
sysError(errorMessage, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
} else if (suffix != null) {
if (!isSameFile(file, path)) {
// If it already exists we try to copy this new version appending suffix to its name
path = Paths.get(path.toString().concat(suffix));
path = path.resolveSibling(path.getFileName().toString().concat(suffix));
// We just move the file to new dir but with a new name (appended with suffix)
Files.move(file, path, StandardCopyOption.REPLACE_EXISTING);
}
Expand Down Expand Up @@ -258,6 +258,8 @@ public static void move(Path source, Path destination) throws IOException {
Files.walkFileTree(source, new TreeCopier(source, destination, true));
}
}

// TODO: note that this will fail if source and target are on different NIO.2 filesystems.

static class TreeCopier extends SimpleFileVisitor<Path> {
private final Path source;
Expand Down
84 changes: 84 additions & 0 deletions src/main/java/org/elasticsearch/common/io/PathUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/

package org.elasticsearch.common.io;

import org.elasticsearch.common.SuppressForbidden;

import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
* Utilities for creating a Path from names,
* or accessing the default FileSystem.
* <p>
* This class allows the default filesystem to
* be changed during tests.
*/
@SuppressForbidden(reason = "accesses the default filesystem by design")
public final class PathUtils {
/** no instantiation */
private PathUtils() {}

/** the actual JDK default */
static final FileSystem ACTUAL_DEFAULT = FileSystems.getDefault();

/** can be changed by tests (via reflection) */
private static volatile FileSystem DEFAULT = ACTUAL_DEFAULT;

/**
* Returns a {@code Path} from name components.
* <p>
* This works just like {@code Paths.get()}.
* Remember: just like {@code Paths.get()} this is NOT A STRING CONCATENATION
* UTILITY FUNCTION.
* <p>
* Remember: this should almost never be used. Usually resolve
* a path against an existing one!
*/
public static Path get(String first, String... more) {
return DEFAULT.getPath(first, more);
}

/**
* Returns a {@code Path} from a URI
* <p>
* This works just like {@code Paths.get()}.
* <p>
* Remember: this should almost never be used. Usually resolve
* a path against an existing one!
*/
public static Path get(URI uri) {
if (uri.getScheme().equalsIgnoreCase("file")) {
return DEFAULT.provider().getPath(uri);
} else {
return Paths.get(uri);
}
}

/**
* Returns the default FileSystem.
*/
public static FileSystem getDefaultFileSystem() {
return DEFAULT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class EsExecutors {
*/
public static final String PROCESSORS = "processors";

/** Useful for testing */
public static final String DEFAULT_SYSPROP = "es.processors.override";

/**
* Returns the number of processors available but at most <tt>32</tt>.
*/
Expand All @@ -44,7 +47,11 @@ public static int boundedNumberOfProcessors(Settings settings) {
* ie. >= 48 create too many threads and run into OOM see #3478
* We just use an 32 core upper-bound here to not stress the system
* too much with too many created threads */
return settings.getAsInt(PROCESSORS, Math.min(32, Runtime.getRuntime().availableProcessors()));
int defaultValue = Math.min(32, Runtime.getRuntime().availableProcessors());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to document it but I wonder why we don't use the settings as we did before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to document it? Its just for tests. The idea is not to rely upon a bunch of test plumbing (like configuration) to always set it, its too fragile. with the base class setting a sysprop, we know its always set consistently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nevermind I didn't see what we still use the settings in the return statement.... all is well

try {
defaultValue = Integer.parseInt(System.getProperty(DEFAULT_SYSPROP));
} catch (Throwable ignored) {}
return settings.getAsInt(PROCESSORS, defaultValue);
}

public static PrioritizedEsThreadPoolExecutor newSinglePrioritizing(ThreadFactory threadFactory) {
Expand Down
Loading