From b9850595c9b27752fe48ce874f8dc90d473d9e60 Mon Sep 17 00:00:00 2001 From: yuyang Date: Sun, 18 Sep 2016 05:38:13 +0800 Subject: Add Factor Testcase TX PKT Size JIRA: BOTTLENECK-99 Add factor testcase to locate the bottleneck of tx pkt size. A separated logic for determine if the tx pkt size is the system bottleneck is provided. Change-Id: I9ccbe19c88a72170b66fffd7f1bd7e5a45dbdc27 Signed-off-by: yuyang --- .../testcase_cfg/posca_factor_tx_pkt_size.yaml | 12 ++ .../testcase_script/posca_factor_tx_pkt_size.py | 122 +++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 testsuites/posca/testcase_cfg/posca_factor_tx_pkt_size.yaml create mode 100644 testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py diff --git a/testsuites/posca/testcase_cfg/posca_factor_tx_pkt_size.yaml b/testsuites/posca/testcase_cfg/posca_factor_tx_pkt_size.yaml new file mode 100644 index 00000000..dcceee02 --- /dev/null +++ b/testsuites/posca/testcase_cfg/posca_factor_tx_pkt_size.yaml @@ -0,0 +1,12 @@ +[config] +test_ip: 192.168.23.2:8888 +throughput: 1000 +tool: netperf +protocol: tcp +test_time: 30 +tx pkt sizes: 8 +rx pkt sizes: 8,16,32,64,128,256,512,1024,2048 +tx cache sizes: 2304,4608,9216,18432,32768,65536 +rx cache sizes: 1152,2304,4608,9216,18432,32768,65536,131072 +cpu load: 0.9 +latency: 100000 diff --git a/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py b/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py new file mode 100644 index 00000000..4b44c853 --- /dev/null +++ b/testsuites/posca/testcase_script/posca_factor_tx_pkt_size.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import os +import argparse +import time +import logging +import ConfigParser +import json + +#------------------------------------------------------ +# parser for configuration files in each test case +# ------------------------------------------------------ +parser = argparse.ArgumentParser() +parser.add_argument("-c", "--conf", + help="configuration files for the testcase, in yaml format", + default="/home/opnfv/bottlenecks/testsuites/posca/testcase_cfg/posca_factor_tx_pkt_size.yaml") +args = parser.parse_args() + +cmd="curl -i" +order_arg="-H \"Content-Type: application/json\" -X POST -d \'{\"cmd\": \"start\", \"opts\":{\"output-file\": \"/tem/yardstick.out\"}, \"args\": \"../samples/netperf.yaml\"}'" + +#-------------------------------------------------- +# logging configuration +#-------------------------------------------------- +logger = logging.getLogger(__name__) + +def posca_env_check(): + print "========== posca system bandwidth env check ===========" + if os.path.exists(r'/home/opnfv/bottlenecks/testsuites/posca/test_result/'): + return True + else: + os.mkdirs(r'/home/opnfv/bottlenecks/testsuites/posca/test_result/') + +def posca_output_result(time_new,input_1,input_2,input_3,input_4,input_5,input_6): + save_dic={} + save_dic['rx_pkt_size']=input_1 + save_dic['tx_cache_size']=input_2 + save_dic['tx_cache_size']=input_3 + save_dic['throughput']=input_4 + save_dic['latency']=input_5 + save_dic['cpu_load']=input_6 + with open("/home/opnfv/bottlenecks/testsuites/posca/test_result/factor_tx_pkt_size_%s.json"%(time_new),"a") as f: + f.write(json.dumps(save_dic,f)) + f.write("\n") + +def posca_config_read(config_str): + print "========== posca system bandwidth config read ===========" + + con_dic = {} + config = ConfigParser.ConfigParser() + with open(config_str,"rd") as cfgfile: + config.readfp(cfgfile) + con_dic['test_ip']=config.get("config","test_ip") + con_dic['test_tool']=config.get("config","tool") + con_dic['test_time']=config.get("config","test_time") + con_dic['test_protocol']=config.get("config","protocol") + con_dic['test_tx_pkt_s']=config.get("config","tx pkt sizes") + con_dic['test_rx_pkt_s']=config.get("config","rx pkt sizes") + con_dic['test_tx_cache_s']=config.get("config","tx cache sizes") + con_dic['test_rx_cache_s']=config.get("config","rx cache sizes") + con_dic['test_cpu_load']=config.get("config","cpu load") + con_dic['test_latency']=config.get("config","latency") + + return con_dic + +def posca_run(con_dic): + print "========== run posca system bandwidth ===========" + + test_rx_pkt_s_a = con_dic['test_rx_pkt_s'].split(',') + test_tx_cache_s_a = con_dic['test_tx_cache_s'].split(',') + test_rx_cache_s_a = con_dic['test_rx_cache_s'].split(',') + time_new = time.strftime('%H_%M',time.localtime(time.time())) + bandwidth_tmp = 1 + + for test_rx_cache_s_e in test_rx_cache_s_a: + for test_tx_cache_s_e in test_tx_cache_s_a: + for test_rx_pkt_s_e in test_rx_pkt_s_a: + print "%s,%s,%s"%(test_rx_pkt_s_e,test_tx_cache_s_e,test_rx_cache_s_e) + order_excute = os.popen("%s %s http://%s/api/v3/yardstick/tasks/task %s %s %s"%(cmd,order_arg,con_dic['test_ip'],test_rx_pkt_s_e,test_rx_cache_s_e,test_tx_cache_s_e)) + order_result = order_excute.read() + task_id = order_result.find("task_id") + time.sleep(con_dic['test_time']) + cmd_excute = os.popen( "%s http://%s/api/v3/yardstick/testresults?task_id=%s"%(cmd,con_dic['test_ip'],task_id)) + test_result = cmd_excute.read() + bandwidth = test_result.find("bandwidth") + cpu_load = test_result.find("cpu_load") + latency = test_result.find("latency") + posca_output_result(time_new,test_rx_pkt_s_e,test_rx_cache_s_e,test_tx_cache_s_e,bandwidth,latency,cpu_load) + if (abs(bandwidth-con_dic['test_throughput'])/con_dic['test_throughput'] >0.05) and (latency < con_dic['test_latency']) and (cpu_load < con_dic['test_cpu_load']): + if (abs(bandwidth_tmp-bandwidth)/bandwidth <0.05): + print "%s,%s,%s,%s,%s,%s"%(test_rx_pkt_s_e,test_rx_cache_s_e,test_tx_cache_s_e,bandwidth,latency,cpu_load) + return True + else: + bandwidth_tmp = bandwidth + else: + print "%s,%s,%s,%s,%s,%s"%(test_rx_pkt_s_e,test_rx_cache_s_e,test_tx_cache_s_e,bandwidth,latency,cpu_load) + return False + + +def main(): + if not (args.conf): + logger.error("Configuration files do not exist for the specified testcases") + exit(-1) + else: + testcase_cfg = args.conf + + con_dic=posca_config_read(testcase_cfg) + posca_env_check() + posca_run(con_dic) + + time.sleep(5) + +if __name__=='__main__': + main() -- cgit 1.2.3-korg 00 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
heat_template_version: pike

description: >
  OpenStack containerized Ironic Conductor service

parameters:
  DockerIronicConductorImage:
    description: image
    type: string
  DockerIronicConfigImage:
    description: The container image to use for the ironic config_volume
    type: string
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json
  ServiceData:
    default: {}
    description: Dictionary packing service data
    type: json
  ServiceNetMap:
    default: {}
    description: Mapping of service_name -> network name. Typically set
                 via parameter_defaults in the resource registry.  This
                 mapping overrides those in ServiceNetMapDefaults.
    type: json
  DefaultPasswords:
    default: {}
    type: json
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json

resources:

  ContainersCommon:
    type: ./containers-common.yaml

  MySQLClient:
    type: ../../puppet/services/database/mysql-client.yaml

  IronicConductorBase:
    type: ../../puppet/services/ironic-conductor.yaml
    properties:
      EndpointMap: {get_param: EndpointMap}
      ServiceData: {get_param: ServiceData}
      ServiceNetMap: {get_param: ServiceNetMap}
      DefaultPasswords: {get_param: DefaultPasswords}
      RoleName: {get_param: RoleName}
      RoleParameters: {get_param: RoleParameters}

outputs:
  role_data:
    description: Role data for the Ironic Conductor role.
    value:
      service_name: {get_attr: [IronicConductorBase, role_data, service_name]}
      config_settings:
        map_merge:
          - get_attr: [IronicConductorBase, role_data, config_settings]
          # to avoid hard linking errors we store these on the same
          # volume/device as the ironic master_path
          # https://github.com/docker/docker/issues/7457
          - ironic::drivers::pxe::tftp_root: /var/lib/ironic/tftpboot
          - ironic::drivers::pxe::tftp_master_path: /var/lib/ironic/tftpboot/master_images
          - ironic::pxe::tftp_root: /var/lib/ironic/tftpboot
          - ironic::pxe::http_root: /var/lib/ironic/httpboot
          - ironic::conductor::http_root: /var/lib/ironic/httpboot
      logging_source: {get_attr: [IronicConductorBase, role_data, logging_source]}
      logging_groups: {get_attr: [IronicConductorBase, role_data, logging_groups]}
      step_config: &step_config
        list_join:
          - "\n"
          - - {get_attr: [IronicConductorBase, role_data, step_config]}
            - {get_attr: [MySQLClient, role_data, step_config]}
      service_config_settings: {get_attr: [IronicConductorBase, role_data, service_config_settings]}
      # BEGIN DOCKER SETTINGS
      puppet_config:
        config_volume: ironic
        puppet_tags: ironic_config
        step_config: *step_config
        config_image: {get_param: DockerIronicConfigImage}
      kolla_config:
        /var/lib/kolla/config_files/ironic_conductor.json:
          command: /usr/bin/ironic-conductor
          config_files:
            - source: "/var/lib/kolla/config_files/src/*"
              dest: "/"
              merge: true
              preserve_properties: true
          permissions:
            - path: /var/lib/ironic
              owner: ironic:ironic
              recurse: true
            - path: /var/log/ironic
              owner: ironic:ironic
              recurse: true
      docker_config:
        step_4:
          ironic_conductor:
            start_order: 80
            image: {get_param: DockerIronicConductorImage}
            net: host
            privileged: true
            restart: always
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, volumes]}
                -
                  - /var/lib/kolla/config_files/ironic_conductor.json:/var/lib/kolla/config_files/config.json:ro
                  - /var/lib/config-data/puppet-generated/ironic/:/var/lib/kolla/config_files/src:ro
                  - /lib/modules:/lib/modules:ro
                  - /sys:/sys
                  - /dev:/dev
                  - /run:/run #shared?
                  - /var/lib/ironic:/var/lib/ironic
                  - /var/log/containers/ironic:/var/log/ironic
            environment:
              - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
      host_prep_tasks:
        - name: create persistent directories
          file:
            path: "{{ item }}"
            state: directory
          with_items:
            - /var/log/containers/ironic
            - /var/lib/ironic
        - name: stat /httpboot
          stat: path=/httpboot
          register: stat_httpboot
        - name: stat /tftpboot
          stat: path=/tftpboot
          register: stat_tftpboot
        - name: stat /var/lib/ironic/httpboot
          stat: path=/var/lib/ironic/httpboot
          register: stat_ironic_httpboot
        - name: stat /var/lib/ironic/tftpboot
          stat: path=/var/lib/ironic/tftpboot
          register: stat_ironic_tftpboot
        # cannot use 'copy' module as with 'remote_src' it doesn't support recursion
        - name: migrate /httpboot to containerized (if applicable)
          command: /bin/cp -R /httpboot /var/lib/ironic/httpboot
          when: stat_httpboot.stat.exists and not stat_ironic_httpboot.stat.exists
        - name: migrate /tftpboot to containerized (if applicable)
          command: /bin/cp -R /tftpboot /var/lib/ironic/tftpboot
          when: stat_tftpboot.stat.exists and not stat_ironic_tftpboot.stat.exists
        # Even if there was nothing to copy from original locations,
        # we need to create the dirs before starting the containers
        - name: ensure ironic pxe directories exist
          file:
            path: /var/lib/ironic/{{ item }}
            state: directory
          with_items:
            - httpboot
            - tftpboot
      upgrade_tasks:
        - name: Stop and disable ironic_conductor service
          tags: step2
          service: name=openstack-ironic-conductor state=stopped enabled=no