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 TestPubsubSignalcreate()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 whensuccessPredicateis 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.voidwaitForSuccess(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 whensuccessPredicateis evaluated to true.successPredicateis aSerializableFunctionthat accepts a set of currently captured events and returns true when the set satisfies the success criteria.If
successPredicateis evaluated to false, then it will be re-evaluated when next event becomes available.If
successPredicateis evaluated to true, then a success will be signaled andwaitForSuccess(Duration)will unblock.If
successPredicatethrows, 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
-