Skip to content
axxbetadocs
v0.2.26next
GitHub

Pub/Sub

View .mdOpen in Claude

Publish messages to Pub/Sub topics and check the messages your services publish.

The steps use the scenario’s project (the {word} gcp project with the following properties:, from gcp-core).

Checking a topic does not take messages from anyone: for the topics a run checks, Axx creates a subscription of its own (axx-<run>-<topic>) once the services are up, and deletes it when the run ends. A check only looks at the messages received since its scenario started; match on data unique to the scenario, since scenarios run in parallel. The conditions are paths into the message data (JSON) and attribute <name> rows for its attributes.

Add it to a project with axx pack add gcp-pubsub; it builds on gcp-core, which comes with it.

When a message is published to the {word} pubsub topic:
"""
...
"""

Send a message to the pubsub topic; the doc string is its body.

Parameter Takes For example
{word} one word, with no spaces parcels, PX-4101

Example:

When a message is published to the shipment-events pubsub topic:
"""
{"parcel": "PX-5105", "carrier": "HERON", "service": "express", "weightKg": 3.2}
"""

Since 0.1.0.

When the {filepath} message is published to the {word} pubsub topic[[ with the following attributes:]]

Send a message whose body is the file to the pubsub topic, with the attributes of the table when the step has one.

Parameter Takes For example
{filepath} a file of the project: a path relative to the feature file’s directory, the resources directories or axx.yaml’s directory (looked for in that order), or an absolute path, quoted when it has a space seeds/parcels.yaml, kafka/scan-delivered.json
{word} one word, with no spaces parcels, PX-4101

Each row is an attribute sent with the message, as text: its name and its value.

Variants, the parts in [[...]] said or left out:

  • the {filepath} message is published to the {word} pubsub topic
  • the {filepath} message is published to the {word} pubsub topic with the following attributes:

Example:

When the messages/px-5105-weighed.json message is published to the shipment-events pubsub topic
When the messages/px-5105-weighed.json message is published to the shipment-events pubsub topic with the following attributes:
| eventType | ShipmentWeighed |

Since 0.1.0.

Then [[within {duration} ]]the {word} pubsub topic has a message where:
| path | value |

The table may start with the row naming its columns, as above, or go straight to its rows.

Check that the pubsub topic has a message with those values, received since the scenario started.

  • The check waits for it: 10 seconds, or within {duration}.
  • Axx creates a subscription of its own to the topic for the run.
Parameter Takes For example
{duration} a duration in seconds (s) or minutes (m) 5s, 2m
{word} one word, with no spaces parcels, PX-4101

Each row is a path into the message’s JSON body (a field name, a dotted path or a JSONPath) and the value it has, compared as text: null for null and undefined for absent. A row attribute <name> is instead on the attribute of that name sent with the message: undefined when there is none.

Variants, the parts in [[...]] said or left out:

  • the {word} pubsub topic has a message where:
  • within {duration} the {word} pubsub topic has a message where:

Example:

Then within 30s the invoice-events pubsub topic has a message where:
| attribute eventType | InvoiceReconciled |
| invoice | INV-2026-09-KES1 |
| status | RECONCILED |

Since 0.1.0.