UNPKG

@gatling.io/core

Version:

Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).

108 lines (107 loc) 4.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.incrementUsersPerSec = exports.nothingFor = exports.rampUsersPerSec = exports.constantUsersPerSec = exports.atOnceUsers = exports.stressPeakUsers = exports.rampUsers = void 0; const jvm_types_1 = require("@gatling.io/jvm-types"); const duration_1 = require("./utils/duration"); const wrapOpenInjectionStep = (_underlying) => ({ _underlying }); const wrapConstantRateOpenInjectionStep = (_underlying) => ({ _underlying, randomized: () => wrapOpenInjectionStep(_underlying.randomized()) }); const wrapOpenInjectionStepRamp = (_underlying) => ({ _underlying, during: (duration) => wrapOpenInjectionStep(_underlying.during((0, duration_1.toJvmDuration)(duration))) }); const wrapOpenInjectionStepStressPeak = (_underlying) => ({ _underlying, during: (duration) => wrapOpenInjectionStep(_underlying.during((0, duration_1.toJvmDuration)(duration))) }); const wrapOpenInjectionStepConstantRate = (_underlying) => ({ _underlying, during: (duration) => wrapConstantRateOpenInjectionStep(_underlying.during((0, duration_1.toJvmDuration)(duration))) }); const wrapOpenInjectionStepRampRate = (_underlying) => ({ _underlying, to: (to) => wrapOpenInjectionStepRampRateDuring(_underlying.to(to)) }); const wrapOpenInjectionStepRampRateDuring = (_underlying) => ({ _underlying, during: (duration) => wrapRampRateOpenInjectionStep(_underlying.during((0, duration_1.toJvmDuration)(duration))) }); const wrapRampRateOpenInjectionStep = (_underlying) => ({ _underlying, randomized: () => wrapOpenInjectionStep(_underlying.randomized()) }); const wrapOpenInjectionStepStairs = (_underlying) => ({ _underlying, times: (levels) => wrapOpenInjectionStepStairsTimes(_underlying.times(levels)) }); const wrapOpenInjectionStepStairsTimes = (_underlying) => ({ _underlying, eachLevelLasting: (duration) => wrapOpenInjectionStepStairsComposite(_underlying.eachLevelLasting((0, duration_1.toJvmDuration)(duration))) }); const wrapOpenInjectionStepStairsComposite = (_underlying) => ({ _underlying, startingFrom: (startingRate) => wrapOpenInjectionStepStairsComposite(_underlying.startingFrom(startingRate)), separatedByRampsLasting: (duration) => wrapOpenInjectionStepStairsComposite(_underlying.separatedByRampsLasting((0, duration_1.toJvmDuration)(duration))) }); /** * Bootstrap a new open workload rampUsers injection profile, see {@link OpenInjectionStepRamp} * * @param users - the total number of users to inject * @returns the next DSL step */ const rampUsers = (users) => wrapOpenInjectionStepRamp(jvm_types_1.CoreDsl.rampUsers(users)); exports.rampUsers = rampUsers; /** * Bootstrap a new open workload stress peak injection profile, see {@link * OpenInjectionStepStressPeak} * * @param users - the total number of users to inject * @returns the next DSL step */ const stressPeakUsers = (users) => wrapOpenInjectionStepStressPeak(jvm_types_1.CoreDsl.stressPeakUsers(users)); exports.stressPeakUsers = stressPeakUsers; /** * Inject a bunch of users at the same time. * * @param users - the number of users to inject * @returns a new OpenInjectionStep */ const atOnceUsers = (users) => wrapOpenInjectionStep(jvm_types_1.CoreDsl.atOnceUsers(users)); exports.atOnceUsers = atOnceUsers; /** * Bootstrap a new open workload constantUsersPerSec injection profile, see {@link * OpenInjectionStepConstantRate} * * @param rate - the users per second rate * @returns the next DSL step */ const constantUsersPerSec = (rate) => wrapOpenInjectionStepConstantRate(jvm_types_1.CoreDsl.constantUsersPerSec(rate)); exports.constantUsersPerSec = constantUsersPerSec; /** * Bootstrap a new open workload rampUsersPerSec injection profile, see {@link * OpenInjectionStepRampRate} * * @param rate - the users per second start rate * @returns the next DSL step */ const rampUsersPerSec = (rate) => wrapOpenInjectionStepRampRate(jvm_types_1.CoreDsl.rampUsersPerSec(rate)); exports.rampUsersPerSec = rampUsersPerSec; /** * Don't inject any new user for a given duration * * @param duration - the duration * @returns a new OpenInjectionStep */ const nothingFor = (duration) => wrapOpenInjectionStep(jvm_types_1.CoreDsl.nothingFor((0, duration_1.toJvmDuration)(duration))); exports.nothingFor = nothingFor; /** * Bootstrap a new open workload incrementUsersPerSec injection profile, see {@link * OpenInjectionStepStairs} * * @param rateIncrement - the difference of users per second rate between levels of the stairs * @returns the next DSL step */ const incrementUsersPerSec = (rateIncrement) => wrapOpenInjectionStepStairs(jvm_types_1.CoreDsl.incrementUsersPerSec(rateIncrement)); exports.incrementUsersPerSec = incrementUsersPerSec;