Ejemplo n.º 1
0
    def test_environment_encoding(self):
        for environment in (DockerEnvironment(),
                            DockerEnvironment(container_image='img'),
                            ProcessEnvironment('run.sh'),
                            ProcessEnvironment('run.sh',
                                               os='linux',
                                               arch='amd64',
                                               env={'k1': 'v1'}),
                            ExternalEnvironment('localhost:8080'),
                            ExternalEnvironment('localhost:8080',
                                                params={'k1': 'v1'}),
                            EmbeddedPythonEnvironment(),
                            EmbeddedPythonGrpcEnvironment(),
                            EmbeddedPythonGrpcEnvironment(num_workers=2,
                                                          state_cache_size=0),
                            SubprocessSDKEnvironment(command_string=u'foö')):
            context = pipeline_context.PipelineContext()
            self.assertEqual(
                environment,
                Environment.from_runner_api(environment.to_runner_api(context),
                                            context))

        with self.assertRaises(ValueError) as ctx:
            EmbeddedPythonGrpcEnvironment(num_workers=2).to_runner_api(
                pipeline_context.PipelineContext())
        self.assertIn('Must provide worker num and state cache size.',
                      ctx.exception.args)
Ejemplo n.º 2
0
 def test_environment_encoding(self):
     for environment in (DockerEnvironment(),
                         DockerEnvironment(container_image='img'),
                         ProcessEnvironment('run.sh'),
                         ProcessEnvironment('run.sh',
                                            os='linux',
                                            arch='amd64',
                                            env={'k1': 'v1'}),
                         ExternalEnvironment('localhost:8080'),
                         ExternalEnvironment('localhost:8080',
                                             params={'k1': 'v1'}),
                         EmbeddedPythonEnvironment(),
                         EmbeddedPythonGrpcEnvironment(),
                         EmbeddedPythonGrpcEnvironment(state_cache_size=0),
                         SubprocessSDKEnvironment(command_string=u'foö')):
         context = pipeline_context.PipelineContext()
         self.assertEqual(
             environment,
             Environment.from_runner_api(environment.to_runner_api(context),
                                         context))
Ejemplo n.º 3
0
 def test_environment_encoding(self):
   for environment in (DockerEnvironment(),
                       DockerEnvironment(container_image='img'),
                       DockerEnvironment(capabilities=['x, y, z']),
                       ProcessEnvironment('run.sh'),
                       ProcessEnvironment('run.sh',
                                          os='linux',
                                          arch='amd64',
                                          env={'k1': 'v1'}),
                       ExternalEnvironment('localhost:8080'),
                       ExternalEnvironment('localhost:8080',
                                           params={'k1': 'v1'}),
                       EmbeddedPythonEnvironment(),
                       EmbeddedPythonGrpcEnvironment(),
                       EmbeddedPythonGrpcEnvironment(
                           state_cache_size=0, data_buffer_time_limit_ms=0),
                       SubprocessSDKEnvironment(command_string=u'foö')):
     context = pipeline_context.PipelineContext()
     proto = environment.to_runner_api(context)
     reconstructed = Environment.from_runner_api(proto, context)
     self.assertEqual(environment, reconstructed)
     self.assertEqual(proto, reconstructed.to_runner_api(context))