Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make waiting for API events in tests more convenient #541

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

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.

1 participant