Try the new Bazel Central Registry UI →
rules_itestAPI docs @0.0.56

@rules_itest//:itest.bzl

Rules for running services in integration tests.

Functions & Macros

port

This function is used to reference the auto assigned port of a service in the args or env attributes of an itest_service or itest_task.

To reference the auto assigned port in the itest_service_group use port_alias instead

Parameters
*label
named_port

This function is used to reference a named port of a service in the args or env attributes of an itest_service or itest_task.

To reference a named port in the itest_service_group use named_port_alias instead

Parameters
*label
*name
port_alias

This function is used to reference the auto assigned port of a service in the aliases attribute of an itest_service_group.

To reference the auto assigned port in itest_service or itest_task use port instead

Parameters
*label
named_port_alias

This function is used to reference a named port of a service in the aliases attribute of an itest_service_group.

To reference a named port in itest_service or itest_task use named_port instead

Parameters
*label
*name
itest_service
Parameters
*name
tags
Default: []
hygienic
Default: True
named_ports
Default: []
kwargs
itest_service_group
Parameters
*name
tags
Default: []
hygienic
Default: True
kwargs
itest_task
Parameters
*name
tags
Default: []
hygienic
Default: True
kwargs

Rules

service_test

Brings up a set of services/tasks and runs a test target against them.

This can be used to customize which services a particular test needs while being able to bring them up in an easy and consistent way.

Example usage:

go_test(
    name = "_example_test_no_services",
    srcs = [..],
    tags = ["manual"],
)

service_test(
    name = "example_test",
    test = ":_example_test_no_services",
    services = [
        "//services/mysql",
        ...
    ],
)

Typically this would be wrapped into a macro.

All common binary attributes are supported including args.

AttributeTypeDescription
*namename

A unique name for this target.

testlabel

The underlying test target to execute once the services have been brought up and healthchecked.

Default: None
envdictionary: String → String

The service manager will merge these variables into the environment when spawning the underlying binary.

Default: {}
datalist of labels
Default: []
deferredboolean

If set, the group will not be started on boot up. It can be started using the service manager's control API.

Default: False
port_aliasesdictionary: String → String

Port aliases allow you to 're-export' another service's port as belonging to this service group.
This can be used to create abstractions (such as an itest_service combined with an itest_task) but not leak
their implementation naming details through how client code accesses port names.

Use the functions port_alias and named_port_alias to reference ports from the services to alias ports for

Default: {}
serviceslist of labels

Services/tasks that comprise this group. Can be itest_service, itest_task, or itest_service_group.

Default: []