Search in sources :

Example 1 with TransactionType

use of com.hedera.mirror.monitor.publish.transaction.TransactionType in project hedera-mirror-node by hashgraph.

the class CompositeTransactionGeneratorTest method distribution.

@Test
void distribution() {
    properties.setWarmupPeriod(Duration.ZERO);
    CompositeTransactionGenerator generator = supplier.get();
    assertThat(generator.distribution.get().getPmf()).hasSize(properties.getScenarios().size()).extracting(Pair::getValue).containsExactly(0.75, 0.25);
    Multiset<TransactionType> types = HashMultiset.create();
    double seconds = 5;
    for (int i = 0; i < totalTps * seconds; ) {
        List<PublishRequest> requests = generator.next();
        requests.stream().map(r -> r.getScenario().getProperties().getType()).forEach(types::add);
        i += requests.size();
    }
    for (PublishScenarioProperties publishScenarioProperties : properties.getScenarios().values()) {
        assertThat(types.count(publishScenarioProperties.getType())).isNotNegative().isNotZero().isCloseTo((int) (publishScenarioProperties.getTps() * seconds), withinPercentage(10));
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Stopwatch(com.google.common.base.Stopwatch) Multiset(com.google.common.collect.Multiset) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) PublishRequest(com.hedera.mirror.monitor.publish.PublishRequest) PublishScenarioProperties(com.hedera.mirror.monitor.publish.PublishScenarioProperties) Assertions.withinPercentage(org.assertj.core.api.Assertions.withinPercentage) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ScenarioStatus(com.hedera.mirror.monitor.ScenarioStatus) HashMultiset(com.google.common.collect.HashMultiset) Duration(java.time.Duration) Map(java.util.Map) Suppliers(com.google.common.base.Suppliers) ValueSource(org.junit.jupiter.params.provider.ValueSource) Pair(org.apache.commons.math3.util.Pair) Assertions.from(org.assertj.core.api.Assertions.from) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) PublishScenario(com.hedera.mirror.monitor.publish.PublishScenario) PublishProperties(com.hedera.mirror.monitor.publish.PublishProperties) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Timeout(org.junit.jupiter.api.Timeout) TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) PublishScenarioProperties(com.hedera.mirror.monitor.publish.PublishScenarioProperties) PublishRequest(com.hedera.mirror.monitor.publish.PublishRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with TransactionType

use of com.hedera.mirror.monitor.publish.transaction.TransactionType in project hedera-mirror-node by hashgraph.

the class ExpressionConverterImplTest method cached.

@Test
void cached() throws InvalidProtocolBufferException {
    TransactionType type = TransactionType.CONSENSUS_CREATE_TOPIC;
    when(transactionPublisher.publish(any())).thenReturn(response(type, 100));
    assertThat(expressionConverter.convert("${topic.foo}")).isEqualTo("0.0.100");
    assertThat(expressionConverter.convert("${topic.foo}")).isEqualTo("0.0.100");
    verify(transactionPublisher).publish(request.capture());
    assertThat(request.getValue().getScenario().getProperties().getType()).isEqualTo(type);
}
Also used : TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) Test(org.junit.jupiter.api.Test)

Example 3 with TransactionType

use of com.hedera.mirror.monitor.publish.transaction.TransactionType in project hedera-mirror-node by hashgraph.

the class ExpressionConverterImplTest method schedule.

@Test
void schedule() throws InvalidProtocolBufferException {
    TransactionType type = TransactionType.SCHEDULE_CREATE;
    when(transactionPublisher.publish(any())).thenReturn(response(type, 100));
    assertThat(expressionConverter.convert("${schedule.foo}")).isEqualTo("0.0.100");
    verify(transactionPublisher).publish(request.capture());
    assertThat(request.getValue().getScenario().getProperties().getType()).isEqualTo(type);
}
Also used : TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionType

use of com.hedera.mirror.monitor.publish.transaction.TransactionType in project hedera-mirror-node by hashgraph.

the class ExpressionConverterImplTest method token.

@Test
void token() throws InvalidProtocolBufferException {
    TransactionType type = TransactionType.TOKEN_CREATE;
    when(transactionPublisher.publish(any())).thenReturn(response(type, 101));
    assertThat(expressionConverter.convert("${token.foo}")).isEqualTo("0.0.101");
    verify(transactionPublisher).publish(request.capture());
    assertThat(request.getValue().getScenario().getProperties().getType()).isEqualTo(type);
}
Also used : TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) Test(org.junit.jupiter.api.Test)

Example 5 with TransactionType

use of com.hedera.mirror.monitor.publish.transaction.TransactionType in project hedera-mirror-node by hashgraph.

the class ExpressionConverterImplTest method error.

@Test
void error() throws InvalidProtocolBufferException {
    TransactionType type = TransactionType.CONSENSUS_SUBMIT_MESSAGE;
    when(transactionPublisher.publish(any())).thenReturn(response(type, 100));
    assertThatThrownBy(() -> expressionConverter.convert("${topic.foo}")).isInstanceOf(RuntimeException.class);
}
Also used : TransactionType(com.hedera.mirror.monitor.publish.transaction.TransactionType) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionType (com.hedera.mirror.monitor.publish.transaction.TransactionType)10 Test (org.junit.jupiter.api.Test)10 Stopwatch (com.google.common.base.Stopwatch)1 Suppliers (com.google.common.base.Suppliers)1 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 ScenarioStatus (com.hedera.mirror.monitor.ScenarioStatus)1 PublishProperties (com.hedera.mirror.monitor.publish.PublishProperties)1 PublishRequest (com.hedera.mirror.monitor.publish.PublishRequest)1 PublishScenario (com.hedera.mirror.monitor.publish.PublishScenario)1 PublishScenarioProperties (com.hedera.mirror.monitor.publish.PublishScenarioProperties)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 TimeoutException (java.util.concurrent.TimeoutException)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Pair (org.apache.commons.math3.util.Pair)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1