Skip to content

Make waiting for API events in tests more convenient#541

Closed
azawlocki wants to merge 7 commits intomasterfrom
az/api-events
Closed

Make waiting for API events in tests more convenient#541
azawlocki wants to merge 7 commits intomasterfrom
az/api-events

Conversation

@azawlocki
Copy link
Contributor

@azawlocki azawlocki commented Aug 31, 2021

The purpose of this PR is to facilitate writing test scenarios with steps that wait for particular API events in addition to (or instead of) waiting for particular log entries.

Main changes:

  • The method Runner.wait_for_api_event(predicate, ...) is added. It can be used to wait until an API event satisfying given predicate is registered by MITM proxy, much like the existing method Probe.wait_for_log(predicate, ...) is used to wait until a log entry satisfying given predicate occurs in the agent log stream for a particular probe. Unlike in case of log monitors examined by Probe.wait_for_log(), the method Runner.wait_for_api_event() processes API events from all nodes, treated as a single stream of events.

  • The method EventMonitor.wait_for_event(), used internally by both Runner.wait_for_api_event() and Probe.wait_for_log(), is modified to accept a more general predicate that can accept arbitrary positional and keyword arguments, along with the event. The predicate can also return an arbitrary type: conversion to bool is used to determine if the predicate accepts given event. Value returned by the predicate for the accepted event is returned along with the event from EventMonitor.wait_for_event().

  • Some predicates for API events are added to goth.api_monitor.api_event module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants