Skip to content

Commit

Permalink
Add UTs for getLuceneVersionForDocValuesUpdates()
Browse files Browse the repository at this point in the history
Signed-off-by: Bhumika Saini <sabhumik@amazon.com>
  • Loading branch information
Bhumika Saini committed Jul 20, 2023
1 parent 9605b3f commit 2c1e9c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public static long invertLong(String str) {
return Long.MAX_VALUE - num;
}

/**
* Extracts the Lucene major version from the provided DocValuesUpdates file name
* @param filename DocValuesUpdates file name to parse
* @return Lucene major version that wrote the DocValuesUpdates file
* @throws CorruptIndexException If the Lucene major version cannot be inferred
*/
public static int getLuceneVersionForDocValuesUpdates(String filename) throws CorruptIndexException {
// TODO: The following regex could work incorrectly if both major and minor versions are double-digits.
// This is because the major and minor versions do not have a separator in the filename currently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.index.remote;

import org.apache.lucene.index.CorruptIndexException;
import org.opensearch.test.OpenSearchTestCase;

public class RemoteStoreUtilsTests extends OpenSearchTestCase {
Expand Down Expand Up @@ -38,4 +39,12 @@ public void testinvert() {
assertEquals(num, RemoteStoreUtils.invertLong(RemoteStoreUtils.invertLong(num)));
}
}

public void testGetLuceneVersionForDocValuesUpdates() throws CorruptIndexException {
assertEquals(9, RemoteStoreUtils.getLuceneVersionForDocValuesUpdates("_0_1_Lucene90_0.dvm"));
}

public void testGetLuceneVersionForDocValuesUpdatesException() {
assertThrows(CorruptIndexException.class, () -> RemoteStoreUtils.getLuceneVersionForDocValuesUpdates("_0_1_Asserting_0.dvm"));
}
}

0 comments on commit 2c1e9c7

Please sign in to comment.