Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote current test param when test fails #22283

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public CacheStats stats()
@Override
public ConcurrentMap<K, V> asMap()
{
return new ConcurrentMap<K, V>()
return new ConcurrentMap<>()
{
@Override
public V putIfAbsent(K key, V value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public CacheStats stats()
@Override
public ConcurrentMap<K, V> asMap()
{
return new ConcurrentMap<K, V>()
return new ConcurrentMap<>()
{
private final ConcurrentMap<Token<K>, V> dataCacheMap = dataCache.asMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,21 +448,15 @@ public void testInvalidateOngoingLoad()
assertThat(loadOngoing.await(10, SECONDS)).isTrue(); // 1

switch (invalidation) {
case INVALIDATE_KEY:
cache.invalidate(key);
break;
case INVALIDATE_PREDEFINED_KEYS:
cache.invalidateAll(ImmutableList.of(key));
break;
case INVALIDATE_SELECTED_KEYS:
case INVALIDATE_KEY -> cache.invalidate(key);
case INVALIDATE_PREDEFINED_KEYS -> cache.invalidateAll(ImmutableList.of(key));
case INVALIDATE_SELECTED_KEYS -> {
Set<Integer> keys = cache.asMap().keySet().stream()
.filter(foundKey -> (int) foundKey == key)
.collect(toImmutableSet());
cache.invalidateAll(keys);
break;
case INVALIDATE_ALL:
cache.invalidateAll();
break;
}
case INVALIDATE_ALL -> cache.invalidateAll();
}

invalidated.countDown(); // 2
Expand All @@ -475,6 +469,9 @@ public void testInvalidateOngoingLoad()
assertThat(threadA.get()).isEqualTo("stale value");
assertThat(threadB.get()).isEqualTo("fresh value");
}
catch (AssertionError e) {
throw new AssertionError("Error for invalidation=%s: %s".formatted(invalidation, e.getMessage()), e);
}
finally {
executor.shutdownNow();
assertThat(executor.awaitTermination(10, SECONDS)).isTrue();
Expand Down Expand Up @@ -516,21 +513,15 @@ public void testInvalidateAndLoadConcurrently()

// invalidate
switch (invalidation) {
case INVALIDATE_KEY:
cache.invalidate(key);
break;
case INVALIDATE_PREDEFINED_KEYS:
cache.invalidateAll(ImmutableList.of(key));
break;
case INVALIDATE_SELECTED_KEYS:
case INVALIDATE_KEY -> cache.invalidate(key);
case INVALIDATE_PREDEFINED_KEYS -> cache.invalidateAll(ImmutableList.of(key));
case INVALIDATE_SELECTED_KEYS -> {
Set<Integer> keys = cache.asMap().keySet().stream()
.filter(foundKey -> (int) foundKey == key)
.collect(toImmutableSet());
cache.invalidateAll(keys);
break;
case INVALIDATE_ALL:
cache.invalidateAll();
break;
}
case INVALIDATE_ALL -> cache.invalidateAll();
}

// read through cache
Expand All @@ -548,6 +539,9 @@ public void testInvalidateAndLoadConcurrently()
assertThat(remoteState.get()).isEqualTo(2 * 3 * 5 * 7);
assertThat((long) cache.get(key, remoteState::get)).isEqualTo(remoteState.get());
}
catch (AssertionError e) {
throw new AssertionError("Error for invalidation=%s: %s".formatted(invalidation, e.getMessage()), e);
}
finally {
executor.shutdownNow();
assertThat(executor.awaitTermination(10, SECONDS)).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,21 +568,15 @@ public String load(Integer key)
assertThat(loadOngoing.await(10, SECONDS)).isTrue(); // 1

switch (invalidation) {
case INVALIDATE_KEY:
cache.invalidate(key);
break;
case INVALIDATE_PREDEFINED_KEYS:
cache.invalidateAll(ImmutableList.of(key));
break;
case INVALIDATE_SELECTED_KEYS:
case INVALIDATE_KEY -> cache.invalidate(key);
case INVALIDATE_PREDEFINED_KEYS -> cache.invalidateAll(ImmutableList.of(key));
case INVALIDATE_SELECTED_KEYS -> {
Set<Integer> keys = cache.asMap().keySet().stream()
.filter(foundKey -> (int) foundKey == key)
.collect(toImmutableSet());
cache.invalidateAll(keys);
break;
case INVALIDATE_ALL:
cache.invalidateAll();
break;
}
case INVALIDATE_ALL -> cache.invalidateAll();
}

remoteState.put(key, "fresh value");
Expand All @@ -596,6 +590,9 @@ public String load(Integer key)
assertThat(threadA.get()).isEqualTo("stale value");
assertThat(threadB.get()).isEqualTo("fresh value");
}
catch (AssertionError e) {
throw new AssertionError("Error for invalidation=%s: %s".formatted(invalidation, e.getMessage()), e);
}
finally {
executor.shutdownNow();
assertThat(executor.awaitTermination(10, SECONDS)).isTrue();
Expand Down Expand Up @@ -639,21 +636,15 @@ public void testInvalidateAndLoadConcurrently()

// invalidate
switch (invalidation) {
case INVALIDATE_KEY:
cache.invalidate(key);
break;
case INVALIDATE_PREDEFINED_KEYS:
cache.invalidateAll(ImmutableList.of(key));
break;
case INVALIDATE_SELECTED_KEYS:
case INVALIDATE_KEY -> cache.invalidate(key);
case INVALIDATE_PREDEFINED_KEYS -> cache.invalidateAll(ImmutableList.of(key));
case INVALIDATE_SELECTED_KEYS -> {
Set<Integer> keys = cache.asMap().keySet().stream()
.filter(foundKey -> (int) foundKey == key)
.collect(toImmutableSet());
cache.invalidateAll(keys);
break;
case INVALIDATE_ALL:
cache.invalidateAll();
break;
}
case INVALIDATE_ALL -> cache.invalidateAll();
}

// read through cache
Expand All @@ -672,6 +663,9 @@ public void testInvalidateAndLoadConcurrently()
assertThat(remoteState.get(key).get()).isEqualTo(2 * 3 * 5 * 7);
assertThat((long) cache.get(key)).isEqualTo(2 * 3 * 5 * 7);
}
catch (AssertionError e) {
throw new AssertionError("Error for invalidation=%s: %s".formatted(invalidation, e.getMessage()), e);
}
finally {
executor.shutdownNow();
assertThat(executor.awaitTermination(10, SECONDS)).isTrue();
Expand Down
Loading