Merge pull request elastic/elasticsearch#1102 from jasontedor/collections-shuffle-reproducibility

Remove usage of Collections#shuffle(List)

Original commit: elastic/x-pack-elasticsearch@76edae4539
This commit is contained in:
Jason Tedor 2015-12-11 11:48:25 -05:00
commit d0c4e79b3f
3 changed files with 6 additions and 7 deletions

View File

@ -61,7 +61,7 @@ public class ShieldActionMapperTests extends ESTestCase {
}
clearScrollRequest.addScrollId("_all");
//make sure that wherever the _all is among the scroll ids the action name gets translated
Collections.shuffle(clearScrollRequest.getScrollIds(), getRandom());
Collections.shuffle(clearScrollRequest.getScrollIds(), random());
assertThat(shieldActionMapper.action(ClearScrollAction.NAME, clearScrollRequest), equalTo(ShieldActionMapper.CLUSTER_PERMISSION_SCROLL_CLEAR_ALL_NAME));
}

View File

@ -60,7 +60,7 @@ public class RealmsTests extends ESTestCase {
for (int i = 0; i < factories.size() - 1; i++) {
orders.add(i);
}
Collections.shuffle(orders, getRandom());
Collections.shuffle(orders, random());
Map<Integer, Integer> orderToIndex = new HashMap<>();
for (int i = 0; i < factories.size() - 1; i++) {
builder.put("shield.authc.realms.realm_" + i + ".type", "type_" + i);
@ -118,7 +118,7 @@ public class RealmsTests extends ESTestCase {
for (int i = 0; i < factories.size() - 1; i++) {
orders.add(i);
}
Collections.shuffle(orders, getRandom());
Collections.shuffle(orders, random());
Map<Integer, Integer> orderToIndex = new HashMap<>();
for (int i = 0; i < factories.size() - 1; i++) {
builder.put("shield.authc.realms.realm_" + i + ".type", "type_" + i);
@ -186,7 +186,7 @@ public class RealmsTests extends ESTestCase {
for (int i = 0; i < factories.size() - 1; i++) {
orders.add(i);
}
Collections.shuffle(orders, getRandom());
Collections.shuffle(orders, random());
Map<Integer, Integer> orderToIndex = new HashMap<>();
for (int i = 0; i < factories.size() - 1; i++) {
builder.put("shield.authc.realms.realm_" + i + ".type", "type_" + i);

View File

@ -5,9 +5,9 @@
*/
package org.elasticsearch.watcher.test.bench;
import org.elasticsearch.common.Randomness;
import org.elasticsearch.common.metrics.MeanMetric;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.watcher.support.clock.SystemClock;
import org.elasticsearch.watcher.trigger.Trigger;
import org.elasticsearch.watcher.trigger.TriggerEngine;
@ -22,7 +22,6 @@ import org.elasticsearch.watcher.trigger.schedule.engine.TickerScheduleTriggerEn
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
@ -65,7 +64,7 @@ public class ScheduleEngineTriggerBenchmark {
}
ScheduleRegistry scheduleRegistry = new ScheduleRegistry(emptyMap());
List<String> impls = new ArrayList<>(Arrays.asList(new String[]{"schedule", "ticker"}));
Collections.shuffle(impls);
Randomness.shuffle(impls);
List<Stats> results = new ArrayList<>();
for (String impl : impls) {