Skip to content

Commit

Permalink
Issue #LR-766 chore: upgraded the elasticsearch from 6.8.22 to 7.17.13 (
Browse files Browse the repository at this point in the history
  • Loading branch information
AmiableAnil authored Apr 12, 2024
1 parent 2dd227b commit e981b02
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 338 deletions.
6 changes: 5 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ version: 2.1
jobs:
build:
machine:
image: ubuntu-2004:202008-01
image: ubuntu-2004:202201-02
# https://circleci.com/docs/parallelism-faster-jobs/
# parallelism: 4
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large
steps:
- checkout
- restore_cache:
Expand Down
2 changes: 1 addition & 1 deletion core/es-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.8.22</version>
<version>7.17.13</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public static Map<String, Object> getSearchResponseMap(
long count = 0;
if (response != null) {
SearchHits hits = response.getHits();
count = hits.getTotalHits();
count = hits.getTotalHits().value;

for (SearchHit hit : hits) {
esSource.add(hit.getSourceAsMap());
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
package org.sunbird.common;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.doNothing;
import static org.powermock.api.mockito.PowerMockito.mock;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.bulk.BulkItemResponse;
Expand Down Expand Up @@ -49,6 +38,14 @@
import org.sunbird.util.PropertiesCache;
import scala.concurrent.Future;

import java.util.*;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.doNothing;
import static org.powermock.api.mockito.PowerMockito.mock;

/**
* Test class for Elastic search Rest High level client Impl
*
Expand Down Expand Up @@ -302,27 +299,27 @@ private static void mockRulesForBulk(boolean fail) {
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ActionListener<BulkResponse>) invocation.getArguments()[1])
((ActionListener<BulkResponse>) invocation.getArguments()[2])
.onResponse(response);
return null;
}
})
.when(client)
.bulkAsync(Mockito.any(), Mockito.any());
.bulkAsync(Mockito.any(), Mockito.any(), Mockito.any());
} else {

doAnswer(
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

((ActionListener<BulkResponse>) invocation.getArguments()[1])
((ActionListener<BulkResponse>) invocation.getArguments()[2])
.onFailure(new NullPointerException());
return null;
}
})
.when(client)
.bulkAsync(Mockito.any(), Mockito.any());
.bulkAsync(Mockito.any(), Mockito.any(), Mockito.any());
}
}

Expand All @@ -336,26 +333,26 @@ private static void mockRulesForSave(boolean fail) {
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ActionListener<IndexResponse>) invocation.getArguments()[1]).onResponse(ir);
((ActionListener<IndexResponse>) invocation.getArguments()[2]).onResponse(ir);
return null;
}
})
.when(client)
.indexAsync(Mockito.any(), Mockito.any());
.indexAsync(Mockito.any(), Mockito.any(), Mockito.any());
} else {

doAnswer(
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

((ActionListener<IndexResponse>) invocation.getArguments()[1])
((ActionListener<IndexResponse>) invocation.getArguments()[2])
.onFailure(new NullPointerException());
return null;
}
})
.when(client)
.indexAsync(Mockito.any(), Mockito.any());
.indexAsync(Mockito.any(), Mockito.any(), Mockito.any());
}
}

Expand All @@ -370,13 +367,13 @@ private static void mockRulesForUpdate(boolean fail) {
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ActionListener<UpdateResponse>) invocation.getArguments()[1])
((ActionListener<UpdateResponse>) invocation.getArguments()[2])
.onResponse(updateRes);
return null;
}
})
.when(client)
.updateAsync(Mockito.any(), Mockito.any());
.updateAsync(Mockito.any(), Mockito.any(), Mockito.any());
} else {

doAnswer(
Expand All @@ -385,13 +382,13 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

((ActionListener<UpdateResponse>) invocation.getArguments()[1])
((ActionListener<UpdateResponse>) invocation.getArguments()[2])
.onFailure(new NullPointerException());
return null;
}
})
.when(client)
.updateAsync(Mockito.any(), Mockito.any());
.updateAsync(Mockito.any(), Mockito.any(), Mockito.any());
}
}

Expand All @@ -410,27 +407,27 @@ private static void mockRulesForGet(boolean fail) {
@SuppressWarnings("unchecked")
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ActionListener<GetResponse>) invocation.getArguments()[1])
((ActionListener<GetResponse>) invocation.getArguments()[2])
.onResponse(getResponse);
return null;
}
})
.when(client)
.getAsync(Mockito.any(), Mockito.any());
.getAsync(Mockito.any(), Mockito.any(), Mockito.any());
} else {

doAnswer(
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

((ActionListener<GetResponse>) invocation.getArguments()[1])
((ActionListener<GetResponse>) invocation.getArguments()[2])
.onFailure(new NullPointerException());
return null;
}
})
.when(client)
.getAsync(Mockito.any(), Mockito.any());
.getAsync(Mockito.any(), Mockito.any(), Mockito.any());
}
}

Expand All @@ -446,27 +443,27 @@ private static void mockRulesForDelete(boolean fail, boolean notFound) {
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ActionListener<DeleteResponse>) invocation.getArguments()[1])
((ActionListener<DeleteResponse>) invocation.getArguments()[2])
.onResponse(delResponse);
return null;
}
})
.when(client)
.deleteAsync(Mockito.any(), Mockito.any());
.deleteAsync(Mockito.any(), Mockito.any(), Mockito.any());
} else {

doAnswer(
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

((ActionListener<DeleteResponse>) invocation.getArguments()[1])
((ActionListener<DeleteResponse>) invocation.getArguments()[2])
.onFailure(new NullPointerException());
return null;
}
})
.when(client)
.deleteAsync(Mockito.any(), Mockito.any());
.deleteAsync(Mockito.any(), Mockito.any(), Mockito.any());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import java.io.IOException;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.VelocityContext;
import org.sunbird.exception.ProjectCommonException;
Expand All @@ -21,6 +13,15 @@
import org.sunbird.request.Request;
import org.sunbird.request.RequestContext;

import java.io.IOException;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* This class will contains all the common utility methods.
*
Expand Down Expand Up @@ -231,25 +232,6 @@ public enum Method {
PATCH
}

/**
* Enum to hold the index name for Elastic search.
*
* @author Manzarul
*/
public enum EsIndex {
sunbird("searchindex");

private String indexName;

private EsIndex(String name) {
this.indexName = name;
}

public String getIndexName() {
return indexName;
}
}

/**
* This enum will hold all the ES type name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ public void testEsTypeSuccess() {
assertEquals("usernotes", ProjectUtil.EsType.usernotes.getTypeName());
}

@Test
public void testEsIndexSuccess() {
assertEquals("searchindex", ProjectUtil.EsIndex.sunbird.getIndexName());
}

@Test
public void testBulkProcessStatusSuccess() {
assertEquals(0, ProjectUtil.BulkProcessStatus.NEW.getValue());
Expand Down
Loading

0 comments on commit e981b02

Please sign in to comment.