def testAllFlagsPassed(self):
        options_list = beam_pipeline_options.GenerateAllPipelineOptions(
            "--itargone=anarg,--itargtwo=anotherarg",
            "[\"--project=testProj\","
            "\"--gcpTempLocation=gs://test-bucket/staging\"]",
            [{
                "postgresUsername": "******"
            }, {
                "postgresPassword": "******"
            }], [{
                "name": "aTestVal",
                "type": "TestValue",
                "value": "this_is_a_test"
            }, {
                "name": "testier",
                "type": "TestValue",
                "value": "another_test"
            }])

        self.assertListEqual(options_list, [
            "\"--itargone=anarg\"", "\"--itargtwo=anotherarg\"",
            "\"--project=testProj\"",
            "\"--gcpTempLocation=gs://test-bucket/staging\"",
            "\"--aTestVal=this_is_a_test\"", "\"--testier=another_test\"",
            "\"--postgresUsername=postgres\"", "\"--postgresPassword=mypass\""
        ])
    def testItOptionsWithSpaces(self):
        options_list = beam_pipeline_options.GenerateAllPipelineOptions(
            None, "[\"--project=testProj\", "
            "\"--gcpTempLocation=gs://test-bucket/staging\"]", [], [])

        self.assertListEqual(options_list, [
            "\"--project=testProj\"",
            "\"--gcpTempLocation=gs://test-bucket/staging\""
        ])
Beispiel #3
0
def Run(benchmark_spec):
    # Get handle to the dpb service
    dpb_service_instance = benchmark_spec.dpb_service

    # Create a file handle to contain the response from running the job on
    # the dpb service
    stdout_file = tempfile.NamedTemporaryFile(
        suffix='.stdout', prefix='beam_integration_benchmark', delete=False)
    stdout_file.close()

    if FLAGS.beam_it_class is None:
        if FLAGS.beam_sdk == beam_benchmark_helper.BEAM_JAVA_SDK:
            classname = DEFAULT_JAVA_IT_CLASS
        elif FLAGS.beam_sdk == beam_benchmark_helper.BEAM_PYTHON_SDK:
            classname = DEFAULT_PYTHON_IT_MODULE
        else:
            raise NotImplementedError('Unsupported Beam SDK: %s.' %
                                      FLAGS.beam_sdk)
    else:
        classname = FLAGS.beam_it_class

    static_pipeline_options, dynamic_pipeline_options = \
        beam_pipeline_options.ReadPipelineOptionConfigFile()

    job_arguments = beam_pipeline_options.GenerateAllPipelineOptions(
        FLAGS.beam_it_args, FLAGS.beam_it_options, static_pipeline_options,
        dynamic_pipeline_options)

    job_type = BaseDpbService.BEAM_JOB_TYPE

    results = []
    metadata = copy.copy(dpb_service_instance.GetMetadata())

    start = datetime.datetime.now()
    dpb_service_instance.SubmitJob('',
                                   classname,
                                   job_arguments=job_arguments,
                                   job_stdout_file=stdout_file,
                                   job_type=job_type)
    end_time = datetime.datetime.now()
    run_time = (end_time - start).total_seconds()
    results.append(sample.Sample('run_time', run_time, 'seconds', metadata))
    return results
 def testNoFlagsPassed(self):
     options_list = beam_pipeline_options.GenerateAllPipelineOptions(
         None, None, [], [])
     self.assertListEqual(options_list, [])