use of com.radixdlt.counters.SystemCounters.CounterType in project radixdlt by radixdlt.
the class SystemCountersImplTest method testMap.
private void testMap(String path, Map<String, Object> m) {
for (Map.Entry<String, Object> entry : m.entrySet()) {
String p = entry.getKey().toUpperCase();
String newPath = path.isEmpty() ? p : path + "_" + p;
Object o = entry.getValue();
if (o instanceof Map<?, ?>) {
@SuppressWarnings("unchecked") Map<String, Object> newm = (Map<String, Object>) o;
testMap(newPath, newm);
} else {
String s = o.toString();
CounterType ct = CounterType.valueOf(newPath);
// Check that values in the map match the values we set above
assertThat(Long.parseLong(s)).isEqualTo(ordinal(ct));
}
}
}
use of com.radixdlt.counters.SystemCounters.CounterType in project radixdlt by radixdlt.
the class RandomVoteAndViewTimeoutDropperTest method when_random_validators__then_sanity_checks_should_pass.
@Test
public void when_random_validators__then_sanity_checks_should_pass() {
SimulationTest simulationTest = bftTestBuilder.build();
final var runningTest = simulationTest.run(Duration.of(2, ChronoUnit.MINUTES));
final var checkResults = runningTest.awaitCompletion();
List<CounterType> counterTypes = List.of(CounterType.BFT_VERTEX_STORE_FORKS, CounterType.BFT_COMMITTED_VERTICES, CounterType.BFT_PACEMAKER_TIMEOUTS_SENT, CounterType.LEDGER_STATE_VERSION);
Map<CounterType, LongSummaryStatistics> statistics = counterTypes.stream().collect(Collectors.toMap(counterType -> counterType, counterType -> runningTest.getNetwork().getSystemCounters().values().stream().mapToLong(s -> s.get(counterType)).summaryStatistics()));
System.out.println("statistics:\n" + print(statistics.entrySet()));
assertThat(checkResults).allSatisfy((name, error) -> AssertionsForClassTypes.assertThat(error).isNotPresent());
}
use of com.radixdlt.counters.SystemCounters.CounterType in project radixdlt by radixdlt.
the class SystemCountersImplTest method when_tomap__then_values_correct.
@Test
public void when_tomap__then_values_correct() {
SystemCounters counters = new SystemCountersImpl();
for (CounterType value : CounterType.values()) {
counters.set(value, ordinal(value));
}
// Ensure writeable
Map<String, Object> m = new TreeMap<>(counters.toMap());
assertNotNull(m.remove("time"));
testMap("", m);
}
Aggregations