Skip to content

Commit 9033742

Browse files
committed
Defer ITs
Signed-off-by: Lakshya Taragi <lakshya.taragi@gmail.com>
1 parent 8a5ef58 commit 9033742

File tree

2 files changed

+2
-268
lines changed

2 files changed

+2
-268
lines changed

server/src/internalClusterTest/java/org/opensearch/remotemigration/RemoteStoreMigrationShardAllocationBaseTestCase.java

+2-141
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,20 @@
88

99
package org.opensearch.remotemigration;
1010

11-
import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplanation;
1211
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
1312
import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
14-
import org.opensearch.action.support.ActiveShardCount;
1513
import org.opensearch.cluster.metadata.IndexMetadata;
1614
import org.opensearch.cluster.node.DiscoveryNode;
1715
import org.opensearch.cluster.node.DiscoveryNodes;
1816
import org.opensearch.cluster.routing.IndexShardRoutingTable;
1917
import org.opensearch.cluster.routing.ShardRouting;
20-
import org.opensearch.cluster.routing.ShardRoutingState;
21-
import org.opensearch.cluster.routing.allocation.AllocateUnassignedDecision;
22-
import org.opensearch.cluster.routing.allocation.MoveDecision;
23-
import org.opensearch.cluster.routing.allocation.NodeAllocationResult;
24-
import org.opensearch.cluster.routing.allocation.decider.Decision;
25-
import org.opensearch.common.Nullable;
2618
import org.opensearch.common.settings.Settings;
2719
import org.opensearch.core.rest.RestStatus;
2820
import org.opensearch.index.IndexSettings;
2921
import org.opensearch.indices.replication.common.ReplicationType;
3022
import org.opensearch.snapshots.SnapshotInfo;
3123
import org.opensearch.snapshots.SnapshotState;
3224

33-
import java.util.List;
3425
import java.util.Map;
3526
import java.util.Optional;
3627

@@ -56,7 +47,7 @@ protected void setClusterMode(String mode) {
5647
}
5748

5849
// set the migration direction for cluster [remote_store, docrep, none]
59-
protected void setDirection(String direction) {
50+
public void setDirection(String direction) {
6051
updateSettingsRequest.persistentSettings(Settings.builder().put(MIGRATION_DIRECTION_SETTING.getKey(), direction));
6152
assertAcked(internalCluster().client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
6253
}
@@ -88,7 +79,7 @@ protected String allNodesExcept(String except) {
8879
return exclude.toString();
8980
}
9081

91-
// create a new test index with un-allocated primary and no replicas
82+
// create a new test index
9283
protected void prepareIndexWithoutReplica(Optional<String> name) {
9384
String indexName = name.orElse(TEST_INDEX);
9485
internalCluster().client()
@@ -105,33 +96,6 @@ protected void prepareIndexWithoutReplica(Optional<String> name) {
10596
.actionGet();
10697
}
10798

108-
// create a new test index with allocated primary and 1 unallocated replica
109-
public void prepareIndexWithAllocatedPrimary(DiscoveryNode primaryShardNode, Optional<String> name) {
110-
String indexName = name.orElse(TEST_INDEX);
111-
internalCluster().client()
112-
.admin()
113-
.indices()
114-
.prepareCreate(indexName)
115-
.setSettings(
116-
Settings.builder()
117-
.put("index.number_of_shards", 1)
118-
.put("index.number_of_replicas", 1)
119-
.put("index.routing.allocation.include._name", primaryShardNode.getName())
120-
.put("index.routing.allocation.exclude._name", allNodesExcept(primaryShardNode.getName()))
121-
)
122-
.setWaitForActiveShards(ActiveShardCount.ONE)
123-
.execute()
124-
.actionGet();
125-
126-
ensureYellowAndNoInitializingShards(TEST_INDEX);
127-
128-
logger.info(" --> verify allocation of primary shard");
129-
assertAllocation(true, primaryShardNode);
130-
131-
logger.info(" --> verify non-allocation of replica shard");
132-
assertNonAllocation(false);
133-
}
134-
13599
protected ShardRouting getShardRouting(boolean isPrimary) {
136100
IndexShardRoutingTable table = internalCluster().client()
137101
.admin()
@@ -146,108 +110,6 @@ protected ShardRouting getShardRouting(boolean isPrimary) {
146110
return (isPrimary ? table.primaryShard() : table.replicaShards().get(0));
147111
}
148112

149-
// obtain decision for allocation/relocation of a shard to a given node
150-
protected Decision getDecisionForTargetNode(
151-
DiscoveryNode targetNode,
152-
boolean isPrimary,
153-
boolean includeYesDecisions,
154-
boolean isRelocation
155-
) {
156-
ClusterAllocationExplanation explanation = internalCluster().client()
157-
.admin()
158-
.cluster()
159-
.prepareAllocationExplain()
160-
.setIndex(TEST_INDEX)
161-
.setShard(0)
162-
.setPrimary(isPrimary)
163-
.setIncludeYesDecisions(includeYesDecisions)
164-
.get()
165-
.getExplanation();
166-
167-
Decision requiredDecision = null;
168-
List<NodeAllocationResult> nodeAllocationResults;
169-
if (isRelocation) {
170-
MoveDecision moveDecision = explanation.getShardAllocationDecision().getMoveDecision();
171-
nodeAllocationResults = moveDecision.getNodeDecisions();
172-
} else {
173-
AllocateUnassignedDecision allocateUnassignedDecision = explanation.getShardAllocationDecision().getAllocateDecision();
174-
nodeAllocationResults = allocateUnassignedDecision.getNodeDecisions();
175-
}
176-
177-
for (NodeAllocationResult nodeAllocationResult : nodeAllocationResults) {
178-
if (nodeAllocationResult.getNode().equals(targetNode)) {
179-
for (Decision decision : nodeAllocationResult.getCanAllocateDecision().getDecisions()) {
180-
if (decision.label().equals(NAME)) {
181-
requiredDecision = decision;
182-
break;
183-
}
184-
}
185-
}
186-
}
187-
188-
assertNotNull(requiredDecision);
189-
return requiredDecision;
190-
}
191-
192-
// get allocation and relocation decisions for all nodes
193-
protected void prepareDecisions() {
194-
internalCluster().client()
195-
.admin()
196-
.indices()
197-
.prepareUpdateSettings(TEST_INDEX)
198-
.setSettings(Settings.builder().put("index.routing.allocation.exclude._name", allNodesExcept(null)))
199-
.execute()
200-
.actionGet();
201-
}
202-
203-
protected void attemptAllocation(@Nullable String targetNodeName) {
204-
Settings.Builder settingsBuilder;
205-
if (targetNodeName != null) {
206-
settingsBuilder = Settings.builder()
207-
.put("index.routing.allocation.include._name", targetNodeName)
208-
.put("index.routing.allocation.exclude._name", allNodesExcept(targetNodeName));
209-
} else {
210-
String clusterManagerNodeName = internalCluster().client()
211-
.admin()
212-
.cluster()
213-
.prepareState()
214-
.execute()
215-
.actionGet()
216-
.getState()
217-
.getNodes()
218-
.getClusterManagerNode()
219-
.getName();
220-
// to allocate freely among all nodes other than cluster-manager node
221-
settingsBuilder = Settings.builder()
222-
.put("index.routing.allocation.include._name", allNodesExcept(clusterManagerNodeName))
223-
.put("index.routing.allocation.exclude._name", clusterManagerNodeName);
224-
}
225-
internalCluster().client().admin().indices().prepareUpdateSettings(TEST_INDEX).setSettings(settingsBuilder).execute().actionGet();
226-
}
227-
228-
// verify that shard does not exist at targetNode
229-
protected void assertNonAllocation(boolean isPrimary) {
230-
if (isPrimary) {
231-
ensureRed(TEST_INDEX);
232-
} else {
233-
ensureYellowAndNoInitializingShards(TEST_INDEX);
234-
}
235-
ShardRouting shardRouting = getShardRouting(isPrimary);
236-
assertFalse(shardRouting.active());
237-
assertNull(shardRouting.currentNodeId());
238-
assertEquals(ShardRoutingState.UNASSIGNED, shardRouting.state());
239-
}
240-
241-
// verify that shard exists at targetNode
242-
protected void assertAllocation(boolean isPrimary, @Nullable DiscoveryNode targetNode) {
243-
ShardRouting shardRouting = getShardRouting(isPrimary);
244-
assertTrue(shardRouting.active());
245-
assertNotNull(shardRouting.currentNodeId());
246-
if (targetNode != null) {
247-
assertEquals(shardRouting.currentNodeId(), targetNode.getId());
248-
}
249-
}
250-
251113
// create a snapshot
252114
public static SnapshotInfo createSnapshot(String snapshotRepoName, String snapshotName, String... indices) {
253115
SnapshotInfo snapshotInfo = internalCluster().client()
@@ -332,5 +194,4 @@ public static void assertRemoteStoreBackedIndex(String indexName) {
332194
INDEX_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING.get(indexSettings)
333195
);
334196
}
335-
336197
}

server/src/internalClusterTest/java/org/opensearch/remotemigration/RemoteStoreMigrationShardAllocationIT.java

-127
This file was deleted.

0 commit comments

Comments
 (0)