[Fix] a bug in ClearRealmCacheTests

Original commit: elastic/x-pack-elasticsearch@8d8fdf4c2a
This commit is contained in:
uboness 2015-01-16 18:36:58 +01:00
parent 56957f98bc
commit 9e078f4924
1 changed files with 10 additions and 5 deletions

View File

@ -41,7 +41,7 @@ public class ClearRealmsCacheTests extends ShieldIntegrationTest {
public static void init() throws Exception {
usernames = new String[randomIntBetween(5, 10)];
for (int i = 0; i < usernames.length; i++) {
usernames[i] = "user_" + i;
usernames[i] = randomAsciiOfLength(6) + "_" + i;
}
}
@ -63,6 +63,9 @@ public class ClearRealmsCacheTests extends ShieldIntegrationTest {
EVICT_SOME() {
private final String[] evicted_usernames = randomSelection(usernames);
{
Arrays.sort(evicted_usernames);
}
@Override
public ClearRealmCacheRequest createRequest() {
@ -194,11 +197,13 @@ public class ClearRealmsCacheTests extends ShieldIntegrationTest {
// selects a random sub-set of the give values
private static String[] randomSelection(String[] values) {
double base = randomDouble();
List<String> list = new ArrayList<>();
for (String value : values) {
if (randomDouble() < base) {
list.add(value);
while (list.isEmpty()) {
double base = randomDouble();
for (String value : values) {
if (randomDouble() < base) {
list.add(value);
}
}
}
return list.toArray(new String[list.size()]);