@@ -446,6 +446,10 @@ def _kafka_test_preprocessor(
446446 'test_spanner_read_yaml' ,
447447 'test_spanner_write_yaml' ,
448448 'test_enrich_spanner_with_bigquery_yaml' ,
449+ 'test_pubsub_topic_to_bigquery_yaml' ,
450+ 'test_pubsub_subscription_to_bigquery_yaml' ,
451+ 'test_jdbc_to_bigquery_yaml' ,
452+ 'test_spanner_to_avro_yaml' ,
449453 'test_gcs_text_to_bigquery_yaml' ,
450454 'test_sqlserver_to_bigquery_yaml' ,
451455 'test_postgres_to_bigquery_yaml' ,
@@ -568,6 +572,7 @@ def _iceberg_io_read_test_preprocessor(
568572@YamlExamplesTestSuite .register_test_preprocessor ([
569573 'test_spanner_read_yaml' ,
570574 'test_enrich_spanner_with_bigquery_yaml' ,
575+ 'test_spanner_to_avro_yaml' ,
571576 'test_spanner_to_bigquery_yaml'
572577])
573578def _spanner_io_read_test_preprocessor (
@@ -648,6 +653,41 @@ def _enrichment_test_preprocessor(
648653 return test_spec
649654
650655
656+ @YamlExamplesTestSuite .register_test_preprocessor ([
657+ 'test_pubsub_topic_to_bigquery_yaml' ,
658+ 'test_pubsub_subscription_to_bigquery_yaml' ,
659+ 'test_pubsub_to_iceberg_yaml'
660+ ])
661+ def _pubsub_io_read_test_preprocessor (
662+ test_spec : dict , expected : List [str ], env : TestEnvironment ):
663+ """
664+ Preprocessor for tests that involve reading from Pub/Sub.
665+ This preprocessor replaces any ReadFromPubSub transform with a Create
666+ transform that reads from a predefined in-memory list of messages.
667+ This allows the test to verify the pipeline's correctness without relying
668+ on an active Pub/Sub subscription or topic.
669+ """
670+ if pipeline := test_spec .get ('pipeline' , None ):
671+ for transform in pipeline .get ('transforms' , []):
672+ if transform .get ('type' , '' ) == 'ReadFromPubSub' :
673+ transform ['type' ] = 'TestReadFromPubSub'
674+
675+ return test_spec
676+
677+
678+ @YamlExamplesTestSuite .register_test_preprocessor ([
679+ 'test_jdbc_to_bigquery_yaml' ,
680+ ])
681+ def _jdbc_io_read_test_preprocessor (
682+ test_spec : dict , expected : List [str ], env : TestEnvironment ):
683+ """
684+ Preprocessor for tests that involve reading from SqlServer.
685+ url syntax: 'jdbc:mysql://<host>:<port>/<database>'
686+ """
687+ return _db_io_read_test_processor (
688+ test_spec , lambda url : url .split ('/' )[- 1 ], 'Jdbc' )
689+
690+
651691@YamlExamplesTestSuite .register_test_preprocessor ([
652692 'test_sqlserver_to_bigquery_yaml' ,
653693])
@@ -748,14 +788,14 @@ def _db_io_read_test_processor(
748788}
749789
750790INPUT_TABLES = {
751- ('shipment-test' , 'shipment' , 'shipments' ): input_data .
752- spanner_shipments_data (),
791+ ('shipment-test' , 'shipment' , 'shipments' ): input_data .shipments_data (),
753792 ('orders-test' , 'order-database' , 'orders' ): input_data .
754793 spanner_orders_data (),
755794 ('db' , 'users' , 'NY' ): input_data .iceberg_dynamic_destinations_users_data (),
756795 ('BigTable' , 'beam-test' , 'bigtable-enrichment-test' ): input_data .
757796 bigtable_data (),
758797 ('BigQuery' , 'ALL_TEST' , 'customers' ): input_data .bigquery_data (),
798+ ('Jdbc' , 'shipment' , 'shipments' ): input_data .shipments_data (),
759799 ('SqlServer' , 'shipment' , 'shipments' ): input_data .shipments_data (),
760800 ('Postgres' , 'shipment' , 'shipments' ): input_data .shipments_data (),
761801 ('Oracle' , 'shipment' , 'shipments' ): input_data .shipments_data (),
@@ -784,5 +824,3 @@ def _db_io_read_test_processor(
784824if __name__ == '__main__' :
785825 logging .getLogger ().setLevel (logging .INFO )
786826 unittest .main ()
787-
788- # cloud_spanner_to_bigquery_flex
0 commit comments