def testDeserialization(self):
        serialized_pipeline = kubernetes_remote_runner._serialize_pipeline(  # pylint: disable=protected-access
            self.test_pipeline)
        pipeline = kubernetes_remote_runner.deserialize_pipeline(
            serialized_pipeline)

        self.assertEqual(self.test_pipeline.pipeline_info.pipeline_name,
                         pipeline.pipeline_info.pipeline_name)
        self.assertEqual(self.test_pipeline.pipeline_info.pipeline_root,
                         pipeline.pipeline_info.pipeline_root)
        self.assertEqual(self.test_pipeline.enable_cache,
                         pipeline.enable_cache)
        self.assertEqual(self.test_pipeline.beam_pipeline_args,
                         pipeline.beam_pipeline_args)
        self.assertEqual(self.test_pipeline.metadata_connection_config,
                         pipeline.metadata_connection_config)
        self.assertListEqual([
            component.executor_spec.executor_class
            for component in self.test_pipeline.components
        ], [
            component.executor_spec.executor_class
            for component in pipeline.components
        ])
        self.assertEqual(self.test_pipeline.metadata_connection_config,
                         pipeline.metadata_connection_config)
Exemple #2
0
  def testSerialization(self):
    serialized_pipeline = kubernetes_remote_runner._serialize_pipeline(  # pylint: disable=protected-access
        self.test_pipeline)

    pipeline = json.loads(serialized_pipeline)
    components = [
        json_utils.loads(component) for component in pipeline['components']
    ]
    metadata_connection_config = metadata_store_pb2.ConnectionConfig()
    json_format.Parse(pipeline['metadata_connection_config'],
                      metadata_connection_config)
    expected_downstream_ids = {
        '_FakeComponent.a': ['_FakeComponent.b', '_FakeComponent.c'],
        '_FakeComponent.b': ['_FakeComponent.c'],
        '_FakeComponent.c': [],
    }
    self.assertEqual(self.test_pipeline.pipeline_info.pipeline_name,
                     pipeline['pipeline_name'])
    self.assertEqual(self.test_pipeline.pipeline_info.pipeline_root,
                     pipeline['pipeline_root'])
    self.assertEqual(self.test_pipeline.enable_cache, pipeline['enable_cache'])
    self.assertEqual(self.test_pipeline.beam_pipeline_args,
                     pipeline['beam_pipeline_args'])
    self.assertEqual(self.test_pipeline.metadata_connection_config,
                     metadata_connection_config)
    self.assertListEqual([
        component.executor_spec.executor_class
        for component in self.test_pipeline.components
    ], [component.executor_spec.executor_class for component in components])
    self.assertEqual(self.test_pipeline.metadata_connection_config,
                     metadata_connection_config)
    # Enforce order of downstream ids for comparison.
    for downstream_ids in pipeline['downstream_ids'].values():
      downstream_ids.sort()
    self.assertEqual(expected_downstream_ids, pipeline['downstream_ids'])