コード例 #1
0
def dns_server_in_docker_jobspec(grpclb_ips, fallback_ips, shortname,
                                 cause_no_error_no_data_for_balancer_a_record):
    container_name = dockerjob.random_name(shortname)
    run_dns_server_cmdline = [
        'python',
        'test/cpp/naming/utils/run_dns_server_for_lb_interop_tests.py',
        '--grpclb_ips=%s' % ','.join(grpclb_ips),
        '--fallback_ips=%s' % ','.join(fallback_ips),
    ]
    if cause_no_error_no_data_for_balancer_a_record:
        run_dns_server_cmdline.append(
            '--cause_no_error_no_data_for_balancer_a_record')
    docker_cmdline = docker_run_cmdline(
        run_dns_server_cmdline,
        cwd='/var/local/git/grpc',
        image=docker_images.get(_FAKE_SERVERS_SAFENAME),
        docker_args=['--name=%s' % container_name])
    jobset.message(
        'IDLE',
        'docker_cmdline:\b|%s|' % ' '.join(docker_cmdline),
        do_newline=True)
    server_job = jobset.JobSpec(
        cmdline=docker_cmdline, shortname=shortname, timeout_seconds=30 * 60)
    server_job.container_name = container_name
    return server_job
コード例 #2
0
def cloud_to_prod_jobspec(language,
                          test_case,
                          server_host_nickname,
                          server_host,
                          docker_image=None,
                          auth=False,
                          manual_cmd_log=None,
                          service_account_key_file=None):
    """Creates jobspec for cloud-to-prod interop test"""
    container_name = None
    cmdargs = [
        '--server_host=%s' % server_host,
        '--server_host_override=%s' % server_host, '--server_port=443',
        '--use_tls=true',
        '--test_case=%s' % test_case
    ]
    environ = dict(language.cloud_to_prod_env(), **language.global_env())
    if auth:
        auth_cmdargs, auth_env = auth_options(language, test_case,
                                              service_account_key_file)
        cmdargs += auth_cmdargs
        environ.update(auth_env)
    cmdline = bash_cmdline(language.client_cmd(cmdargs))
    cwd = language.client_cwd

    if docker_image:
        container_name = dockerjob.random_name(
            'interop_client_%s' % language.safename)
        cmdline = docker_run_cmdline(
            cmdline,
            image=docker_image,
            cwd=cwd,
            environ=environ,
            docker_args=['--net=host',
                         '--name=%s' % container_name])
        if manual_cmd_log is not None:
            if manual_cmd_log == []:
                manual_cmd_log.append(
                    'echo "Testing ${docker_image:=%s}"' % docker_image)
            manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
        cwd = None
        environ = None

    suite_name = 'cloud_to_prod_auth' if auth else 'cloud_to_prod'
    test_job = jobset.JobSpec(
        cmdline=cmdline,
        cwd=cwd,
        environ=environ,
        shortname='%s:%s:%s:%s' % (suite_name, language, server_host_nickname,
                                   test_case),
        timeout_seconds=_TEST_TIMEOUT,
        flake_retries=4 if args.allow_flakes else 0,
        timeout_retries=2 if args.allow_flakes else 0,
        kill_handler=_job_kill_handler)
    if docker_image:
        test_job.container_name = container_name
    return test_job
コード例 #3
0
ファイル: run_interop_tests.py プロジェクト: wowo666/grpc
def server_jobspec(language, docker_image, insecure=False, manual_cmd_log=None):
    """Create jobspec for running a server"""
    container_name = dockerjob.random_name(
        'interop_server_%s' % language.safename)
    cmdline = bash_cmdline(
        language.server_cmd([
            '--port=%s' % _DEFAULT_SERVER_PORT,
            '--use_tls=%s' % ('false' if insecure else 'true')
        ]))
    environ = language.global_env()
    docker_args = ['--name=%s' % container_name]
    if language.safename == 'http2':
        # we are running the http2 interop server. Open next N ports beginning
        # with the server port. These ports are used for http2 interop test
        # (one test case per port).
        docker_args += list(
            itertools.chain.from_iterable(
                ('-p', str(_DEFAULT_SERVER_PORT + i))
                for i in range(len(_HTTP2_SERVER_TEST_CASES))))
        # Enable docker's healthcheck mechanism.
        # This runs a Python script inside the container every second. The script
        # pings the http2 server to verify it is ready. The 'health-retries' flag
        # specifies the number of consecutive failures before docker will report
        # the container's status as 'unhealthy'. Prior to the first 'health_retries'
        # failures or the first success, the status will be 'starting'. 'docker ps'
        # or 'docker inspect' can be used to see the health of the container on the
        # command line.
        docker_args += [
            '--health-cmd=python test/http2_test/http2_server_health_check.py '
            '--server_host=%s --server_port=%d' % ('localhost',
                                                   _DEFAULT_SERVER_PORT),
            '--health-interval=1s',
            '--health-retries=5',
            '--health-timeout=10s',
        ]

    else:
        docker_args += ['-p', str(_DEFAULT_SERVER_PORT)]

    docker_cmdline = docker_run_cmdline(
        cmdline,
        image=docker_image,
        cwd=language.server_cwd,
        environ=environ,
        docker_args=docker_args)
    if manual_cmd_log is not None:
        if manual_cmd_log == []:
            manual_cmd_log.append(
                'echo "Testing ${docker_image:=%s}"' % docker_image)
        manual_cmd_log.append(manual_cmdline(docker_cmdline, docker_image))
    server_job = jobset.JobSpec(
        cmdline=docker_cmdline,
        environ=environ,
        shortname='interop_server_%s' % language,
        timeout_seconds=30 * 60)
    server_job.container_name = container_name
    return server_job
コード例 #4
0
ファイル: run_interop_tests.py プロジェクト: zhexuany/grpc
def server_jobspec(language,
                   docker_image,
                   insecure=False,
                   manual_cmd_log=None):
    """Create jobspec for running a server"""
    container_name = dockerjob.random_name('interop_server_%s' %
                                           language.safename)
    cmdline = bash_cmdline(
        language.server_cmd([
            '--port=%s' % _DEFAULT_SERVER_PORT,
            '--use_tls=%s' % ('false' if insecure else 'true')
        ]))
    environ = language.global_env()
    docker_args = ['--name=%s' % container_name]
    if language.safename == 'http2':
        # we are running the http2 interop server. Open next N ports beginning
        # with the server port. These ports are used for http2 interop test
        # (one test case per port).
        docker_args += list(
            itertools.chain.from_iterable(
                ('-p', str(_DEFAULT_SERVER_PORT + i))
                for i in range(len(_HTTP2_SERVER_TEST_CASES))))
        # Enable docker's healthcheck mechanism.
        # This runs a Python script inside the container every second. The script
        # pings the http2 server to verify it is ready. The 'health-retries' flag
        # specifies the number of consecutive failures before docker will report
        # the container's status as 'unhealthy'. Prior to the first 'health_retries'
        # failures or the first success, the status will be 'starting'. 'docker ps'
        # or 'docker inspect' can be used to see the health of the container on the
        # command line.
        docker_args += [
            '--health-cmd=python test/http2_test/http2_server_health_check.py '
            '--server_host=%s --server_port=%d' %
            ('localhost', _DEFAULT_SERVER_PORT),
            '--health-interval=1s',
            '--health-retries=5',
            '--health-timeout=10s',
        ]

    else:
        docker_args += ['-p', str(_DEFAULT_SERVER_PORT)]

    docker_cmdline = docker_run_cmdline(cmdline,
                                        image=docker_image,
                                        cwd=language.server_cwd,
                                        environ=environ,
                                        docker_args=docker_args)
    if manual_cmd_log is not None:
        manual_cmd_log.append(manual_cmdline(docker_cmdline))
    server_job = jobset.JobSpec(cmdline=docker_cmdline,
                                environ=environ,
                                shortname='interop_server_%s' % language,
                                timeout_seconds=30 * 60)
    server_job.container_name = container_name
    return server_job
コード例 #5
0
def cloud_to_prod_jobspec(language,
                          test_case,
                          server_host_name,
                          server_host_detail,
                          docker_image=None,
                          auth=False,
                          manual_cmd_log=None):
    """Creates jobspec for cloud-to-prod interop test"""
    container_name = None
    cmdargs = [
        '--server_host=%s' % server_host_detail[0],
        '--server_host_override=%s' % server_host_detail[1],
        '--server_port=443', '--use_tls=true',
        '--test_case=%s' % test_case
    ]
    environ = dict(language.cloud_to_prod_env(), **language.global_env())
    if auth:
        auth_cmdargs, auth_env = auth_options(language, test_case)
        cmdargs += auth_cmdargs
        environ.update(auth_env)
    cmdline = bash_cmdline(language.client_cmd(cmdargs))
    cwd = language.client_cwd

    if docker_image:
        container_name = dockerjob.random_name('interop_client_%s' %
                                               language.safename)
        cmdline = docker_run_cmdline(
            cmdline,
            image=docker_image,
            cwd=cwd,
            environ=environ,
            docker_args=['--net=host',
                         '--name=%s' % container_name])
        if manual_cmd_log is not None:
            if manual_cmd_log == []:
                manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' %
                                      docker_image)
            manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
        cwd = None
        environ = None

    suite_name = 'cloud_to_prod_auth' if auth else 'cloud_to_prod'
    test_job = jobset.JobSpec(
        cmdline=cmdline,
        cwd=cwd,
        environ=environ,
        shortname='%s:%s:%s:%s' %
        (suite_name, language, server_host_name, test_case),
        timeout_seconds=_TEST_TIMEOUT,
        flake_retries=4 if args.allow_flakes else 0,
        timeout_retries=2 if args.allow_flakes else 0,
        kill_handler=_job_kill_handler)
    if docker_image:
        test_job.container_name = container_name
    return test_job
コード例 #6
0
def server_jobspec(language,
                   docker_image,
                   insecure=False,
                   manual_cmd_log=None):
    """Create jobspec for running a server"""
    container_name = dockerjob.random_name('interop_server_%s' %
                                           language.safename)
    cmdline = bash_cmdline(
        language.server_cmd([
            '--port=%s' % _DEFAULT_SERVER_PORT,
            '--use_tls=%s' % ('false' if insecure else 'true')
        ]))
    environ = language.global_env()
    if language.safename == 'http2':
        # we are running the http2 interop server. Open next N ports beginning
        # with the server port. These ports are used for http2 interop test
        # (one test case per port). We also attach the docker container running
        # the server to local network, so we don't have to mess with port mapping
        port_args = [
            '-p',
            str(_DEFAULT_SERVER_PORT + 0),
            '-p',
            str(_DEFAULT_SERVER_PORT + 1),
            '-p',
            str(_DEFAULT_SERVER_PORT + 2),
            '-p',
            str(_DEFAULT_SERVER_PORT + 3),
            '-p',
            str(_DEFAULT_SERVER_PORT + 4),
            '-p',
            str(_DEFAULT_SERVER_PORT + 5),
            '-p',
            str(_DEFAULT_SERVER_PORT + 6),
            '--net=host',
        ]
    else:
        port_args = ['-p', str(_DEFAULT_SERVER_PORT)]

    docker_cmdline = docker_run_cmdline(cmdline,
                                        image=docker_image,
                                        cwd=language.server_cwd,
                                        environ=environ,
                                        docker_args=port_args +
                                        ['--name=%s' % container_name])
    if manual_cmd_log is not None:
        manual_cmd_log.append(manual_cmdline(docker_cmdline))
    server_job = jobset.JobSpec(cmdline=docker_cmdline,
                                environ=environ,
                                shortname='interop_server_%s' % language,
                                timeout_seconds=30 * 60)
    server_job.container_name = container_name
    return server_job
コード例 #7
0
ファイル: run_interop_tests.py プロジェクト: yugui/grpc
def cloud_to_cloud_jobspec(language, test_case, server_name, server_host,
                           server_port, docker_image=None, insecure=False):
  """Creates jobspec for cloud-to-cloud interop test"""
  interop_only_options = [
      '--server_host_override=foo.test.google.fr',
      '--use_tls=%s' % ('false' if insecure else 'true'),
      '--use_test_ca=true',
  ]
  common_options = [
      '--test_case=%s' % test_case,
      '--server_host=%s' % server_host,
  ]
  if test_case in _HTTP2_BADSERVER_TEST_CASES:
    # We are running the http2_badserver_interop test. Adjust command line accordingly.
    offset = sorted(_HTTP2_BADSERVER_TEST_CASES).index(test_case)
    client_options = common_options + ['--server_port=%s' %
                                       (int(server_port)+offset)]
    cmdline = bash_cmdline(language.client_cmd_http2interop(client_options))
  else:
    client_options = interop_only_options + common_options + ['--server_port=%s' % server_port]
    cmdline = bash_cmdline(language.client_cmd(client_options))

  cwd = language.client_cwd
  environ = language.global_env()
  if docker_image:
    container_name = dockerjob.random_name('interop_client_%s' % language.safename)
    cmdline = docker_run_cmdline(cmdline,
                                 image=docker_image,
                                 environ=environ,
                                 cwd=cwd,
                                 docker_args=['--net=host',
                                              '--name', container_name])
    cwd = None

  test_job = jobset.JobSpec(
          cmdline=cmdline,
          cwd=cwd,
          environ=environ,
          shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name,
                                                        test_case),
          timeout_seconds=_TEST_TIMEOUT,
          flake_retries=5 if args.allow_flakes else 0,
          timeout_retries=2 if args.allow_flakes else 0,
          kill_handler=_job_kill_handler)
  if docker_image:
    test_job.container_name = container_name
  return test_job
コード例 #8
0
def cloud_to_cloud_jobspec(language, test_case, server_name, server_host,
                           server_port, docker_image=None):
  """Creates jobspec for cloud-to-cloud interop test"""
  interop_only_options = [
      '--server_host_override=foo.test.google.fr',
      '--use_tls=true',
      '--use_test_ca=true',
  ]
  common_options = [
      '--test_case=%s' % test_case,
      '--server_host=%s' % server_host,
  ]
  if test_case in _HTTP2_BADSERVER_TEST_CASES:
    # We are running the http2_badserver_interop test. Adjust command line accordingly.
    offset = sorted(_HTTP2_BADSERVER_TEST_CASES).index(test_case)
    client_options = common_options + ['--server_port=%s' %
                                       (int(server_port)+offset)]
    cmdline = bash_cmdline(language.client_cmd_http2interop(client_options))
  else:
    client_options = interop_only_options + common_options + ['--server_port=%s' % server_port]
    cmdline = bash_cmdline(language.client_cmd(client_options))

  cwd = language.client_cwd
  environ = language.global_env()
  if docker_image:
    container_name = dockerjob.random_name('interop_client_%s' % language.safename)
    cmdline = docker_run_cmdline(cmdline,
                                 image=docker_image,
                                 environ=environ,
                                 cwd=cwd,
                                 docker_args=['--net=host',
                                              '--name', container_name])
    cwd = None

  test_job = jobset.JobSpec(
          cmdline=cmdline,
          cwd=cwd,
          environ=environ,
          shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name,
                                                        test_case),
          timeout_seconds=_TEST_TIMEOUT,
          flake_retries=5 if args.allow_flakes else 0,
          timeout_retries=2 if args.allow_flakes else 0,
          kill_handler=_job_kill_handler)
  if docker_image:
    test_job.container_name = container_name
  return test_job
コード例 #9
0
ファイル: run_interop_tests.py プロジェクト: rltvty/grpc
def cloud_to_cloud_jobspec(language, test_case, server_name, server_host,
                           server_port, docker_image=None, insecure=False,
                           manual_cmd_log=None):
  """Creates jobspec for cloud-to-cloud interop test"""
  interop_only_options = [
      '--server_host_override=foo.test.google.fr',
      '--use_tls=%s' % ('false' if insecure else 'true'),
      '--use_test_ca=true',
  ]
  common_options = [
      '--test_case=%s' % test_case,
      '--server_host=%s' % server_host,
      '--server_port=%s' % server_port,
  ]
  if test_case in _HTTP2_BADSERVER_TEST_CASES:
    cmdline = bash_cmdline(language.client_cmd_http2interop(common_options))
    cwd = language.http2_cwd
  else:
    cmdline = bash_cmdline(language.client_cmd(common_options+interop_only_options))
    cwd = language.client_cwd

  environ = language.global_env()
  if docker_image:
    container_name = dockerjob.random_name('interop_client_%s' % language.safename)
    cmdline = docker_run_cmdline(cmdline,
                                 image=docker_image,
                                 environ=environ,
                                 cwd=cwd,
                                 docker_args=['--net=host',
                                              '--name=%s' % container_name])
    if manual_cmd_log is not None:
      manual_cmd_log.append(manual_cmdline(cmdline))
    cwd = None

  test_job = jobset.JobSpec(
          cmdline=cmdline,
          cwd=cwd,
          environ=environ,
          shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name,
                                                        test_case),
          timeout_seconds=_TEST_TIMEOUT,
          flake_retries=5 if args.allow_flakes else 0,
          timeout_retries=2 if args.allow_flakes else 0,
          kill_handler=_job_kill_handler)
  if docker_image:
    test_job.container_name = container_name
  return test_job
コード例 #10
0
ファイル: run_stress_tests.py プロジェクト: zs1621/grpc
def cloud_to_cloud_jobspec(language,
                           test_cases,
                           server_addresses,
                           test_duration_secs,
                           num_channels_per_server,
                           num_stubs_per_channel,
                           metrics_port,
                           docker_image=None):
    """Creates jobspec for cloud-to-cloud interop test"""
    cmdline = bash_login_cmdline(
        language.client_cmd([
            '--test_cases=%s' % test_cases,
            '--server_addresses=%s' % server_addresses,
            '--test_duration_secs=%s' % test_duration_secs,
            '--num_stubs_per_channel=%s' % num_stubs_per_channel,
            '--num_channels_per_server=%s' % num_channels_per_server,
            '--metrics_port=%s' % metrics_port
        ]))
    print(cmdline)
    cwd = language.client_cwd
    environ = language.global_env()
    if docker_image:
        container_name = dockerjob.random_name('interop_client_%s' %
                                               language.safename)
        cmdline = docker_run_cmdline(
            cmdline,
            image=docker_image,
            environ=environ,
            cwd=cwd,
            docker_args=['--net=host', '--name', container_name])
        cwd = None

    test_job = jobset.JobSpec(
        cmdline=cmdline,
        cwd=cwd,
        environ=environ,
        shortname='cloud_to_cloud:%s:%s_server:stress_test' %
        (language, server_name),
        timeout_seconds=test_duration_secs * 2,
        flake_retries=0,
        timeout_retries=0,
        kill_handler=_job_kill_handler)
    test_job.container_name = container_name
    return test_job
コード例 #11
0
def lb_client_interop_jobspec(language,
                              dns_server_ip,
                              docker_image,
                              transport_security='tls'):
    """Runs a gRPC client under test in a docker container"""
    interop_only_options = [
        '--server_host=%s' % _SERVICE_NAME,
        '--server_port=%d' % _FALLBACK_SERVER_PORT
    ] + transport_security_to_args(transport_security)
    # Don't set the server host override in any client;
    # Go and Java default to no override.
    # We're using a DNS server so there's no need.
    if language.safename == 'c++':
        interop_only_options += ['--server_host_override=""']
    # Don't set --use_test_ca; we're configuring
    # clients to use test CA's via alternate means.
    interop_only_options += ['--use_test_ca=false']
    client_args = language.client_cmd(interop_only_options)
    container_name = dockerjob.random_name(
        'lb_interop_client_%s' % language.safename)
    docker_cmdline = docker_run_cmdline(
        client_args,
        environ=language.global_env(),
        image=docker_image,
        cwd=language.client_cwd,
        docker_args=[
            '--dns=%s' % dns_server_ip,
            '--net=host',
            '--name=%s' % container_name,
            '-v',
            '{grpc_grpc_root_dir}:/external_mount:ro'.format(
                grpc_grpc_root_dir=ROOT),
        ])
    jobset.message(
        'IDLE',
        'docker_cmdline:\b|%s|' % ' '.join(docker_cmdline),
        do_newline=True)
    test_job = jobset.JobSpec(
        cmdline=docker_cmdline,
        shortname=('lb_interop_client:%s' % language),
        timeout_seconds=_TEST_TIMEOUT,
        kill_handler=_job_kill_handler)
    test_job.container_name = container_name
    return test_job
コード例 #12
0
def lb_client_interop_jobspec(language,
                              dns_server_ip,
                              docker_image,
                              transport_security='tls'):
    """Runs a gRPC client under test in a docker container"""
    interop_only_options = [
        '--server_host=%s' % _SERVICE_NAME,
        '--server_port=%d' % _FALLBACK_SERVER_PORT
    ] + transport_security_to_args(transport_security)
    # Don't set the server host override in any client;
    # Go and Java default to no override.
    # We're using a DNS server so there's no need.
    if language.safename == 'c++':
        interop_only_options += ['--server_host_override=""']
    # Don't set --use_test_ca; we're configuring
    # clients to use test CA's via alternate means.
    interop_only_options += ['--use_test_ca=false']
    client_args = language.client_cmd(interop_only_options)
    container_name = dockerjob.random_name('lb_interop_client_%s' %
                                           language.safename)
    docker_cmdline = docker_run_cmdline(
        client_args,
        environ=language.global_env(),
        image=docker_image,
        cwd=language.client_cwd,
        docker_args=[
            '--dns=%s' % dns_server_ip,
            '--net=host',
            '--name=%s' % container_name,
            '-v',
            '{grpc_grpc_root_dir}:/external_mount:ro'.format(
                grpc_grpc_root_dir=ROOT),
        ])
    jobset.message('IDLE',
                   'docker_cmdline:\b|%s|' % ' '.join(docker_cmdline),
                   do_newline=True)
    test_job = jobset.JobSpec(cmdline=docker_cmdline,
                              shortname=('lb_interop_client:%s' % language),
                              timeout_seconds=_TEST_TIMEOUT,
                              kill_handler=_job_kill_handler)
    test_job.container_name = container_name
    return test_job
コード例 #13
0
ファイル: run_stress_tests.py プロジェクト: Indifer/grpc
def server_jobspec(language, docker_image, test_duration_secs):
  """Create jobspec for running a server"""
  container_name = dockerjob.random_name('interop_server_%s' %
                                         language.safename)
  cmdline = bash_login_cmdline(language.server_cmd(['--port=%s' %
                                                    _DEFAULT_SERVER_PORT]))
  environ = language.global_env()
  docker_cmdline = docker_run_cmdline(
      cmdline,
      image=docker_image,
      cwd=language.server_cwd,
      environ=environ,
      docker_args=['-p', str(_DEFAULT_SERVER_PORT), '--name', container_name])

  server_job = jobset.JobSpec(cmdline=docker_cmdline,
                              environ=environ,
                              shortname='interop_server_%s' % language,
                              timeout_seconds=test_duration_secs * 3)
  server_job.container_name = container_name
  return server_job
コード例 #14
0
def grpc_server_in_docker_jobspec(server_cmdline, shortname):
    container_name = dockerjob.random_name(shortname)
    environ = {
        'GRPC_GO_LOG_VERBOSITY_LEVEL': '3',
        'GRPC_GO_LOG_SEVERITY_LEVEL': 'INFO ',
    }
    docker_cmdline = docker_run_cmdline(
        server_cmdline,
        cwd='/go',
        image=docker_images.get(_FAKE_SERVERS_SAFENAME),
        environ=environ,
        docker_args=['--name=%s' % container_name])
    jobset.message('IDLE',
                   'docker_cmdline:\b|%s|' % ' '.join(docker_cmdline),
                   do_newline=True)
    server_job = jobset.JobSpec(cmdline=docker_cmdline,
                                shortname=shortname,
                                timeout_seconds=30 * 60)
    server_job.container_name = container_name
    return server_job
コード例 #15
0
def server_jobspec(language, docker_image, test_duration_secs):
  """Create jobspec for running a server"""
  container_name = dockerjob.random_name('interop_server_%s' %
                                         language.safename)
  cmdline = bash_login_cmdline(language.server_cmd(['--port=%s' %
                                                    _DEFAULT_SERVER_PORT]))
  environ = language.global_env()
  docker_cmdline = docker_run_cmdline(
      cmdline,
      image=docker_image,
      cwd=language.server_cwd,
      environ=environ,
      docker_args=['-p', str(_DEFAULT_SERVER_PORT), '--name', container_name])

  server_job = jobset.JobSpec(cmdline=docker_cmdline,
                              environ=environ,
                              shortname='interop_server_%s' % language,
                              timeout_seconds=test_duration_secs * 3)
  server_job.container_name = container_name
  return server_job
コード例 #16
0
def grpc_server_in_docker_jobspec(server_cmdline, shortname):
    container_name = dockerjob.random_name(shortname)
    environ = {
        'GRPC_GO_LOG_VERBOSITY_LEVEL': '3',
        'GRPC_GO_LOG_SEVERITY_LEVEL': 'INFO ',
    }
    docker_cmdline = docker_run_cmdline(
        server_cmdline,
        cwd='/go',
        image=docker_images.get(_FAKE_SERVERS_SAFENAME),
        environ=environ,
        docker_args=['--name=%s' % container_name])
    jobset.message(
        'IDLE',
        'docker_cmdline:\b|%s|' % ' '.join(docker_cmdline),
        do_newline=True)
    server_job = jobset.JobSpec(
        cmdline=docker_cmdline, shortname=shortname, timeout_seconds=30 * 60)
    server_job.container_name = container_name
    return server_job
コード例 #17
0
ファイル: run_stress_tests.py プロジェクト: Indifer/grpc
def cloud_to_cloud_jobspec(language,
                           test_cases,
                           server_addresses,
                           test_duration_secs,
                           num_channels_per_server,
                           num_stubs_per_channel,
                           metrics_port,
                           docker_image=None):
  """Creates jobspec for cloud-to-cloud interop test"""
  cmdline = bash_login_cmdline(language.client_cmd([
      '--test_cases=%s' % test_cases, '--server_addresses=%s' %
      server_addresses, '--test_duration_secs=%s' % test_duration_secs,
      '--num_stubs_per_channel=%s' % num_stubs_per_channel,
      '--num_channels_per_server=%s' % num_channels_per_server,
      '--metrics_port=%s' % metrics_port
  ]))
  print(cmdline)
  cwd = language.client_cwd
  environ = language.global_env()
  if docker_image:
    container_name = dockerjob.random_name('interop_client_%s' %
                                           language.safename)
    cmdline = docker_run_cmdline(
        cmdline,
        image=docker_image,
        environ=environ,
        cwd=cwd,
        docker_args=['--net=host', '--name', container_name])
    cwd = None

  test_job = jobset.JobSpec(cmdline=cmdline,
                            cwd=cwd,
                            environ=environ,
                            shortname='cloud_to_cloud:%s:%s_server:stress_test' % (
                                language, server_name),
                            timeout_seconds=test_duration_secs * 2,
                            flake_retries=0,
                            timeout_retries=0,
                            kill_handler=_job_kill_handler)
  test_job.container_name = container_name
  return test_job
コード例 #18
0
def cloud_to_cloud_jobspec(language,
                           test_case,
                           server_name,
                           server_host,
                           server_port,
                           docker_image=None):
    """Creates jobspec for cloud-to-cloud interop test"""
    cmdline = bash_cmdline(
        language.client_cmd([
            '--server_host_override=foo.test.google.fr', '--use_tls=true',
            '--use_test_ca=true',
            '--test_case=%s' % test_case,
            '--server_host=%s' % server_host,
            '--server_port=%s' % server_port
        ]))
    cwd = language.client_cwd
    environ = language.global_env()
    if docker_image:
        container_name = dockerjob.random_name('interop_client_%s' %
                                               language.safename)
        cmdline = docker_run_cmdline(
            cmdline,
            image=docker_image,
            environ=environ,
            cwd=cwd,
            docker_args=['--net=host', '--name', container_name])
        cwd = None

    test_job = jobset.JobSpec(cmdline=cmdline,
                              cwd=cwd,
                              environ=environ,
                              shortname='cloud_to_cloud:%s:%s_server:%s' %
                              (language, server_name, test_case),
                              timeout_seconds=_TEST_TIMEOUT,
                              flake_retries=5 if args.allow_flakes else 0,
                              timeout_retries=2 if args.allow_flakes else 0,
                              kill_handler=_job_kill_handler)
    if docker_image:
        test_job.container_name = container_name
    return test_job
コード例 #19
0
ファイル: run_interop_tests.py プロジェクト: yugui/grpc
def server_jobspec(language, docker_image, insecure=False):
  """Create jobspec for running a server"""
  container_name = dockerjob.random_name('interop_server_%s' % language.safename)
  cmdline = bash_cmdline(
      language.server_cmd(['--port=%s' % _DEFAULT_SERVER_PORT,
                           '--use_tls=%s' % ('false' if insecure else 'true')]))
  environ = language.global_env()
  if language.safename == 'http2':
    # we are running the http2 interop server. Open next N ports beginning
    # with the server port. These ports are used for http2 interop test
    # (one test case per port). We also attach the docker container running
    # the server to local network, so we don't have to mess with port mapping
    port_args = [
      '-p', str(_DEFAULT_SERVER_PORT+0),
      '-p', str(_DEFAULT_SERVER_PORT+1),
      '-p', str(_DEFAULT_SERVER_PORT+2),
      '-p', str(_DEFAULT_SERVER_PORT+3),
      '-p', str(_DEFAULT_SERVER_PORT+4),
      '-p', str(_DEFAULT_SERVER_PORT+5),
      '-p', str(_DEFAULT_SERVER_PORT+6),
      '--net=host',
    ]
  else:
    port_args = ['-p', str(_DEFAULT_SERVER_PORT)]

  docker_cmdline = docker_run_cmdline(cmdline,
                                      image=docker_image,
                                      cwd=language.server_cwd,
                                      environ=environ,
                                      docker_args=port_args +
                                        ['--name', container_name])
  server_job = jobset.JobSpec(
          cmdline=docker_cmdline,
          environ=environ,
          shortname='interop_server_%s' % language,
          timeout_seconds=30*60)
  server_job.container_name = container_name
  return server_job
コード例 #20
0
ファイル: run_interop_tests.py プロジェクト: endobson/grpc
def cloud_to_cloud_jobspec(language, test_case, server_name, server_host,
                           server_port, docker_image=None, insecure=False,
                           manual_cmd_log=None):
  """Creates jobspec for cloud-to-cloud interop test"""
  interop_only_options = [
      '--server_host_override=foo.test.google.fr',
      '--use_tls=%s' % ('false' if insecure else 'true'),
      '--use_test_ca=true',
  ]

  client_test_case = test_case
  if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
    client_test_case = _GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES[test_case]
  if client_test_case in language.unimplemented_test_cases():
    print('asking client %s to run unimplemented test case %s' % (repr(language), client_test_case))
    sys.exit(1)

  common_options = [
      '--test_case=%s' % client_test_case,
      '--server_host=%s' % server_host,
      '--server_port=%s' % server_port,
  ]

  if test_case in _HTTP2_SERVER_TEST_CASES:
    if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
      client_options = interop_only_options + common_options
      cmdline = bash_cmdline(language.client_cmd(client_options))
      cwd = language.client_cwd
    else:
      cmdline = bash_cmdline(language.client_cmd_http2interop(common_options))
      cwd = language.http2_cwd
  else:
    cmdline = bash_cmdline(language.client_cmd(common_options+interop_only_options))
    cwd = language.client_cwd

  environ = language.global_env()
  if docker_image and language.safename != 'objc':
    # we can't run client in docker for objc.
    container_name = dockerjob.random_name('interop_client_%s' % language.safename)
    cmdline = docker_run_cmdline(cmdline,
                                 image=docker_image,
                                 environ=environ,
                                 cwd=cwd,
                                 docker_args=['--net=host',
                                              '--name=%s' % container_name])
    if manual_cmd_log is not None:
      if manual_cmd_log == []:
        manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' % docker_image)
      manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
    cwd = None

  test_job = jobset.JobSpec(
          cmdline=cmdline,
          cwd=cwd,
          environ=environ,
          shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name,
                                                        test_case),
          timeout_seconds=_TEST_TIMEOUT,
          flake_retries=5 if args.allow_flakes else 0,
          timeout_retries=2 if args.allow_flakes else 0,
          kill_handler=_job_kill_handler)
  if docker_image:
    test_job.container_name = container_name
  return test_job
コード例 #21
0
def cloud_to_cloud_jobspec(language,
                           test_case,
                           server_name,
                           server_host,
                           server_port,
                           docker_image=None,
                           insecure=False,
                           manual_cmd_log=None):
    """Creates jobspec for cloud-to-cloud interop test"""
    interop_only_options = [
        '--server_host_override=foo.test.google.fr',
        '--use_tls=%s' % ('false' if insecure else 'true'),
        '--use_test_ca=true',
    ]

    client_test_case = test_case
    if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
        client_test_case = _GRPC_CLIENT_TEST_CASES_FOR_HTTP2_SERVER_TEST_CASES[
            test_case]
    if client_test_case in language.unimplemented_test_cases():
        print('asking client %s to run unimplemented test case %s' %
              (repr(language), client_test_case))
        sys.exit(1)

    common_options = [
        '--test_case=%s' % client_test_case,
        '--server_host=%s' % server_host,
        '--server_port=%s' % server_port,
    ]

    if test_case in _HTTP2_SERVER_TEST_CASES:
        if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS:
            client_options = interop_only_options + common_options
            cmdline = bash_cmdline(language.client_cmd(client_options))
            cwd = language.client_cwd
        else:
            cmdline = bash_cmdline(
                language.client_cmd_http2interop(common_options))
            cwd = language.http2_cwd
    else:
        cmdline = bash_cmdline(
            language.client_cmd(common_options + interop_only_options))
        cwd = language.client_cwd

    environ = language.global_env()
    if docker_image and language.safename != 'objc':
        # we can't run client in docker for objc.
        container_name = dockerjob.random_name('interop_client_%s' %
                                               language.safename)
        cmdline = docker_run_cmdline(
            cmdline,
            image=docker_image,
            environ=environ,
            cwd=cwd,
            docker_args=['--net=host',
                         '--name=%s' % container_name])
        if manual_cmd_log is not None:
            if manual_cmd_log == []:
                manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' %
                                      docker_image)
            manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
        cwd = None

    test_job = jobset.JobSpec(cmdline=cmdline,
                              cwd=cwd,
                              environ=environ,
                              shortname='cloud_to_cloud:%s:%s_server:%s' %
                              (language, server_name, test_case),
                              timeout_seconds=_TEST_TIMEOUT,
                              flake_retries=4 if args.allow_flakes else 0,
                              timeout_retries=2 if args.allow_flakes else 0,
                              kill_handler=_job_kill_handler)
    if docker_image:
        test_job.container_name = container_name
    return test_job