apache_beam.testing.test_stream module

Provides TestStream for verifying streaming runner semantics.

For internal use only; no backwards-compatibility guarantees.

class apache_beam.testing.test_stream.Event[source]

Bases: future.types.newobject.newobject

Test stream event to be emitted during execution of a TestStream.

class apache_beam.testing.test_stream.ElementEvent(timestamped_values)[source]

Bases: apache_beam.testing.test_stream.Event

Element-producing test stream event.

class apache_beam.testing.test_stream.WatermarkEvent(new_watermark)[source]

Bases: apache_beam.testing.test_stream.Event

Watermark-advancing test stream event.

class apache_beam.testing.test_stream.ProcessingTimeEvent(advance_by)[source]

Bases: apache_beam.testing.test_stream.Event

Processing time-advancing test stream event.

class apache_beam.testing.test_stream.TestStream(coder=<class 'apache_beam.coders.coders.FastPrimitivesCoder'>)[source]

Bases: apache_beam.transforms.ptransform.PTransform

Test stream that generates events on an unbounded PCollection of elements.

Each event emits elements, advances the watermark or advances the processing time. After all of the specified elements are emitted, ceases to produce output.

get_windowing(unused_inputs)[source]
expand(pbegin)[source]
add_elements(elements)[source]

Add elements to the TestStream.

Elements added to the TestStream will be produced during pipeline execution. These elements can be TimestampedValue, WindowedValue or raw unwrapped elements that are serializable using the TestStream’s specified Coder. When a TimestampedValue or a WindowedValue element is used, the timestamp of the TimestampedValue or WindowedValue will be the timestamp of the produced element; otherwise, the current watermark timestamp will be used for that element. The windows of a given WindowedValue are ignored by the TestStream.

advance_watermark_to(new_watermark)[source]

Advance the watermark to a given Unix timestamp.

The Unix timestamp value used must be later than the previous watermark value and should be given as an int, float or utils.timestamp.Timestamp object.

advance_watermark_to_infinity()[source]

Advance the watermark to the end of time, completing this TestStream.

advance_processing_time(advance_by)[source]

Advance the current processing time by a given duration in seconds.

The duration must be a positive second duration and should be given as an int, float or utils.timestamp.Duration object.