Fix NPE in CcrRetentionLeaseIT (#43059)
The retention leases stats is null if the processing shard copy is being closed. In this the case, we should check against null then retry to avoid failing a test. Closes #41237
This commit is contained in:
parent
f2e66e22eb
commit
53eb630700
|
@ -188,6 +188,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
|
||||
final List<ShardStats> shardsStats = getShardsStats(stats);
|
||||
for (int i = 0; i < numberOfShards * (1 + numberOfReplicas); i++) {
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final RetentionLease retentionLease =
|
||||
|
@ -311,6 +312,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
|
||||
final List<ShardStats> shardsStats = getShardsStats(stats);
|
||||
for (int i = 0; i < numberOfShards * (1 + numberOfReplicas); i++) {
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final ClusterStateResponse followerIndexClusterState =
|
||||
|
@ -349,6 +351,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
if (shardsStats.get(i).getShardRouting().primary() == false) {
|
||||
continue;
|
||||
}
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final ClusterStateResponse followerIndexClusterState =
|
||||
|
@ -600,6 +603,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
|
||||
final List<ShardStats> shardsStats = getShardsStats(stats);
|
||||
for (int i = 0; i < numberOfShards * (1 + numberOfReplicas); i++) {
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final RetentionLease retentionLease =
|
||||
|
@ -663,6 +667,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
|
||||
final List<ShardStats> shardsStats = getShardsStats(stats);
|
||||
for (int i = 0; i < numberOfShards * (1 + numberOfReplicas); i++) {
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final ClusterStateResponse followerIndexClusterState =
|
||||
|
@ -701,6 +706,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
if (shardsStats.get(i).getShardRouting().primary() == false) {
|
||||
continue;
|
||||
}
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final ClusterStateResponse followerIndexClusterState =
|
||||
|
@ -916,6 +922,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
|
||||
final List<ShardStats> afterUnfollowShardsStats = getShardsStats(afterUnfollowStats);
|
||||
for (final ShardStats shardStats : afterUnfollowShardsStats) {
|
||||
assertNotNull(shardStats.getRetentionLeaseStats());
|
||||
assertThat(Strings.toString(shardStats), shardStats.getRetentionLeaseStats().retentionLeases().leases(), empty());
|
||||
}
|
||||
} finally {
|
||||
|
@ -966,6 +973,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
leaderClient().admin().indices().stats(new IndicesStatsRequest().clear().indices(leaderIndex)).actionGet();
|
||||
final List<ShardStats> afterForgetFollowerShardsStats = getShardsStats(afterForgetFollowerStats);
|
||||
for (final ShardStats shardStats : afterForgetFollowerShardsStats) {
|
||||
assertNotNull(shardStats.getRetentionLeaseStats());
|
||||
assertThat(Strings.toString(shardStats), shardStats.getRetentionLeaseStats().retentionLeases().leases(), empty());
|
||||
}
|
||||
}
|
||||
|
@ -985,6 +993,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
|
||||
final List<ShardStats> shardsStats = getShardsStats(stats);
|
||||
for (int i = 0; i < numberOfShards * (1 + numberOfReplicas); i++) {
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final RetentionLease retentionLease =
|
||||
|
@ -1002,6 +1011,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
assertThat(stats.getShards(), arrayWithSize(numberOfShards * (1 + numberOfReplicas)));
|
||||
final List<ShardStats> shardsStats = getShardsStats(stats);
|
||||
for (int i = 0; i < numberOfShards * (1 + numberOfReplicas); i++) {
|
||||
assertNotNull(shardsStats.get(i).getRetentionLeaseStats());
|
||||
final RetentionLeases currentRetentionLeases = shardsStats.get(i).getRetentionLeaseStats().retentionLeases();
|
||||
assertThat(Strings.toString(shardsStats.get(i)), currentRetentionLeases.leases(), hasSize(1));
|
||||
final RetentionLease retentionLease =
|
||||
|
|
Loading…
Reference in New Issue