Search in sources :

Example 1 with CounterType

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));
        }
    }
}
Also used : CounterType(com.radixdlt.counters.SystemCounters.CounterType) TreeMap(java.util.TreeMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 2 with CounterType

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());
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) AssertionsForClassTypes(org.assertj.core.api.AssertionsForClassTypes) NetworkDroppers(com.radixdlt.harness.simulation.NetworkDroppers) RERulesConfig(com.radixdlt.statecomputer.forks.RERulesConfig) Duration(java.time.Duration) Map(java.util.Map) AssertionsForInterfaceTypes.assertThat(org.assertj.core.api.AssertionsForInterfaceTypes.assertThat) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) LongSummaryStatistics(java.util.LongSummaryStatistics) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) NodeValidatorRandomRegistrator(com.radixdlt.harness.simulation.application.NodeValidatorRandomRegistrator) RadixEngineMonitors(com.radixdlt.harness.simulation.monitors.radix_engine.RadixEngineMonitors) Set(java.util.Set) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) TimeUnit(java.util.concurrent.TimeUnit) Builder(com.radixdlt.harness.simulation.SimulationTest.Builder) List(java.util.List) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) ChronoUnit(java.time.temporal.ChronoUnit) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) LedgerMonitors(com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) CounterType(com.radixdlt.counters.SystemCounters.CounterType) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 3 with CounterType

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);
}
Also used : CounterType(com.radixdlt.counters.SystemCounters.CounterType) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

CounterType (com.radixdlt.counters.SystemCounters.CounterType)3 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 NetworkDroppers (com.radixdlt.harness.simulation.NetworkDroppers)1 NetworkLatencies (com.radixdlt.harness.simulation.NetworkLatencies)1 NetworkOrdering (com.radixdlt.harness.simulation.NetworkOrdering)1 SimulationTest (com.radixdlt.harness.simulation.SimulationTest)1 Builder (com.radixdlt.harness.simulation.SimulationTest.Builder)1 NodeValidatorRandomRegistrator (com.radixdlt.harness.simulation.application.NodeValidatorRandomRegistrator)1 ConsensusMonitors (com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors)1 LedgerMonitors (com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors)1 RadixEngineMonitors (com.radixdlt.harness.simulation.monitors.radix_engine.RadixEngineMonitors)1 ForksModule (com.radixdlt.statecomputer.forks.ForksModule)1 RERulesConfig (com.radixdlt.statecomputer.forks.RERulesConfig)1 RadixEngineForksLatestOnlyModule (com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule)1 MainnetForksModule (com.radixdlt.statecomputer.forks.modules.MainnetForksModule)1 Duration (java.time.Duration)1 ChronoUnit (java.time.temporal.ChronoUnit)1