Class TestPubsubSignal
- All Implemented Interfaces:
TestRule
PCollection
and checks whether they match the
success criteria.
Uses a random temporary Pubsub topic for synchronization.
-
Method Summary
Modifier and TypeMethodDescriptionapply
(Statement base, Description description) static TestPubsubSignal
create()
Creates an instance of this rule.Outputs a message that the pipeline has started.<T> PTransform
<PCollection<? extends T>, POutput> signalSuccessWhen
(Coder<T> coder, SerializableFunction<Set<T>, Boolean> successPredicate) Invocation ofsignalSuccessWhen(Coder, SerializableFunction, SerializableFunction)
withObject.toString()
as the formatter.<T> PTransform
<PCollection<? extends T>, POutput> signalSuccessWhen
(Coder<T> coder, SerializableFunction<T, String> formatter, SerializableFunction<Set<T>, Boolean> successPredicate) Outputs a success message whensuccessPredicate
is evaluated to true.org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Supplier
<Void> waitForStart
(Duration duration) Future that waits for a start signal forduration
.void
waitForSuccess
(Duration duration) Wait for a success signal forduration
.
-
Method Details
-
create
Creates an instance of this rule.Loads GCP configuration from
TestPipelineOptions
. -
apply
-
signalStart
Outputs a message that the pipeline has started. -
signalSuccessWhen
public <T> PTransform<PCollection<? extends T>,POutput> signalSuccessWhen(Coder<T> coder, SerializableFunction<T, String> formatter, SerializableFunction<Set<T>, Boolean> successPredicate) Outputs a success message whensuccessPredicate
is evaluated to true.successPredicate
is aSerializableFunction
that accepts a set of currently captured events and returns true when the set satisfies the success criteria.If
successPredicate
is evaluated to false, then it will be re-evaluated when next event becomes available.If
successPredicate
is evaluated to true, then a success will be signaled andwaitForSuccess(Duration)
will unblock.If
successPredicate
throws, then failure will be signaled andwaitForSuccess(Duration)
will unblock. -
signalSuccessWhen
public <T> PTransform<PCollection<? extends T>,POutput> signalSuccessWhen(Coder<T> coder, SerializableFunction<Set<T>, Boolean> successPredicate) Invocation ofsignalSuccessWhen(Coder, SerializableFunction, SerializableFunction)
withObject.toString()
as the formatter. -
waitForStart
public org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Supplier<Void> waitForStart(Duration duration) Future that waits for a start signal forduration
.This future must be created before running the pipeline. A subscription must exist prior to the start signal being published, which occurs immediately upon pipeline startup.
-
waitForSuccess
Wait for a success signal forduration
.- Throws:
IOException
-