Beispiel #1
0
    def launch_clients(self, client_pod_spec):
        is_success = True

        # The command to run inside the container is the wrapper script (which then
        # launches the actual stress client)
        container_cmd = client_pod_spec.template.wrapper_script_path

        # The parameters to the wrapper script (defined in
        # client_pod_spec.template.wrapper_script_path) are are injected into the
        # container via environment variables
        client_env = self.gke_env.copy()
        client_env.update(client_pod_spec.template.env_dict)
        client_env.update({
            'STRESS_TEST_IMAGE_TYPE':
            'CLIENT',
            'STRESS_TEST_CMD':
            client_pod_spec.template.stress_client_cmd,
            'STRESS_TEST_ARGS_STR':
            self._args_dict_to_str(client_pod_spec.get_client_args_dict()),
            'METRICS_CLIENT_CMD':
            client_pod_spec.template.metrics_client_cmd,
            'METRICS_CLIENT_ARGS_STR':
            self._args_dict_to_str(client_pod_spec.template.metrics_args_dict),
            'POLL_INTERVAL_SECS':
            str(client_pod_spec.template.poll_interval_secs),
            'WILL_RUN_FOREVER':
            str(client_pod_spec.template.will_run_forever)
        })

        for pod_name in client_pod_spec.pod_names():
            client_env['POD_NAME'] = pod_name
            print('Creating client: %s' % pod_name)
            is_success = kubernetes_api.create_pod_and_service(
                'localhost',
                self.kubernetes_port,
                'default',  # default namespace,
                pod_name,
                client_pod_spec.docker_image.tag_name,
                [client_pod_spec.template.metrics_port
                 ],  # Ports to expose on the pod
                [container_cmd],
                [],  # Empty args list since all args are passed via env variables
                client_env,
                True  # Client is a headless service (no need for an external ip)
            )

            if not is_success:
                print('Error in launching client %s' % pod_name)
                break

        if is_success:
            print('Successfully created all client(s)')

        return is_success
Beispiel #2
0
  def launch_clients(self, client_pod_spec):
    is_success = True

    # The command to run inside the container is the wrapper script (which then
    # launches the actual stress client)
    container_cmd = client_pod_spec.template.wrapper_script_path

    # The parameters to the wrapper script (defined in
    # client_pod_spec.template.wrapper_script_path) are are injected into the
    # container via environment variables
    client_env = self.gke_env.copy()
    client_env.update(client_pod_spec.template.env_dict)
    client_env.update({
        'STRESS_TEST_IMAGE_TYPE': 'CLIENT',
        'STRESS_TEST_CMD': client_pod_spec.template.stress_client_cmd,
        'STRESS_TEST_ARGS_STR': self._args_dict_to_str(
            client_pod_spec.get_client_args_dict()),
        'METRICS_CLIENT_CMD': client_pod_spec.template.metrics_client_cmd,
        'METRICS_CLIENT_ARGS_STR': self._args_dict_to_str(
            client_pod_spec.template.metrics_args_dict),
        'POLL_INTERVAL_SECS': str(client_pod_spec.template.poll_interval_secs),
        'WILL_RUN_FOREVER': str(client_pod_spec.template.will_run_forever)
    })

    for pod_name in client_pod_spec.pod_names():
      client_env['POD_NAME'] = pod_name
      print 'Creating client: %s' % pod_name
      is_success = kubernetes_api.create_pod_and_service(
          'localhost',
          self.kubernetes_port,
          'default',  # default namespace,
          pod_name,
          client_pod_spec.docker_image.tag_name,
          [client_pod_spec.template.metrics_port],  # Ports to expose on the pod
          [container_cmd],
          [],  # Empty args list since all args are passed via env variables
          client_env,
          True  # Client is a headless service (no need for an external ip)
      )

      if not is_success:
        print 'Error in launching client %s' % pod_name
        break

    if is_success:
      print 'Successfully created all client(s)'

    return is_success
Beispiel #3
0
    def launch_servers(self, server_pod_spec):
        is_success = True

        # The command to run inside the container is the wrapper script (which then
        # launches the actual server)
        container_cmd = server_pod_spec.template.wrapper_script_path

        # The parameters to the wrapper script (defined in
        # server_pod_spec.template.wrapper_script_path) are are injected into the
        # container via environment variables
        server_env = self.gke_env.copy()
        server_env.update(server_pod_spec.template.env_dict)
        server_env.update({
            'STRESS_TEST_IMAGE_TYPE':
            'SERVER',
            'STRESS_TEST_CMD':
            server_pod_spec.template.server_cmd,
            'STRESS_TEST_ARGS_STR':
            self._args_dict_to_str(server_pod_spec.template.server_args_dict),
            'WILL_RUN_FOREVER':
            str(server_pod_spec.template.will_run_forever)
        })

        for pod_name in server_pod_spec.pod_names():
            server_env['POD_NAME'] = pod_name
            print('Creating server: %s' % pod_name)
            is_success = kubernetes_api.create_pod_and_service(
                'localhost',
                self.kubernetes_port,
                'default',  # Use 'default' namespace
                pod_name,
                server_pod_spec.docker_image.tag_name,
                [server_pod_spec.template.server_port
                 ],  # Ports to expose on the pod
                [container_cmd],
                [],  # Args list is empty since we are passing all args via env variables
                server_env,
                True  # Headless = True for server to that GKE creates a DNS record for pod_name
            )
            if not is_success:
                print('Error in launching server: %s' % pod_name)
                break

        if is_success:
            print('Successfully created server(s)')

        return is_success
def _launch_server(gke_settings, stress_server_settings, bq_settings,
                   kubernetes_proxy):
    """ Launches a stress test server instance in GKE cluster """
    if not kubernetes_proxy.is_started:
        print 'Kubernetes proxy must be started before calling this function'
        return False

    # This is the wrapper script that is run in the container. This script runs
    # the actual stress test server
    server_cmd_list = [
        '/var/local/git/grpc/tools/gcp/stress_test/run_server.py'
    ]

    # run_server.py does not take any args from the command line. The args are
    # instead passed via environment variables (see server_env below)
    server_arg_list = []

    # The parameters to the script run_server.py are injected into the container
    # via environment variables
    server_env = {
        'STRESS_TEST_IMAGE_TYPE': 'SERVER',
        'STRESS_TEST_IMAGE': '/var/local/git/grpc/bins/opt/interop_server',
        'STRESS_TEST_ARGS_STR':
        '--port=%s' % stress_server_settings.server_port,
        'RUN_ID': bq_settings.run_id,
        'POD_NAME': stress_server_settings.server_pod_name,
        'GCP_PROJECT_ID': gke_settings.project_id,
        'DATASET_ID': bq_settings.dataset_id,
        'SUMMARY_TABLE_ID': bq_settings.summary_table_id,
        'QPS_TABLE_ID': bq_settings.qps_table_id
    }

    # Launch Server
    is_success = kubernetes_api.create_pod_and_service(
        'localhost',
        kubernetes_proxy.get_port(),
        'default',  # Use 'default' namespace
        stress_server_settings.server_pod_name,
        gke_settings.tag_name,
        [stress_server_settings.server_port],  # Port that should be exposed
        server_cmd_list,
        server_arg_list,
        server_env,
        True  # Headless = True for server. Since we want DNS records to be created by GKE
    )

    return is_success
def _launch_server(gke_settings, stress_server_settings, bq_settings,
                   kubernetes_proxy):
    """ Launches a stress test server instance in GKE cluster """
    if not kubernetes_proxy.is_started:
        print 'Kubernetes proxy must be started before calling this function'
        return False

    # This is the wrapper script that is run in the container. This script runs
    # the actual stress test server
    server_cmd_list = [
        '/var/local/git/grpc/tools/gcp/stress_test/run_server.py'
    ]

    # run_server.py does not take any args from the command line. The args are
    # instead passed via environment variables (see server_env below)
    server_arg_list = []

    # The parameters to the script run_server.py are injected into the container
    # via environment variables
    server_env = {
        'STRESS_TEST_IMAGE_TYPE': 'SERVER',
        'STRESS_TEST_IMAGE': '/var/local/git/grpc/bins/opt/interop_server',
        'STRESS_TEST_ARGS_STR':
        '--port=%s' % stress_server_settings.server_port,
        'RUN_ID': bq_settings.run_id,
        'POD_NAME': stress_server_settings.server_pod_name,
        'GCP_PROJECT_ID': gke_settings.project_id,
        'DATASET_ID': bq_settings.dataset_id,
        'SUMMARY_TABLE_ID': bq_settings.summary_table_id,
        'QPS_TABLE_ID': bq_settings.qps_table_id
    }

    # Launch Server
    is_success = kubernetes_api.create_pod_and_service(
        'localhost',
        kubernetes_proxy.get_port(),
        'default',  # Use 'default' namespace
        stress_server_settings.server_pod_name,
        gke_settings.tag_name,
        [stress_server_settings.server_port],  # Port that should be exposed
        server_cmd_list,
        server_arg_list,
        server_env,
        True  # Headless = True for server. Since we want DNS records to be created by GKE
    )

    return is_success
Beispiel #6
0
  def launch_servers(self, server_pod_spec):
    is_success = True

    # The command to run inside the container is the wrapper script (which then
    # launches the actual server)
    container_cmd = server_pod_spec.template.wrapper_script_path

    # The parameters to the wrapper script (defined in
    # server_pod_spec.template.wrapper_script_path) are are injected into the
    # container via environment variables
    server_env = self.gke_env.copy()
    server_env.update(server_pod_spec.template.env_dict)
    server_env.update({
        'STRESS_TEST_IMAGE_TYPE': 'SERVER',
        'STRESS_TEST_CMD': server_pod_spec.template.server_cmd,
        'STRESS_TEST_ARGS_STR': self._args_dict_to_str(
            server_pod_spec.template.server_args_dict),
        'WILL_RUN_FOREVER': str(server_pod_spec.template.will_run_forever)
    })

    for pod_name in server_pod_spec.pod_names():
      server_env['POD_NAME'] = pod_name
      print 'Creating server: %s' % pod_name
      is_success = kubernetes_api.create_pod_and_service(
          'localhost',
          self.kubernetes_port,
          'default',  # Use 'default' namespace
          pod_name,
          server_pod_spec.docker_image.tag_name,
          [server_pod_spec.template.server_port],  # Ports to expose on the pod
          [container_cmd],
          [],  # Args list is empty since we are passing all args via env variables
          server_env,
          True  # Headless = True for server to that GKE creates a DNS record for pod_name
      )
      if not is_success:
        print 'Error in launching server: %s' % pod_name
        break

    if is_success:
      print 'Successfully created server(s)'

    return is_success
def _launch_client(gke_settings, stress_server_settings, stress_client_settings,
                   bq_settings, kubernetes_proxy):
  """ Launches a configurable number of stress test clients on GKE cluster """
  if not kubernetes_proxy.is_started:
    print 'Kubernetes proxy must be started before calling this function'
    return False

  stress_client_arg_list = [
      '--server_addresses=%s' % stress_client_settings.server_addresses,
      '--test_cases=%s' % stress_client_settings.test_cases_str,
      '--num_stubs_per_channel=%d' %
      stress_client_settings.num_stubs_per_channel
  ]

  # This is the wrapper script that is run in the container. This script runs
  # the actual stress client
  client_cmd_list = ['/var/local/git/grpc/tools/gcp/stress_test/run_client.py']

  # run_client.py takes no args. All args are passed as env variables (see
  # client_env)
  client_arg_list = []

  metrics_server_address = 'localhost:%d' % stress_client_settings.metrics_port
  metrics_client_arg_list = [
      '--metrics_server_address=%s' % metrics_server_address,
      '--total_only=true'
  ]

  # The parameters to the script run_client.py are injected into the container
  # via environment variables
  client_env = {
      'STRESS_TEST_IMAGE_TYPE': 'CLIENT',
      'STRESS_TEST_IMAGE': '/var/local/git/grpc/bins/opt/stress_test',
      'STRESS_TEST_ARGS_STR': ' '.join(stress_client_arg_list),
      'METRICS_CLIENT_IMAGE': '/var/local/git/grpc/bins/opt/metrics_client',
      'METRICS_CLIENT_ARGS_STR': ' '.join(metrics_client_arg_list),
      'RUN_ID': bq_settings.run_id,
      'POLL_INTERVAL_SECS':
          str(stress_client_settings.stress_client_poll_interval_secs),
      'GCP_PROJECT_ID': gke_settings.project_id,
      'DATASET_ID': bq_settings.dataset_id,
      'SUMMARY_TABLE_ID': bq_settings.summary_table_id,
      'QPS_TABLE_ID': bq_settings.qps_table_id
  }

  for pod_name in stress_client_settings.client_pod_names_list:
    client_env['POD_NAME'] = pod_name
    is_success = kubernetes_api.create_pod_and_service(
        'localhost',  # Since proxy is running on localhost
        kubernetes_proxy.get_port(),
        'default',  # default namespace
        pod_name,
        gke_settings.tag_name,
        [stress_client_settings.metrics_port
        ],  # Client pods expose metrics port
        client_cmd_list,
        client_arg_list,
        client_env,
        False  # Client is not a headless service
    )
    if not is_success:
      print 'Error in launching client %s' % pod_name
      return False

  return True
def _launch_client(gke_settings, stress_server_settings,
                   stress_client_settings, bq_settings, kubernetes_proxy):
    """ Launches a configurable number of stress test clients on GKE cluster """
    if not kubernetes_proxy.is_started:
        print 'Kubernetes proxy must be started before calling this function'
        return False

    stress_client_arg_list = [
        '--server_addresses=%s' % stress_client_settings.server_addresses,
        '--test_cases=%s' % stress_client_settings.test_cases_str,
        '--num_stubs_per_channel=%d' %
        stress_client_settings.num_stubs_per_channel
    ]

    # This is the wrapper script that is run in the container. This script runs
    # the actual stress client
    client_cmd_list = [
        '/var/local/git/grpc/tools/gcp/stress_test/run_client.py'
    ]

    # run_client.py takes no args. All args are passed as env variables (see
    # client_env)
    client_arg_list = []

    metrics_server_address = 'localhost:%d' % stress_client_settings.metrics_port
    metrics_client_arg_list = [
        '--metrics_server_address=%s' % metrics_server_address,
        '--total_only=true'
    ]

    # The parameters to the script run_client.py are injected into the container
    # via environment variables
    client_env = {
        'STRESS_TEST_IMAGE_TYPE':
        'CLIENT',
        'STRESS_TEST_IMAGE':
        '/var/local/git/grpc/bins/opt/stress_test',
        'STRESS_TEST_ARGS_STR':
        ' '.join(stress_client_arg_list),
        'METRICS_CLIENT_IMAGE':
        '/var/local/git/grpc/bins/opt/metrics_client',
        'METRICS_CLIENT_ARGS_STR':
        ' '.join(metrics_client_arg_list),
        'RUN_ID':
        bq_settings.run_id,
        'POLL_INTERVAL_SECS':
        str(stress_client_settings.stress_client_poll_interval_secs),
        'GCP_PROJECT_ID':
        gke_settings.project_id,
        'DATASET_ID':
        bq_settings.dataset_id,
        'SUMMARY_TABLE_ID':
        bq_settings.summary_table_id,
        'QPS_TABLE_ID':
        bq_settings.qps_table_id
    }

    for pod_name in stress_client_settings.client_pod_names_list:
        client_env['POD_NAME'] = pod_name
        is_success = kubernetes_api.create_pod_and_service(
            'localhost',  # Since proxy is running on localhost
            kubernetes_proxy.get_port(),
            'default',  # default namespace
            pod_name,
            gke_settings.tag_name,
            [stress_client_settings.metrics_port
             ],  # Client pods expose metrics port
            client_cmd_list,
            client_arg_list,
            client_env,
            False  # Client is not a headless service
        )
        if not is_success:
            print 'Error in launching client %s' % pod_name
            return False

    return True