Java Code Examples for org.elasticsearch.test.ESTestCase#randomFrom()

The following examples show how to use org.elasticsearch.test.ESTestCase#randomFrom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestShardRouting.java    From crate with Apache License 2.0 6 votes vote down vote up
private static RecoverySource buildRecoveryTarget(boolean primary, ShardRoutingState state) {
    switch (state) {
        case UNASSIGNED:
        case INITIALIZING:
            if (primary) {
                return ESTestCase.randomFrom(RecoverySource.EmptyStoreRecoverySource.INSTANCE,
                    RecoverySource.ExistingStoreRecoverySource.INSTANCE);
            } else {
                return RecoverySource.PeerRecoverySource.INSTANCE;
            }
        case STARTED:
        case RELOCATING:
            return null;
        default:
            throw new IllegalStateException("illegal state");
    }
}
 
Example 2
Source File: TestShardRouting.java    From crate with Apache License 2.0 5 votes vote down vote up
private static UnassignedInfo buildUnassignedInfo(ShardRoutingState state) {
    switch (state) {
        case UNASSIGNED:
        case INITIALIZING:
            return new UnassignedInfo(ESTestCase.randomFrom(UnassignedInfo.Reason.values()), "auto generated for test");
        case STARTED:
        case RELOCATING:
            return null;
        default:
            throw new IllegalStateException("illegal state");
    }
}
 
Example 3
Source File: TestShardRouting.java    From crate with Apache License 2.0 5 votes vote down vote up
public static RecoverySource randomRecoverySource() {
    return ESTestCase.randomFrom(RecoverySource.EmptyStoreRecoverySource.INSTANCE,
        RecoverySource.ExistingStoreRecoverySource.INSTANCE,
        RecoverySource.PeerRecoverySource.INSTANCE,
        RecoverySource.LocalShardsRecoverySource.INSTANCE,
        new RecoverySource.SnapshotRecoverySource(
            new Snapshot("repo", new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())),
            Version.CURRENT,
            "some_index"));
}