Search in sources :

Example 21 with PerfTestLoadSettings

use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.

the class ContractCallLoadTest method runContractCalls.

private HapiApiSpec runContractCalls() {
    PerfTestLoadSettings settings = new PerfTestLoadSettings();
    final AtomicInteger submittedSoFar = new AtomicInteger(0);
    final String DEPOSIT_MEMO = "So we out-danced thought, body perfection brought...";
    Supplier<HapiSpecOperation[]> callBurst = () -> new HapiSpecOperation[] { inParallel(IntStream.range(0, settings.getBurstSize()).mapToObj(i -> contractCall("perf", ContractResources.VERBOSE_DEPOSIT_ABI, i + 1, 0, DEPOSIT_MEMO).sending(i + 1).noLogging().suppressStats(true).hasRetryPrecheckFrom(PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution()).toArray(n -> new HapiSpecOperation[n])), logIt(ignore -> String.format("Now a total of %d transactions submitted.", submittedSoFar.addAndGet(settings.getBurstSize()))) };
    return defaultHapiSpec("runContractCalls").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(fileCreate("contractBytecode").path(ContractResources.VERBOSE_DEPOSIT_BYTECODE_PATH), contractCreate("perf").bytecode("contractBytecode"), fileCreate("lookupBytecode").path(ContractResources.BALANCE_LOOKUP_BYTECODE_PATH), contractCreate("balanceLookup").bytecode("lookupBytecode").balance(1L), getContractInfo("perf").hasExpectedInfo().logged()).then(defaultLoadTest(callBurst, settings));
}
Also used : IntStream(java.util.stream.IntStream) LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) List(java.util.List) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Logger(org.apache.logging.log4j.Logger) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 22 with PerfTestLoadSettings

use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.

the class CryptoTransferLoadTest method runCryptoTransfers.

protected HapiApiSpec runCryptoTransfers() {
    PerfTestLoadSettings settings = new PerfTestLoadSettings();
    Supplier<HapiSpecOperation[]> transferBurst = () -> {
        String sender = "sender";
        String receiver = "receiver";
        if (settings.getTotalAccounts() > 2) {
            int s = r.nextInt(settings.getTotalAccounts());
            int re = 0;
            do {
                re = r.nextInt(settings.getTotalAccounts());
            } while (re == s);
            sender = String.format("0.0.%d", TEST_ACCOUNT_STARTS_FROM + s);
            receiver = String.format("0.0.%d", TEST_ACCOUNT_STARTS_FROM + re);
        }
        return new HapiSpecOperation[] { cryptoTransfer(tinyBarsFromTo(sender, receiver, 1L)).noLogging().payingWith(sender).signedBy(GENESIS).suppressStats(true).fee(100_000_000L).hasKnownStatusFrom(SUCCESS, OK, INSUFFICIENT_PAYER_BALANCE, UNKNOWN, TRANSACTION_EXPIRED, INSUFFICIENT_ACCOUNT_BALANCE).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
    };
    return defaultHapiSpec("RunCryptoTransfers").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(cryptoCreate("sender").balance(ignore -> settings.getInitialBalance()).payingWith(GENESIS).withRecharging().key(GENESIS).rechargeWindow(3).logging().hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), cryptoCreate("receiver").payingWith(GENESIS).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).key(GENESIS).logging()).then(defaultLoadTest(transferBurst, settings), getAccountBalance("sender").logged());
}
Also used : INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) INSUFFICIENT_ACCOUNT_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) Random(java.util.Random) TRANSACTION_EXPIRED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_EXPIRED) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) UNKNOWN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNKNOWN) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings)

Example 23 with PerfTestLoadSettings

use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.

the class HCSChunkingRealisticPerfSuite method fragmentLongMessageIntoChunks.

private static HapiApiSpec fragmentLongMessageIntoChunks() {
    PerfTestLoadSettings settings = new PerfTestLoadSettings();
    Supplier<HapiSpecOperation[]> submitBurst = () -> new HapiSpecOperation[] { chunkAFile(LARGE_FILE, CHUNK_SIZE, PAYER, TOPIC, totalMsgSubmitted) };
    return defaultHapiSpec("fragmentLongMessageIntoChunks").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), newKeyNamed("submitKey"), logIt(ignore -> settings.toString())).when(cryptoCreate(PAYER).balance(initialBalance.getAsLong()).withRecharging().rechargeWindow(30).hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED), withOpContext((spec, ignore) -> {
        int factor = settings.getIntProperty("collisionAvoidanceFactor", DEFAULT_COLLISION_AVOIDANCE_FACTOR);
        List<HapiSpecOperation> opsList = new ArrayList<HapiSpecOperation>();
        for (int i = 0; i < settings.getThreads() * factor; i++) {
            var op = createTopic(TOPIC + i).submitKeyName("submitKey").hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED);
            opsList.add(op);
        }
        CustomSpecAssert.allRunFor(spec, inParallel(flattened(opsList)));
    }), // wait all other thread ready
    sleepFor(5000)).then(defaultLoadTest(submitBurst, settings));
}
Also used : LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) ArrayList(java.util.ArrayList) UtilVerbs.chunkAFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.chunkAFile) AtomicLong(java.util.concurrent.atomic.AtomicLong) UtilVerbs.sleepFor(com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) CustomSpecAssert(com.hedera.services.bdd.spec.utilops.CustomSpecAssert) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) ArrayList(java.util.ArrayList) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Example 24 with PerfTestLoadSettings

use of com.hedera.services.bdd.suites.perf.PerfTestLoadSettings in project hedera-services by hashgraph.

the class createTopicLoadTest method runCreateTopics.

private static HapiApiSpec runCreateTopics() {
    PerfTestLoadSettings settings = new PerfTestLoadSettings();
    final AtomicInteger submittedSoFar = new AtomicInteger(0);
    KeyShape submitKeyShape = threshOf(2, SIMPLE, SIMPLE, listOf(2));
    Supplier<HapiSpecOperation[]> submitBurst = () -> new HapiSpecOperation[] { createTopic("testTopic" + submittedSoFar.addAndGet(1)).submitKeyShape(submitKeyShape).noLogging().hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED).deferStatusResolution() };
    return defaultHapiSpec("runCreateTopics").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when().then(defaultLoadTest(submitBurst, settings));
}
Also used : LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) List(java.util.List) Logger(org.apache.logging.log4j.Logger) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Aggregations

HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)24 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)24 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)24 PerfTestLoadSettings (com.hedera.services.bdd.suites.perf.PerfTestLoadSettings)24 List (java.util.List)24 Supplier (java.util.function.Supplier)24 LogManager (org.apache.logging.log4j.LogManager)24 Logger (org.apache.logging.log4j.Logger)24 PLATFORM_TRANSACTION_NOT_CREATED (com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED)22 UtilVerbs.logIt (com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt)21 BUSY (com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY)21 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)19 DUPLICATE_TRANSACTION (com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION)18 LoadTest (com.hedera.services.bdd.spec.utilops.LoadTest)15 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)12 OK (com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK)11 UNKNOWN (com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNKNOWN)11 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)10 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)10