Skip to content

Commit

Permalink
Few fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Sep 1, 2023
1 parent 98322fa commit 12775c3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,16 @@ public void testIndexTemplateWithAliases() throws Exception {

refresh();

SearchResponse searchResponse = client().prepareSearch("test_index").get();
SearchResponse searchResponse = client().prepareSearch("test_index").setPreference("_primary").get();
assertHitCount(searchResponse, 5L);

searchResponse = client().prepareSearch("simple_alias").get();
searchResponse = client().prepareSearch("simple_alias").setPreference("_primary").get();
assertHitCount(searchResponse, 5L);

searchResponse = client().prepareSearch("templated_alias-test_index").get();
searchResponse = client().prepareSearch("templated_alias-test_index").setPreference("_primary").get();
assertHitCount(searchResponse, 5L);

searchResponse = client().prepareSearch("filtered_alias").get();
searchResponse = client().prepareSearch("filtered_alias").setPreference("_primary").get();
assertHitCount(searchResponse, 1L);
assertThat(searchResponse.getHits().getAt(0).getSourceAsMap().get("type"), equalTo("type2"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ public void testAliasSearchRouting() throws Exception {
logger.info("--> search with no routing, should fine one");
for (int i = 0; i < 5; i++) {
assertThat(
client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
client().prepareSearch().setPreference("_primary").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value,
equalTo(1L)
);
}

logger.info("--> search with wrong routing, should not find");
for (int i = 0; i < 5; i++) {
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setRouting("1")
.setQuery(QueryBuilders.matchAllQuery())
.execute()
Expand All @@ -165,7 +165,7 @@ public void testAliasSearchRouting() throws Exception {
);

assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setSize(0)
.setRouting("1")
.setQuery(QueryBuilders.matchAllQuery())
Expand Down Expand Up @@ -202,7 +202,7 @@ public void testAliasSearchRouting() throws Exception {
for (int i = 0; i < 5; i++) {

assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setRouting("0")
.setQuery(QueryBuilders.matchAllQuery())
.execute()
Expand All @@ -212,7 +212,7 @@ public void testAliasSearchRouting() throws Exception {
equalTo(1L)
);
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setSize(0)
.setRouting("0")
.setQuery(QueryBuilders.matchAllQuery())
Expand Down Expand Up @@ -267,7 +267,7 @@ public void testAliasSearchRouting() throws Exception {
logger.info("--> search with 0 routing, should find one");
for (int i = 0; i < 5; i++) {
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setRouting("0")
.setQuery(QueryBuilders.matchAllQuery())
.execute()
Expand All @@ -277,7 +277,7 @@ public void testAliasSearchRouting() throws Exception {
equalTo(1L)
);
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setSize(0)
.setRouting("0")
.setQuery(QueryBuilders.matchAllQuery())
Expand Down Expand Up @@ -311,7 +311,7 @@ public void testAliasSearchRouting() throws Exception {
logger.info("--> search with 1 routing, should find one");
for (int i = 0; i < 5; i++) {
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setRouting("1")
.setQuery(QueryBuilders.matchAllQuery())
.execute()
Expand All @@ -321,7 +321,7 @@ public void testAliasSearchRouting() throws Exception {
equalTo(1L)
);
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setSize(0)
.setRouting("1")
.setQuery(QueryBuilders.matchAllQuery())
Expand Down Expand Up @@ -355,7 +355,7 @@ public void testAliasSearchRouting() throws Exception {
logger.info("--> search with 0,1 indexRoutings , should find two");
for (int i = 0; i < 5; i++) {
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setRouting("0", "1")
.setQuery(QueryBuilders.matchAllQuery())
.execute()
Expand All @@ -365,7 +365,7 @@ public void testAliasSearchRouting() throws Exception {
equalTo(2L)
);
assertThat(
client().prepareSearch()
client().prepareSearch().setPreference("_primary")
.setSize(0)
.setRouting("0", "1")
.setQuery(QueryBuilders.matchAllQuery())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ public void testStrictWeightedRoutingWithShardPref() throws Exception {
logger.info("--> making search requests");
for (int i = 0; i < 50; i++) {
responses[i] = internalCluster().client(nodeMap.get("b").get(0))
.prepareSearch("test")
.prepareSearch("test").setPreference("_primary")
.setPreference(String.format(Locale.ROOT, "_shards:%s", shardId.getId()))
.setSize(100)
.setQuery(QueryBuilders.matchAllQuery())
Expand Down Expand Up @@ -907,7 +907,7 @@ public void testSearchAggregationWithNetworkDisruption_FailOpenEnabled() throws
logger.info("--> making search requests");
for (int i = 0; i < 50; i++) {
responses[i] = internalCluster().client(nodeMap.get("b").get(0))
.prepareSearch("index")
.prepareSearch("index").setPreference("_primary")
.setSize(20)
.addAggregation(terms("f").field("f"))
.execute();
Expand Down Expand Up @@ -986,7 +986,7 @@ public void testMultiGetWithNetworkDisruption_FailOpenEnabled() throws Exception
for (int i = 0; i < 50; i++) {
index1 = randomIntBetween(0, 9);
index2 = randomIntBetween(0, 9);
responses[i] = client().prepareMultiGet()
responses[i] = client().prepareMultiGet().setPreference("_primary")
.add(new MultiGetRequest.Item("test", "" + index1))
.add(new MultiGetRequest.Item("test", "" + index2))
.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected boolean localExecute(Request request) {
return false;
}

protected abstract ClusterBlockException checkBlock(Request request, ClusterState state);
protected abstract ClusterBlockException checkBlock(Request request, ClusterState state) throws InterruptedException;

@Override
protected void doExecute(Task task, final Request request, ActionListener<Response> listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public ClusterTasksResult<Task> execute(ClusterState currentState, List<Task> jo
final DiscoveryNode node = joinTask.node();
if (joinTask.isBecomeClusterManagerTask() || joinTask.isFinishElectionTask()) {
// noop
} else if (currentNodes.nodeExists(node)) {
} else if (currentNodes.nodeExistsWithSameRoles(node)) {
logger.debug("received a join request for an existing node [{}]", node);
// TODO: Fix this by moving it out of this if condition, Had to add this code back here as this was
// leading to failure of JoinTaskExecutorTests::testUpdatesNodeWithNewRoles test.
if (node.isRemoteStoreNode()) {
Expand All @@ -199,8 +200,6 @@ public ClusterTasksResult<Task> execute(ClusterState currentState, List<Task> jo
remoteStoreService.updateClusterStateRepositoriesMetadata(new RemoteStoreNode(node), currentState)
);
}
} else if (currentNodes.nodeExistsWithSameRoles(node)) {
logger.debug("received a join request for an existing node [{}]", node);
} else {
try {
if (enforceMajorVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1969,9 +1969,6 @@ protected Settings nodeSettings(int nodeOrdinal) {
nodeAttributeSettings = remoteStoreGlobalNodeAttributes(REPOSITORY_NAME, REPOSITORY_2_NAME);
}
builder.put(nodeAttributeSettings);
builder.put(CLUSTER_REMOTE_STORE_ENABLED_SETTING.getKey(), true);
builder.put(CLUSTER_REMOTE_SEGMENT_STORE_REPOSITORY_SETTING.getKey(), REPOSITORY_NAME);
builder.put(CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING.getKey(), REPOSITORY_2_NAME);

// Enable tracer only when Telemetry Setting is enabled
if (featureFlagSettings().getAsBoolean(FeatureFlags.TELEMETRY_SETTING.getKey(), false)) {
Expand Down Expand Up @@ -2033,9 +2030,6 @@ public static Settings remoteStoreGlobalClusterSettings(
public static Settings remoteStoreGlobalClusterSettings(String segmentRepoName, String translogRepoName) {
return Settings.builder()
.put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT)
.put(CLUSTER_REMOTE_STORE_ENABLED_SETTING.getKey(), true)
.put(CLUSTER_REMOTE_SEGMENT_STORE_REPOSITORY_SETTING.getKey(), segmentRepoName)
.put(CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING.getKey(), translogRepoName)
.build();
}

Expand Down

0 comments on commit 12775c3

Please sign in to comment.