Search in sources :

Example 1 with VersionUtils.randomVersion

use of org.opensearch.test.VersionUtils.randomVersion in project OpenSearch by opensearch-project.

the class PreBuiltAnalyzerTests method testThatInstancesAreCachedAndReused.

public void testThatInstancesAreCachedAndReused() {
    assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT), PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT));
    // same opensearch version should be cached
    Version v = VersionUtils.randomVersion(random());
    assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(v), PreBuiltAnalyzers.STANDARD.getAnalyzer(v));
    assertNotSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT), PreBuiltAnalyzers.STANDARD.getAnalyzer(VersionUtils.randomPreviousCompatibleVersion(random(), Version.CURRENT)));
    // Same Lucene version should be cached:
    assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(LegacyESVersion.fromId(6020199)), PreBuiltAnalyzers.STOP.getAnalyzer(LegacyESVersion.fromId(6020299)));
}
Also used : VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion) Version(org.opensearch.Version) LegacyESVersion(org.opensearch.LegacyESVersion)

Example 2 with VersionUtils.randomVersion

use of org.opensearch.test.VersionUtils.randomVersion in project OpenSearch by opensearch-project.

the class VersionTests method testMin.

public void testMin() {
    assertEquals(VersionUtils.getPreviousVersion(), Version.min(Version.CURRENT, VersionUtils.getPreviousVersion()));
    assertEquals(LegacyESVersion.fromString("7.0.1"), Version.min(LegacyESVersion.fromString("7.0.1"), Version.CURRENT));
    Version version = VersionUtils.randomVersion(random());
    Version version1 = VersionUtils.randomVersion(random());
    if (version.id <= version1.id) {
        assertEquals(version, Version.min(version1, version));
    } else {
        assertEquals(version1, Version.min(version1, version));
    }
}
Also used : VersionUtils.randomOpenSearchVersion(org.opensearch.test.VersionUtils.randomOpenSearchVersion) VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion)

Example 3 with VersionUtils.randomVersion

use of org.opensearch.test.VersionUtils.randomVersion in project OpenSearch by opensearch-project.

the class VersionTests method testMax.

public void testMax() {
    assertEquals(Version.CURRENT, Version.max(Version.CURRENT, VersionUtils.getPreviousVersion()));
    assertEquals(Version.CURRENT, Version.max(Version.fromString("1.0.1"), Version.CURRENT));
    Version version = VersionUtils.randomVersion(random());
    Version version1 = VersionUtils.randomVersion(random());
    if (version.id >= version1.id) {
        assertEquals(version, Version.max(version1, version));
    } else {
        assertEquals(version1, Version.max(version1, version));
    }
}
Also used : VersionUtils.randomOpenSearchVersion(org.opensearch.test.VersionUtils.randomOpenSearchVersion) VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion)

Aggregations

VersionUtils.randomVersion (org.opensearch.test.VersionUtils.randomVersion)3 VersionUtils.randomOpenSearchVersion (org.opensearch.test.VersionUtils.randomOpenSearchVersion)2 LegacyESVersion (org.opensearch.LegacyESVersion)1 Version (org.opensearch.Version)1