diff --git a/build.gradle b/build.gradle index 5e28b27b9..2f6d80aa9 100644 --- a/build.gradle +++ b/build.gradle @@ -118,12 +118,8 @@ dependencies { test { include '**/*Tests.class' - systemProperty 'tests.security.manager', 'false' } -def opensearch_tmp_dir = rootProject.file('build/private/opensearch_tmp').absoluteFile -opensearch_tmp_dir.mkdirs() - jacocoTestReport { dependsOn test reports { @@ -140,8 +136,6 @@ task integTest(type: RestIntegTestTask) { tasks.named("check").configure { dependsOn(integTest) } integTest { - dependsOn "bundlePlugin" - // The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable if (System.getProperty("test.debug") != null) { jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' diff --git a/src/main/java/org/opensearch/flowframework/constant/CommonName.java b/src/main/java/org/opensearch/flowframework/constant/CommonName.java deleted file mode 100644 index 701fa6d8a..000000000 --- a/src/main/java/org/opensearch/flowframework/constant/CommonName.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ -package org.opensearch.flowframework.constant; - -/** - * Representation of common names that used across the project - */ -public class CommonName { - public static final String GLOBAL_CONTEXT_INDEX_NAME = ".opensearch-flow-framework-global-context"; - -} diff --git a/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java b/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java index 18495003c..d28678e2c 100644 --- a/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java +++ b/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java @@ -12,7 +12,6 @@ import java.util.function.Supplier; -import static org.opensearch.flowframework.constant.CommonName.GLOBAL_CONTEXT_INDEX_NAME; import static org.opensearch.flowframework.constant.CommonValue.GLOBAL_CONTEXT_INDEX; import static org.opensearch.flowframework.constant.CommonValue.GLOBAL_CONTEXT_INDEX_VERSION; diff --git a/src/main/java/org/opensearch/flowframework/indices/GlobalContextHandler.java b/src/main/java/org/opensearch/flowframework/indices/GlobalContextHandler.java index d18c9d20f..07b27a699 100644 --- a/src/main/java/org/opensearch/flowframework/indices/GlobalContextHandler.java +++ b/src/main/java/org/opensearch/flowframework/indices/GlobalContextHandler.java @@ -69,7 +69,7 @@ private void initGlobalContextIndexIfAbsent(ActionListener listener) { * @param template the use-case template * @param listener action listener */ - public void putTemplateToGlobalContext(Template template, ActionListener listener){ + public void putTemplateToGlobalContext(Template template, ActionListener listener) { initGlobalContextIndexIfAbsent(ActionListener.wrap(indexCreated -> { if (!indexCreated) { listener.onFailure(new FlowFrameworkException("No response to create global_context index")); diff --git a/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java b/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java index 295728a6e..69fb68bae 100644 --- a/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java +++ b/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java @@ -8,11 +8,6 @@ */ package org.opensearch.flowframework.indices; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; import org.opensearch.action.update.UpdateRequest; @@ -29,14 +24,18 @@ import org.opensearch.flowframework.workflow.CreateIndexStep; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; - -import static org.mockito.Mockito.*; -import static org.opensearch.flowframework.constant.CommonValue.GLOBAL_CONTEXT_INDEX; +import org.junit.Test; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.opensearch.flowframework.constant.CommonValue.GLOBAL_CONTEXT_INDEX; +import static org.mockito.Mockito.*; public class GlobalContextHandlerTests extends OpenSearchTestCase { @Mock @@ -105,4 +104,4 @@ public void testStoreResponseToGlobalContext() { assertEquals(GLOBAL_CONTEXT_INDEX, requestCaptor.getValue().index()); assertEquals(documentId, requestCaptor.getValue().id()); } -} \ No newline at end of file +} diff --git a/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java b/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java index 57c8acbd8..f02bd8a39 100644 --- a/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java +++ b/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java @@ -8,8 +8,6 @@ */ package org.opensearch.flowframework.workflow; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.client.AdminClient; @@ -25,6 +23,7 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.flowframework.indices.FlowFrameworkIndex; import org.opensearch.test.OpenSearchTestCase; +import org.opensearch.threadpool.ThreadPool; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -32,10 +31,11 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.mockito.ArgumentCaptor; -import org.opensearch.threadpool.ThreadPool; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; -import static org.mockito.Mockito.*; import static org.opensearch.flowframework.constant.CommonValue.*; +import static org.mockito.Mockito.*; public class CreateIndexStepTests extends OpenSearchTestCase { @@ -122,24 +122,24 @@ public void testInitIndexIfAbsent_IndexNotPresent() { verify(indicesAdminClient).create(any(), any()); } -// public void testInitIndexIfAbsent_IndexExist() { -// FlowFrameworkIndex index = FlowFrameworkIndex.GLOBAL_CONTEXT; -// indexMappingUpdated.put(index.getIndexName(), new AtomicBoolean(false)); -// -// when(metadata.hasIndex(index.getIndexName())).thenReturn(true); -// when(metadata.indices()).thenReturn(Map.of(index.getIndexName(), indexMetadata)); -// -// // Mock that the mapping's version is outdated, old version < new version -// when(indexMetadata.mapping()).thenReturn(new MappingMetadata(META, Map.of(SCHEMA_VERSION_FIELD, 0))); -// -// ActionListener listener = mock(ActionListener.class); -// createIndexStep.initIndexIfAbsent(index, listener); -// -// ArgumentCaptor captor = ArgumentCaptor.forClass(PutMappingRequest.class); -// verify(indicesAdminClient).putMapping(captor.capture()); -// -// PutMappingRequest capturedRequest = captor.getValue(); -// assertEquals(index.getIndexName(), capturedRequest.indices()[0]); -// } + // public void testInitIndexIfAbsent_IndexExist() { + // FlowFrameworkIndex index = FlowFrameworkIndex.GLOBAL_CONTEXT; + // indexMappingUpdated.put(index.getIndexName(), new AtomicBoolean(false)); + // + // when(metadata.hasIndex(index.getIndexName())).thenReturn(true); + // when(metadata.indices()).thenReturn(Map.of(index.getIndexName(), indexMetadata)); + // + // // Mock that the mapping's version is outdated, old version < new version + // when(indexMetadata.mapping()).thenReturn(new MappingMetadata(META, Map.of(SCHEMA_VERSION_FIELD, 0))); + // + // ActionListener listener = mock(ActionListener.class); + // createIndexStep.initIndexIfAbsent(index, listener); + // + // ArgumentCaptor captor = ArgumentCaptor.forClass(PutMappingRequest.class); + // verify(indicesAdminClient).putMapping(captor.capture()); + // + // PutMappingRequest capturedRequest = captor.getValue(); + // assertEquals(index.getIndexName(), capturedRequest.indices()[0]); + // } }