Skip to content

Commit

Permalink
Merge branch 'main' into doc_values_searching
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi authored Jan 23, 2024
2 parents bab3b96 + 4167ac5 commit 2fdb9f2
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bump `com.google.api:gax-httpjson` from 0.103.1 to 2.39.0 ([#11794](https://github.com/opensearch-project/OpenSearch/pull/11794))
- Bump `com.google.oauth-client:google-oauth-client` from 1.34.1 to 1.35.0 ([#11960](https://github.com/opensearch-project/OpenSearch/pull/11960))
- Bump `com.diffplug.spotless` from 6.23.2 to 6.24.0 ([#11962](https://github.com/opensearch-project/OpenSearch/pull/11962))
- Bump `com.google.cloud:google-cloud-core` from 2.5.10 to 2.30.0 ([#11961](https://github.com/opensearch-project/OpenSearch/pull/11961))

### Changed
- Mute the query profile IT with concurrent execution ([#9840](https://github.com/opensearch-project/OpenSearch/pull/9840))
Expand Down Expand Up @@ -210,6 +211,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Ensure Jackson default maximums introduced in 2.16.0 do not conflict with OpenSearch settings ([#11890](https://github.com/opensearch-project/OpenSearch/pull/11890))
- Extract cluster management for integration tests into JUnit test rule out of OpenSearchIntegTestCase ([#11877](https://github.com/opensearch-project/OpenSearch/pull/11877))
- Add ability for Boolean and date field queries to run when only doc_values are enabled ([#11650](https://github.com/opensearch-project/OpenSearch/pull/11650))
- Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2 ([#11968](https://github.com/opensearch-project/OpenSearch/pull/11968))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.opensearch.ingest.TestTemplateService;
import org.opensearch.test.OpenSearchTestCase;

import java.util.List;
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;

public class CopyProcessorTests extends OpenSearchTestCase {
Expand All @@ -26,8 +29,7 @@ public void testCopyExistingField() throws Exception {
processor.execute(ingestDocument);
assertThat(ingestDocument.hasField(targetFieldName), equalTo(true));
Object sourceValue = ingestDocument.getFieldValue(sourceFieldName, Object.class);
assertThat(ingestDocument.getFieldValue(targetFieldName, Object.class), equalTo(sourceValue));
assertThat(ingestDocument.getFieldValue(sourceFieldName, Object.class), equalTo(sourceValue));
assertDeepCopiedObjectEquals(ingestDocument.getFieldValue(targetFieldName, Object.class), sourceValue);

Processor processorWithEmptyTarget = createCopyProcessor(sourceFieldName, "", false, false, false);
assertThrows(
Expand Down Expand Up @@ -75,7 +77,7 @@ public void testCopyWithRemoveSource() throws Exception {
Processor processor = createCopyProcessor(sourceFieldName, targetFieldName, false, true, false);
processor.execute(ingestDocument);
assertThat(ingestDocument.hasField(targetFieldName), equalTo(true));
assertThat(ingestDocument.getFieldValue(targetFieldName, Object.class), equalTo(sourceValue));
assertDeepCopiedObjectEquals(ingestDocument.getFieldValue(targetFieldName, Object.class), sourceValue);
assertThat(ingestDocument.hasField(sourceFieldName), equalTo(false));
}

Expand All @@ -97,12 +99,30 @@ public void testCopyToExistingField() throws Exception {
Processor processorWithTargetNullValue = createCopyProcessor(sourceFieldName, targetFieldWithNullValue, false, false, false);
processorWithTargetNullValue.execute(ingestDocument);
assertThat(ingestDocument.hasField(targetFieldWithNullValue), equalTo(true));
assertThat(ingestDocument.getFieldValue(targetFieldWithNullValue, Object.class), equalTo(sourceValue));
assertDeepCopiedObjectEquals(ingestDocument.getFieldValue(targetFieldWithNullValue, Object.class), sourceValue);

Processor processorWithOverrideTargetIsTrue = createCopyProcessor(sourceFieldName, targetFieldName, false, false, true);
processorWithOverrideTargetIsTrue.execute(ingestDocument);
assertThat(ingestDocument.hasField(targetFieldName), equalTo(true));
assertThat(ingestDocument.getFieldValue(targetFieldName, Object.class), equalTo(sourceValue));
assertDeepCopiedObjectEquals(ingestDocument.getFieldValue(targetFieldName, Object.class), sourceValue);
}

@SuppressWarnings("unchecked")
private static void assertDeepCopiedObjectEquals(Object expected, Object actual) {
if (expected instanceof Map) {
Map<String, Object> expectedMap = (Map<String, Object>) expected;
Map<String, Object> actualMap = (Map<String, Object>) actual;
assertEquals(expectedMap.size(), actualMap.size());
for (Map.Entry<String, Object> expectedEntry : expectedMap.entrySet()) {
assertDeepCopiedObjectEquals(expectedEntry.getValue(), actualMap.get(expectedEntry.getKey()));
}
} else if (expected instanceof List) {
assertArrayEquals(((List<?>) expected).toArray(), ((List<?>) actual).toArray());
} else if (expected instanceof byte[]) {
assertArrayEquals((byte[]) expected, (byte[]) actual);
} else {
assertEquals(expected, actual);
}
}

private static Processor createCopyProcessor(
Expand Down
2 changes: 1 addition & 1 deletion plugins/repository-gcs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
api "com.google.auth:google-auth-library-credentials:${versions.google_auth}"
api "com.google.auth:google-auth-library-oauth2-http:${versions.google_auth}"

api 'com.google.cloud:google-cloud-core:2.5.10'
api 'com.google.cloud:google-cloud-core:2.30.0'
api 'com.google.cloud:google-cloud-core-http:2.23.0'
api 'com.google.cloud:google-cloud-storage:1.113.1'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b48ea27cbdccd5f225d8a35ea28e2cd01c25918b

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,30 @@ public boolean offer(E e) {
}
}

/**
* Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2.
*/
@Override
public void put(E e) {
super.offer(e);
}

/**
* Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2.
*/
@Override
public boolean offer(E e, long timeout, TimeUnit unit) {
return super.offer(e);
}

/**
* Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2.
*/
@Override
public boolean add(E e) {
return super.offer(e);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final class RestRemoteClusterInfoAction extends BaseRestHandler {

@Override
public List<Route> routes() {
return singletonList(new Route(GET, "_remote/info"));
return singletonList(new Route(GET, "/_remote/info"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public class RestPutMappingAction extends BaseRestHandler {
public List<Route> routes() {
return unmodifiableList(
asList(
new Route(POST, "/{index}/_mapping/"),
new Route(PUT, "/{index}/_mapping/"),
new Route(POST, "/{index}/_mappings/"),
new Route(PUT, "/{index}/_mappings/")
new Route(POST, "/{index}/_mapping"),
new Route(PUT, "/{index}/_mapping"),
new Route(POST, "/{index}/_mappings"),
new Route(PUT, "/{index}/_mappings")
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;

/**
* Tests for OpenSearchExecutors and its components like OpenSearchAbortPolicy.
Expand Down Expand Up @@ -279,6 +280,41 @@ public void testScaleDown() throws Exception {
terminate(pool);
}

/**
* The test case is adapted from https://bugs.openjdk.org/browse/JDK-8323659 reproducer.
*/
public void testScaleUpWithSpawningTask() throws Exception {
ThreadPoolExecutor pool = OpenSearchExecutors.newScaling(
getClass().getName() + "/" + getTestName(),
0,
1,
between(1, 100),
randomTimeUnit(),
OpenSearchExecutors.daemonThreadFactory("test"),
threadContext
);
assertThat("Min property", pool.getCorePoolSize(), equalTo(0));
assertThat("Max property", pool.getMaximumPoolSize(), equalTo(1));

final CountDownLatch latch = new CountDownLatch(10);
class TestTask implements Runnable {
@Override
public void run() {
latch.countDown();
if (latch.getCount() > 0) {
pool.execute(TestTask.this);
}
}
}
pool.execute(new TestTask());
latch.await();

assertThat("wrong pool size", pool.getPoolSize(), lessThanOrEqualTo(1));
assertThat("wrong active size", pool.getActiveCount(), lessThanOrEqualTo(1));

terminate(pool);
}

public void testRejectionMessageAndShuttingDownFlag() throws InterruptedException {
int pool = between(1, 10);
int queue = between(0, 100);
Expand Down

0 comments on commit 2fdb9f2

Please sign in to comment.