Skip to content

Commit

Permalink
remove duplicate index name file
Browse files Browse the repository at this point in the history
Signed-off-by: Jackie Han <[email protected]>
  • Loading branch information
jackiehanyang committed Oct 2, 2023
1 parent 0be7ba0 commit 098a0e4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 57 deletions.
6 changes: 0 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void initGlobalContextIndexIfAbsent(ActionListener<Boolean> listener) {
* @param template the use-case template
* @param listener action listener
*/
public void putTemplateToGlobalContext(Template template, ActionListener<IndexResponse> listener){
public void putTemplateToGlobalContext(Template template, ActionListener<IndexResponse> listener) {
initGlobalContextIndexIfAbsent(ActionListener.wrap(indexCreated -> {
if (!indexCreated) {
listener.onFailure(new FlowFrameworkException("No response to create global_context index"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -105,4 +104,4 @@ public void testStoreResponseToGlobalContext() {
assertEquals(GLOBAL_CONTEXT_INDEX, requestCaptor.getValue().index());
assertEquals(documentId, requestCaptor.getValue().id());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,17 +23,19 @@
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;
import java.util.concurrent.ExecutionException;
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 {

Expand Down Expand Up @@ -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<Boolean> listener = mock(ActionListener.class);
// createIndexStep.initIndexIfAbsent(index, listener);
//
// ArgumentCaptor<PutMappingRequest> 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<Boolean> listener = mock(ActionListener.class);
// createIndexStep.initIndexIfAbsent(index, listener);
//
// ArgumentCaptor<PutMappingRequest> captor = ArgumentCaptor.forClass(PutMappingRequest.class);
// verify(indicesAdminClient).putMapping(captor.capture());
//
// PutMappingRequest capturedRequest = captor.getValue();
// assertEquals(index.getIndexName(), capturedRequest.indices()[0]);
// }

}

0 comments on commit 098a0e4

Please sign in to comment.