Sign in

    k6

    A MoonBit module for k6 load testing scripts, providing utilities and abstractions to enhance the development experience of k6 scripts using MoonBit.

    k6
    load testing
    Download zip
    Author
    Version
    0.4.1
    License
    Apache-2.0
    Last updated
    7 months ago
    Downloads
    24

    Dependencies

    #ryota0624/k6

    k6のMoonBitバインディング

    #概要

    このライブラリは、k6 JavaScript APIの型安全なMoonBitバインディングを提供します。MoonBitで完全な型安全性を持つ負荷テストを記述し、JavaScriptにコンパイルしてk6で実行できます。

    #提供機能

    #コアモジュール

    #ネットワーク&プロトコル

    #データ&エンコーディング

    #テスト&メトリクス

    #ユーティリティ

    #利用例

    exampleディレクトリには、MoonBitで書かれたk6スクリプトのサンプルが含まれています。

    #ライセンス

    Apache-2.0

    DefaultFunction

    type DefaultFunction = (
    Any
    ) -> Unit

    Default (VU) function that runs for each iteration Receives the data returned from setup

    OnCloseHandler

    type OnCloseHandler = (
    Any
    ) -> Unit

    Event handler for WebSocket close

    OnErrorHandler

    type OnErrorHandler = (
    Any
    ) -> Unit

    Event handler for WebSocket error

    OnMessageHandler

    type OnMessageHandler = (
    Any
    ) -> Unit

    Event handler for WebSocket message

    OnOpenHandler

    type OnOpenHandler = (
    Any
    ) -> Unit

    Event handler for WebSocket connection open

    SetupFunc

    type SetupFunc = () ->
    Any

    Setup function type - runs once before test

    SetupFunction

    type SetupFunction = () ->
    Any

    Setup function that runs once before the test Returns data that will be passed to the default function

    TeardownFunc

    type TeardownFunc = (
    Any
    ) -> Unit

    Teardown function type - runs once after test

    TeardownFunction

    type TeardownFunction = (
    Any
    ) -> Unit

    Teardown function that runs once after the test Receives the data returned from setup

    VUFunc

    type VUFunc = (
    Any
    ) -> Unit

    VU function type - runs for each VU iteration

    ApiKeyAuth

    pub struct ApiKeyAuth {
    key : String
    header_name : String
    }

    API Key Authentication

    ApiKeyAuth::new

    fn ApiKeyAuth::new(key : String, header_name : String) -> ApiKeyAuth

    Create API Key Auth

    AuthSession

    pub struct AuthSession {
    auth_type : String
    credentials :
    Any

    headers : Map[String, String]
    }

    Session with authentication

    AuthSession::api_key

    fn AuthSession::api_key(key : String, header_name : String) -> AuthSession

    Create session with API Key

    AuthSession::basic

    fn AuthSession::basic(username : String, password : String) -> AuthSession

    Create session with Basic Auth

    AuthSession::bearer

    fn AuthSession::bearer(token : String) -> AuthSession

    Create session with Bearer token

    BasicAuth

    pub struct BasicAuth {
    username : String
    password : String
    }

    Basic Authentication credentials

    BasicAuth::new

    fn BasicAuth::new(username : String, password : String) -> BasicAuth

    Create Basic Auth

    BearerAuth

    pub struct BearerAuth {
    token : String
    }

    Bearer Token Authentication

    BearerAuth::new

    fn BearerAuth::new(token : String) -> BearerAuth

    Create Bearer Auth

    Counter

    pub struct Counter {
    name : String
    is_time : Bool
    handle :
    Any

    }

    Counter metric - counts occurrences

    Counter::add

    fn Counter::add(self : Counter, value : Double) -> Unit

    Add a value to the counter

    Counter::add_value

    fn Counter::add_value(self : Counter, value : Double) -> Unit

    Add value to counter

    Counter::increment

    fn Counter::increment(self : Counter) -> Unit

    Increment counter by 1

    Counter::new

    fn Counter::new(name : String, is_time : Bool) -> Counter

    Create a new Counter metric

    Gauge

    pub struct Gauge {
    name : String
    is_time : Bool
    handle :
    Any

    }

    Gauge metric - tracks the latest value

    Gauge::add

    fn Gauge::add(self : Gauge, value : Double) -> Unit

    Set the gauge value

    Gauge::new

    fn Gauge::new(name : String, is_time : Bool) -> Gauge

    Create a new Gauge metric

    Gauge::set

    fn Gauge::set(self : Gauge, value : Double) -> Unit

    Set gauge value

    GroupConfig

    pub struct GroupConfig {
    name : String
    tags : Map[String, String]
    }

    Group configuration

    GroupConfig::new

    fn GroupConfig::new(name : String) -> GroupConfig

    Create group config

    GroupConfig::run

    fn[T : Default] GroupConfig::run(self : GroupConfig, body : () -> T) -> T

    Execute group with config

    GroupConfig::tag

    fn GroupConfig::tag(self : GroupConfig, key : String, value : String) -> GroupConfig

    Add tag to group

    HttpMetrics

    pub struct HttpMetrics {
    requests : Counter
    success_rate : Rate
    duration : Trend
    }

    Track all HTTP metrics at once

    HttpMetrics::new

    fn HttpMetrics::new(prefix : String) -> HttpMetrics

    Create HTTP metrics set

    HttpMetrics::track

    fn HttpMetrics::track(self : HttpMetrics, res : Response) -> Unit

    Track HTTP response with all metrics

    OAuthToken

    pub struct OAuthToken {
    access_token : String
    token_type : String
    expires_in : Int?
    refresh_token : String?
    }

    OAuth 2.0 token response

    Options

    pub struct Options {
    vus : Int?
    duration : String?
    iterations : Int?
    stages : Array[
    Any
    ]?
    thresholds : Map[String, Array[String]]?
    scenarios : Map[String,
    Any
    ]?
    tags : Map[String, String]?
    no_connection_reuse : Bool?
    user_agent : String?
    }

    Test options configuration

    Options::default

    fn Options::default() -> Options

    Create default Options

    Options::duration

    fn Options::duration(self : Options, duration : String) -> Options

    Set duration

    Options::iterations

    fn Options::iterations(self : Options, iterations : Int) -> Options

    Set iterations

    Options::tags

    fn Options::tags(self : Options, tags : Map[String, String]) -> Options

    Set tags

    Options::thresholds

    fn Options::thresholds(self : Options, thresholds : Map[String, Array[String]]) -> Options

    Set thresholds

    Options::to_js

    Convert Options to JS object

    Options::user_agent

    fn Options::user_agent(self : Options, user_agent : String) -> Options

    Set user agent

    Options::vus

    fn Options::vus(self : Options, vus : Int) -> Options

    Set VUs (virtual users)

    Params

    pub struct Params {
    headers : Map[String, String]
    tags : Map[String, String]
    timeout : String?
    }

    HTTP request parameters

    Params::default

    fn Params::default() -> Params

    Create default Params

    Rate

    pub struct Rate {
    name : String
    is_time : Bool
    handle :
    Any

    }

    Rate metric - tracks the percentage of non-zero values

    Rate::add

    fn Rate::add(self : Rate, value : Bool) -> Unit

    Add a value to the rate (true = success, false = failure)

    Rate::failure

    fn Rate::failure(self : Rate) -> Unit

    Record failure

    Rate::new

    fn Rate::new(name : String, is_time : Bool) -> Rate

    Create a new Rate metric

    Rate::record

    fn Rate::record(self : Rate, success : Bool) -> Unit

    Record result (true = success, false = failure)

    Rate::success

    fn Rate::success(self : Rate) -> Unit

    Record success

    RequestBuilder

    pub struct RequestBuilder {
    http_method : String
    url : String
    body :
    Any
    ?
    headers : Map[String, String]
    tags : Map[String, String]
    timeout : String?
    }

    HTTP Request Builder for fluent API

    RequestBuilder::api_key_auth

    fn RequestBuilder::api_key_auth(self : RequestBuilder, key : String, header_name : String) -> RequestBuilder

    Add API Key authentication

    RequestBuilder::basic_auth

    fn RequestBuilder::basic_auth(self : RequestBuilder, username : String, password : String) -> RequestBuilder

    Add Basic Authentication to request

    RequestBuilder::bearer_auth

    fn RequestBuilder::bearer_auth(self : RequestBuilder, token : String) -> RequestBuilder

    Add Bearer token authentication

    RequestBuilder::custom_auth

    fn RequestBuilder::custom_auth(self : RequestBuilder, header_value : String) -> RequestBuilder

    Add custom authentication header

    RequestBuilder::delete

    fn RequestBuilder::delete(url : String) -> RequestBuilder

    Create a new DELETE request builder

    RequestBuilder::get

    fn RequestBuilder::get(url : String) -> RequestBuilder

    Create a new GET request builder

    RequestBuilder::header

    fn RequestBuilder::header(self : RequestBuilder, key : String, value : String) -> RequestBuilder

    Add a header

    RequestBuilder::headers

    fn RequestBuilder::headers(self : RequestBuilder, headers_map : Map[String, String]) -> RequestBuilder

    Add multiple headers

    RequestBuilder::json

    Set request body as JSON

    RequestBuilder::oauth_token

    fn RequestBuilder::oauth_token(self : RequestBuilder, token : OAuthToken) -> RequestBuilder

    Use OAuth token with request

    RequestBuilder::patch

    fn RequestBuilder::patch(url : String) -> RequestBuilder

    Create a new PATCH request builder

    RequestBuilder::post

    fn RequestBuilder::post(url : String) -> RequestBuilder

    Create a new POST request builder

    RequestBuilder::put

    fn RequestBuilder::put(url : String) -> RequestBuilder

    Create a new PUT request builder

    RequestBuilder::send

    Execute the request and return Response

    RequestBuilder::tag

    fn RequestBuilder::tag(self : RequestBuilder, key : String, value : String) -> RequestBuilder

    Add a tag

    RequestBuilder::text

    fn RequestBuilder::text(self : RequestBuilder, data : String) -> RequestBuilder

    Set request body as text

    RequestBuilder::timeout

    fn RequestBuilder::timeout(self : RequestBuilder, timeout : String) -> RequestBuilder

    Set timeout

    RequestBuilder::with_session

    fn RequestBuilder::with_session(self : RequestBuilder, session : AuthSession) -> RequestBuilder

    Apply session auth to request builder

    Response

    pub struct Response {
    status : Int
    status_text : String
    body : String
    headers : Map[String, String]
    json :
    Any

    html :
    Any

    timings :
    Any

    }

    HTTP Response type Represents the response from an HTTP request

    Response::is_ok

    fn Response::is_ok(self : Response) -> Bool

    Check if response status is 2xx

    Response::is_status

    fn Response::is_status(self : Response, code : Int) -> Bool

    Check if response status is specific code

    Response::json_body

    fn Response::json_body(self : Response) ->
    Any

    Get JSON body as Any

    Response::text_body

    fn Response::text_body(self : Response) -> String

    Get text body

    Scenario

    pub struct Scenario {
    executor : String
    vus : Int?
    iterations : Int?
    duration : String?
    start_time : String?
    graceful_stop : String?
    exec : String?
    }

    Scenario configuration

    Scenario::default

    fn Scenario::default() -> Scenario

    Create default Scenario

    Scenario::duration

    fn Scenario::duration(self : Scenario, duration : String) -> Scenario

    Set duration for scenario

    Scenario::executor

    fn Scenario::executor(self : Scenario, executor : String) -> Scenario

    Set executor type

    Scenario::iterations

    fn Scenario::iterations(self : Scenario, iterations : Int) -> Scenario

    Set iterations for scenario

    Scenario::to_js

    Convert Scenario to JS object

    Scenario::vus

    fn Scenario::vus(self : Scenario, vus : Int) -> Scenario

    Set VUs for scenario

    SharedArray

    pub struct SharedArray {
    name : String
    handle :
    Any

    }

    Shared array for sharing data between VUs

    SharedArray::get

    fn SharedArray::get(self : SharedArray, index : Int) ->
    Any

    Get value from SharedArray by index

    SharedArray::length

    fn SharedArray::length(self : SharedArray) -> Int

    Get the length of the SharedArray

    SharedArray::new

    fn SharedArray::new(name : String, callback : () ->
    Any
    ) -> SharedArray

    Create a new SharedArray The callback function should return an array

    Socket

    pub struct Socket {
    handle :
    Any

    }

    WebSocket connection handle

    Socket::close

    fn Socket::close(self : Socket) -> Unit

    Close WebSocket connection

    Socket::on

    fn Socket::on(self : Socket, event : String, handler :
    Any
    ) -> Unit

    Set event handler for WebSocket events Events: "open", "message", "close", "error"

    Socket::send

    fn Socket::send(self : Socket, data : String) -> Unit

    Send message to WebSocket server

    Socket::set_timeout

    fn Socket::set_timeout(self : Socket, callback : () -> Unit, delay : Int) -> Unit

    Set timeout for WebSocket connection

    Stage

    pub struct Stage {
    duration : String
    target : Int
    }

    Load test stage configuration

    Stage::new

    fn Stage::new(duration : String, target : Int) -> Stage

    Create a new Stage

    Stage::to_js

    fn Stage::to_js(self : Stage) ->
    Any

    Convert Stage to JS object

    TagSet

    pub struct TagSet {
    tags : Map[String, String]
    }

    Tag set for organizing test metrics

    TagSet::add

    fn TagSet::add(self : TagSet, key : String, value : String) -> TagSet

    Add a tag

    TagSet::add_all

    fn TagSet::add_all(self : TagSet, tags : Map[String, String]) -> TagSet

    Add multiple tags

    TagSet::get

    fn TagSet::get(self : TagSet, key : String) -> String?

    Get tag value

    TagSet::new

    fn TagSet::new() -> TagSet

    Create new tag set

    TagSet::remove

    fn TagSet::remove(self : TagSet, key : String) -> TagSet

    Remove a tag

    TagSet::to_map

    fn TagSet::to_map(self : TagSet) -> Map[String, String]

    Convert to map

    Test

    pub struct Test {
    setup_data :
    Any
    ?
    }

    Create a test with setup and teardown

    Test::get_setup_data

    fn Test::get_setup_data(self : Test) ->
    Any
    ?

    Get setup data

    Test::new

    fn Test::new() -> Test

    Initialize test

    Test::set_setup_data

    fn Test::set_setup_data(_self : Test, data :
    Any
    ) -> Test

    Set setup data

    TestConfig

    pub struct TestConfig {
    setup_fn : () ->
    Any
    ?
    teardown_fn : (
    Any
    ) -> Unit?
    vu_fn : (
    Any
    ) -> Unit
    }

    Test configuration with lifecycle hooks

    TestConfig::new

    fn TestConfig::new(vu_fn : (
    Any
    ) -> Unit) -> TestConfig

    Create test config with only VU function

    TestConfig::setup

    fn TestConfig::setup(self : TestConfig, setup_fn : () ->
    Any
    ) -> TestConfig

    Set setup function

    TestConfig::teardown

    fn TestConfig::teardown(self : TestConfig, teardown_fn : (
    Any
    ) -> Unit) -> TestConfig

    Set teardown function

    TestSetup

    pub struct TestSetup {
    base_url : String?
    timeout : String?
    credentials :
    Any
    ?
    test_data :
    Any
    ?
    }

    Builder for test configuration

    TestSetup::base_url

    fn TestSetup::base_url(self : TestSetup, url : String) -> TestSetup

    Set base URL

    TestSetup::build

    Build setup data object

    TestSetup::credentials

    fn TestSetup::credentials(self : TestSetup, username : String, password : String) -> TestSetup

    Set credentials

    TestSetup::new

    fn TestSetup::new() -> TestSetup

    Create new test setup builder

    TestSetup::test_data

    fn TestSetup::test_data(self : TestSetup, data :
    Any
    ) -> TestSetup

    Set test data

    TestSetup::timeout

    fn TestSetup::timeout(self : TestSetup, timeout : String) -> TestSetup

    Set timeout

    Trend

    pub struct Trend {
    name : String
    is_time : Bool
    handle :
    Any

    }

    Trend metric - calculates statistics over added values

    Trend::add

    fn Trend::add(self : Trend, value : Double) -> Unit

    Add a value to the trend

    Trend::add_value

    fn Trend::add_value(self : Trend, value : Double) -> Unit

    Add value to trend

    Trend::new

    fn Trend::new(name : String, is_time : Bool) -> Trend

    Create a new Trend metric

    WebSocketParams

    pub struct WebSocketParams {
    headers : Map[String, String]?
    tags : Map[String, String]?
    }

    WebSocket connection parameters

    WebSocketParams::default

    Create default WebSocket params

    WebSocketResponse

    pub struct WebSocketResponse {
    url : String
    status : Int
    headers :
    Any

    }

    WebSocket connection response

    add_to_shared_data

    fn add_to_shared_data(data :
    Any
    , key : String, value :
    Any
    ) -> Unit

    Add value to shared data

    api_group

    fn api_group(endpoint : String, body : () -> Unit) -> Unit

    Group for API calls

    auth_group

    fn auth_group(body : () -> Unit) -> Unit

    Group for authentication

    b64decode

    fn b64decode(input : String) -> String

    Decode base64 string

    b64decode_with_format

    fn b64decode_with_format(input : String, encoding : String, format : String) -> String

    Decode base64 string with specific encoding and format encoding: "std" (standard) or "rawstd", "url" or "rawurl" format: "s" (string) or "b" (binary)

    b64encode

    fn b64encode(input : String) -> String

    Encode string to base64

    b64encode_with_encoding

    fn b64encode_with_encoding(input : String, encoding : String) -> String

    Encode string to base64 with specific encoding encoding: "std" (standard) or "rawstd", "url" or "rawurl"

    batch

    Performs multiple HTTP requests in parallel Takes an array of request objects and returns an array of responses

    check

    fn check(val :
    Any
    , checks : Map[String, (
    Any
    ) -> Bool]) -> Bool

    Runs checks on values and returns whether all checks passed

    check_all

    fn check_all(res : Response, checks_list : Array[(String, (Response) -> Bool)]) -> Bool

    Run multiple checks on a response

    check_body_contains

    fn check_body_contains(res : Response, text : String) -> Bool

    Create a check for response body contains text

    check_equals

    fn[T : Eq] check_equals(val : T, expected : T, name : String) -> Bool

    Check if value equals expected

    check_greater

    fn[T : Compare + Eq] check_greater(val : T, threshold : T, name : String) -> Bool

    Check if value is greater than threshold

    check_less

    fn[T : Compare + Eq] check_less(val : T, threshold : T, name : String) -> Bool

    Check if value is less than threshold

    check_response

    fn check_response(res : Response, name : String, condition : (Response) -> Bool) -> Bool

    Check response with custom condition

    check_status

    fn check_status(res : Response, expected : Int) -> Bool

    Create a check for HTTP response status

    check_status_200

    fn check_status_200(res : Response) -> Bool

    Check if response status is 200

    check_status_201

    fn check_status_201(res : Response) -> Bool

    Check if response status is 201

    check_status_204

    fn check_status_204(res : Response) -> Bool

    Check if response status is 204

    check_status_400

    fn check_status_400(res : Response) -> Bool

    Check if response status is 400

    check_status_404

    fn check_status_404(res : Response) -> Bool

    Check if response status is 404

    check_status_500

    fn check_status_500(res : Response) -> Bool

    Check if response status is 500

    check_status_ok

    fn check_status_ok(res : Response) -> Bool

    Check if response status is 2xx (success)

    check_status_range

    fn check_status_range(res : Response, min : Int, max : Int) -> Bool

    Create a check for HTTP response status in range

    check_value

    fn[T] check_value(val : T, name : String, condition : (T) -> Bool) -> Bool

    Check any value with custom condition

    cleanup_group

    fn cleanup_group(body : () -> Unit) -> Unit

    Group for cleanup operations

    cleanup_resources

    fn cleanup_resources(_data :
    Any
    ) -> Unit

    Clean up resources in teardown

    connect

    fn connect(url : String, params : WebSocketParams, callback : (Socket) -> Unit) -> WebSocketResponse

    Connect to WebSocket server The callback function receives a Socket object

    create_api_key_header

    fn create_api_key_header(key : String) -> String

    Create API Key header value

    create_basic_auth_header

    fn create_basic_auth_header(username : String, password : String) -> String

    Create Authorization header for Basic Auth

    create_bearer_auth_header

    fn create_bearer_auth_header(token : String) -> String

    Create Authorization header for Bearer token

    create_counter

    fn create_counter(name : String) -> Counter

    Create a simple counter metric

    create_gauge

    fn create_gauge(name : String) -> Gauge

    Create a simple gauge metric

    create_hash

    fn create_hash(algorithm : String) ->
    Any

    Create a hash object algorithm: "md5", "sha1", "sha256", "sha384", "sha512", "sha512_256", "ripemd160"

    create_hmac

    fn create_hmac(algorithm : String, secret : String) ->
    Any

    Create an HMAC object algorithm: "md5", "sha1", "sha256", "sha384", "sha512", "sha512_256", "ripemd160"

    create_rate

    fn create_rate(name : String) -> Rate

    Create a rate metric

    create_shared_data

    fn create_shared_data() ->
    Any

    Create shared data object for passing between lifecycle stages

    create_tagged_counter

    fn create_tagged_counter(name : String, _tags : Map[String, String]) -> Counter

    Create counter with tags

    create_tagged_rate

    fn create_tagged_rate(name : String, _tags : Map[String, String]) -> Rate

    Create rate with tags

    create_tagged_trend

    fn create_tagged_trend(name : String, _tags : Map[String, String]) -> Trend

    Create trend with tags

    create_time_counter

    fn create_time_counter(name : String) -> Counter

    Create a time counter metric (for duration measurements)

    create_time_gauge

    fn create_time_gauge(name : String) -> Gauge

    Create a time gauge metric

    create_time_trend

    fn create_time_trend(name : String) -> Trend

    Create a time trend metric (for duration measurements)

    create_trend

    fn create_trend(name : String) -> Trend

    Create a trend metric

    current_iteration

    fn current_iteration() -> Int

    Get current iteration number

    current_vu

    fn current_vu() -> Int

    Get current VU ID

    db_group

    fn db_group(name : String, body : () -> Unit) -> Unit

    Group for database operations

    delete

    fn delete(url : String) -> Response

    Performs an HTTP DELETE request

    env

    fn env(key : String) -> String?

    Get environment variable by name

    every_n_iterations

    fn every_n_iterations(n : Int, f : () -> Unit) -> Unit

    Run code every N iterations

    execution_instance

    fn execution_instance() ->
    Any

    Get instance execution context Contains: vusActive, vusInitialized, iterationsCompleted, iterationsInterrupted

    execution_scenario

    fn execution_scenario() ->
    Any

    Get scenario execution context Contains: name, executor, startTime, progress, iterationInInstance, iterationInTest

    execution_vu

    fn execution_vu() ->
    Any

    Get VU execution context Contains: idInInstance, idInTest, iterationInInstance, iterationInScenario

    fail

    fn fail(message : String) -> Unit

    Throws an error and aborts the current iteration

    get

    fn get(url : String) -> Response

    Performs an HTTP GET request

    get_from_shared_data

    fn get_from_shared_data(data :
    Any
    , key : String) ->
    Any

    Get value from shared data

    get_with_params

    fn get_with_params(url : String, params :
    Any
    ) -> Response

    Performs an HTTP GET request with parameters

    group

    fn[T : Default] group(name : String, body : () -> T) -> T

    Executes code within a group context

    group_every_n_iterations

    fn group_every_n_iterations(n : Int, name : String, body : () -> Unit) -> Unit

    Run group every N iterations

    group_on_first_iteration

    fn group_on_first_iteration(name : String, body : () -> Unit) -> Unit

    Run group only on first iteration

    group_on_vu

    fn group_on_vu(vu_id : Int, name : String, body : () -> Unit) -> Unit

    Run group only on specific VU

    http_group

    fn http_group(name : String, body : () -> Unit) -> Unit

    Group for HTTP requests

    is_first_iteration

    fn is_first_iteration() -> Bool

    Check if this is the first iteration

    is_iteration

    fn is_iteration(n : Int) -> Bool

    Check if this is a specific iteration

    is_setup_phase

    fn is_setup_phase() -> Bool

    Check if running in setup phase

    is_teardown_phase

    fn is_teardown_phase() -> Bool

    Check if running in teardown phase

    is_vu

    fn is_vu(n : Int) -> Bool

    Check if this is a specific VU

    is_vu_phase

    fn is_vu_phase() -> Bool

    Check if running in VU phase

    iter

    fn iter() -> Int

    Current iteration number (only available in VU context)

    iteration_in_instance

    fn iteration_in_instance() -> Int

    Get iteration number in instance

    iteration_in_scenario

    fn iteration_in_scenario() -> Int

    Get iteration number in scenario

    log_test_summary

    fn log_test_summary(_data :
    Any
    ) -> Unit

    Log test summary in teardown

    md5

    fn md5(data : String, output_encoding : String) -> String

    Calculate MD5 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    measure_time

    fn[T] measure_time(trend : Trend, f : () -> T) -> T

    Measure execution time of a function and record to trend

    measure_time_with_duration

    fn[T] measure_time_with_duration(f : () -> T) -> (T, Double)

    Measure execution time and return both result and duration

    nested_group

    fn[T : Default] nested_group(parent_name : String, child_name : String, body : () -> T) -> T

    Run nested groups with different tags

    on_first_iteration

    fn on_first_iteration(f : () -> Unit) -> Unit

    Run code only on first iteration

    on_first_vu

    fn on_first_vu(f : () -> Unit) -> Unit

    Run code only on first VU

    on_iteration

    fn on_iteration(n : Int, f : () -> Unit) -> Unit

    Run code only on specific iteration

    on_vu

    fn on_vu(n : Int, f : () -> Unit) -> Unit

    Run code only on specific VU

    open

    fn open(filename : String) -> String

    Loads file content into memory (only available in init context)

    pace

    fn pace(duration_seconds : Double) -> Unit

    Sleep for a specific duration in seconds

    pace_random

    fn pace_random(min_seconds : Double, max_seconds : Double) -> Unit

    Sleep for a random duration between min and max seconds

    patch

    fn patch(url : String, body :
    Any
    ) -> Response

    Performs an HTTP PATCH request

    post

    fn post(url : String, body :
    Any
    ) -> Response

    Performs an HTTP POST request

    post_with_params

    fn post_with_params(url : String, body :
    Any
    , params :
    Any
    ) -> Response

    Performs an HTTP POST request with parameters

    put

    fn put(url : String, body :
    Any
    ) -> Response

    Performs an HTTP PUT request

    quick_delete

    fn quick_delete(url : String) -> Response

    Quick DELETE request

    quick_get

    fn quick_get(url : String) -> Response

    Quick GET request

    quick_patch_json

    fn quick_patch_json(url : String, data :
    Any
    ) -> Response

    Quick PATCH request with JSON body

    quick_post_json

    fn quick_post_json(url : String, data :
    Any
    ) -> Response

    Quick POST request with JSON body

    quick_put_json

    fn quick_put_json(url : String, data :
    Any
    ) -> Response

    Quick PUT request with JSON body

    random_bytes

    fn random_bytes(size : Int) ->
    Any

    Generate random bytes

    random_seed

    fn random_seed(seed : Int) -> Unit

    Sets the seed for reproducible pseudo-random number generation

    request

    fn request(http_method : String, url : String, body :
    Any
    , params : Params) -> Response

    Performs a generic HTTP request

    request_oauth_token

    fn request_oauth_token(token_url : String, client_id : String, client_secret : String) -> OAuthToken

    Request OAuth 2.0 token (Client Credentials flow)

    ripemd160

    fn ripemd160(data : String, output_encoding : String) -> String

    Calculate RIPEMD160 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    run_groups

    fn run_groups(groups : Array[(String, () -> Unit)]) -> Unit

    Run multiple groups in sequence

    scenario_executor

    fn scenario_executor() -> String

    Get scenario executor

    scenario_info

    fn scenario_info() ->
    Any

    Get scenario information

    scenario_name

    fn scenario_name() -> String

    Get scenario name

    scenario_progress

    fn scenario_progress() -> Double

    Get scenario progress (0.0 to 1.0)

    setup_database

    fn setup_database() ->
    Any

    Example: Setup database connection

    setup_group

    fn setup_group(body : () -> Unit) -> Unit

    Group for setup operations

    setup_http_config

    fn setup_http_config() ->
    Any

    Setup HTTP client configuration

    setup_test_data_from_file

    fn setup_test_data_from_file(filename : String) ->
    Any

    Setup test data from file

    setup_test_urls

    fn setup_test_urls(base_url : String) ->
    Any

    Setup test URLs

    sha1

    fn sha1(data : String, output_encoding : String) -> String

    Calculate SHA1 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    sha256

    fn sha256(data : String, output_encoding : String) -> String

    Calculate SHA256 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    sha384

    fn sha384(data : String, output_encoding : String) -> String

    Calculate SHA384 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    sha512

    fn sha512(data : String, output_encoding : String) -> String

    Calculate SHA512 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    sha512_256

    fn sha512_256(data : String, output_encoding : String) -> String

    Calculate SHA512/256 hash output_encoding: "hex", "base64", "base64url", "base64rawurl", "binary"

    sleep

    fn sleep(duration : Double) -> Unit

    Pauses VU execution for the specified duration in seconds

    tag_api_version

    fn tag_api_version(version : String) -> (String, String)

    Create API version tag

    tag_environment

    fn tag_environment(env : String) -> (String, String)

    Create environment tag

    tag_region

    fn tag_region(region : String) -> (String, String)

    Create region tag

    tag_scenario

    fn tag_scenario(scenario : String) -> (String, String)

    Create scenario tag

    tag_test_type

    fn tag_test_type(test_type : String) -> (String, String)

    Create test type tag

    tag_user_type

    fn tag_user_type(user_type : String) -> (String, String)

    Create user type tag

    tagged_group_request

    fn tagged_group_request(group_name : String, builder : RequestBuilder, tags : Map[String, String]) -> Response

    Execute request in tagged group

    tagged_request

    fn tagged_request(builder : RequestBuilder, tags : Map[String, String]) -> Response

    Execute request with tags

    teardown_database

    fn teardown_database(_data :
    Any
    ) -> Unit

    Example: Teardown database connection

    test_auth_required

    fn test_auth_required(url : String) -> Bool

    Test if authentication is required

    test_auth_valid

    fn test_auth_valid(url : String, session : AuthSession) -> Bool

    Test if authentication is valid

    test_basic_auth

    fn test_basic_auth(url : String, username : String, password : String) -> Bool

    Test Basic Auth credentials

    test_bearer_token

    fn test_bearer_token(url : String, token : String) -> Bool

    Test Bearer token

    test_info

    fn test_info() ->
    Any

    Get test execution context Contains: options, abort()

    test_info_data

    fn test_info_data() ->
    Any

    Get test information

    think

    fn think(duration_seconds : Double) -> Unit

    Simulate user think time (alias for sleep)

    think_random

    fn think_random(min_seconds : Double, max_seconds : Double) -> Unit

    Think time between min and max seconds

    track_http_count

    fn track_http_count(counter : Counter) -> Unit

    Track HTTP request count

    track_http_duration

    fn track_http_duration(_name : String, _res : Response, trend : Trend) -> Unit

    Track HTTP request duration

    track_http_success

    fn track_http_success(rate : Rate, res : Response) -> Unit

    Track success rate based on HTTP status
    fn vu() -> Int

    Current VU number (only available in VU context)

    vu_id_in_instance

    fn vu_id_in_instance() -> Int

    Get VU ID in instance

    vu_id_in_test

    fn vu_id_in_test() -> Int

    Get VU ID in test

    vu_info

    fn vu_info() ->
    Any

    Get VU information