mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-24 05:44:59 +00:00
Makes sure creation date garentees execution in tests
This commit is contained in:
parent
9920d6be2d
commit
faf067080b
@ -68,6 +68,7 @@ public class IndexLifecycleServiceTests extends ESTestCase {
|
|||||||
private String nodeId;
|
private String nodeId;
|
||||||
private DiscoveryNode masterNode;
|
private DiscoveryNode masterNode;
|
||||||
private IndicesAdminClient indicesClient;
|
private IndicesAdminClient indicesClient;
|
||||||
|
private long now;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void prepareServices() {
|
public void prepareServices() {
|
||||||
@ -78,8 +79,8 @@ public class IndexLifecycleServiceTests extends ESTestCase {
|
|||||||
masterNode = DiscoveryNode.createLocal(settings(Version.CURRENT)
|
masterNode = DiscoveryNode.createLocal(settings(Version.CURRENT)
|
||||||
.put(NODE_MASTER_SETTING.getKey(), true).build(),
|
.put(NODE_MASTER_SETTING.getKey(), true).build(),
|
||||||
new TransportAddress(TransportAddress.META_ADDRESS, 9300), nodeId);
|
new TransportAddress(TransportAddress.META_ADDRESS, 9300), nodeId);
|
||||||
long randomMilli = randomNonNegativeLong();
|
now = randomNonNegativeLong();
|
||||||
Clock clock = Clock.fixed(Instant.ofEpochMilli(randomMilli), ZoneId.of(randomFrom(ZoneId.getAvailableZoneIds())));
|
Clock clock = Clock.fixed(Instant.ofEpochMilli(now), ZoneId.of(randomFrom(ZoneId.getAvailableZoneIds())));
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> null).when(clusterService).addListener(any());
|
doAnswer(invocationOnMock -> null).when(clusterService).addListener(any());
|
||||||
when(threadPool.executor(ThreadPool.Names.GENERIC)).thenReturn(executorService);
|
when(threadPool.executor(ThreadPool.Names.GENERIC)).thenReturn(executorService);
|
||||||
@ -96,7 +97,7 @@ public class IndexLifecycleServiceTests extends ESTestCase {
|
|||||||
when(adminClient.indices()).thenReturn(indicesClient);
|
when(adminClient.indices()).thenReturn(indicesClient);
|
||||||
|
|
||||||
indexLifecycleService = new IndexLifecycleService(Settings.EMPTY, client, clusterService, clock,
|
indexLifecycleService = new IndexLifecycleService(Settings.EMPTY, client, clusterService, clock,
|
||||||
threadPool, () -> randomMilli);
|
threadPool, () -> now);
|
||||||
Mockito.verify(clusterService).addListener(indexLifecycleService);
|
Mockito.verify(clusterService).addListener(indexLifecycleService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +356,7 @@ public class IndexLifecycleServiceTests extends ESTestCase {
|
|||||||
SortedMap<String, LifecyclePolicy> policyMap = new TreeMap<>();
|
SortedMap<String, LifecyclePolicy> policyMap = new TreeMap<>();
|
||||||
policyMap.put(policyName, policy);
|
policyMap.put(policyName, policy);
|
||||||
Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20));
|
Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20));
|
||||||
long creationDate = randomNonNegativeLong();
|
long creationDate = randomLongBetween(0, now - 1);
|
||||||
IndexMetaData indexMetadata = IndexMetaData.builder(index.getName())
|
IndexMetaData indexMetadata = IndexMetaData.builder(index.getName())
|
||||||
.settings(settings(Version.CURRENT)
|
.settings(settings(Version.CURRENT)
|
||||||
.put(LifecycleSettings.LIFECYCLE_NAME_SETTING.getKey(), policyName)
|
.put(LifecycleSettings.LIFECYCLE_NAME_SETTING.getKey(), policyName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user