#!/usr/bin/env python3 # Copyright 2015-2016 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """VSPERF main script. """ import logging import os import sys import argparse import time import datetime import shutil import unittest import xmlrunner import locale import copy import glob import subprocess sys.dont_write_bytecode = True from conf import settings from conf import get_test_param from core.loader import Loader from testcases import PerformanceTestCase from testcases import IntegrationTestCase from tools import tasks from tools import networkcard from tools import functions from tools.pkt_gen import trafficgen from tools.opnfvdashboard import opnfvdashboard from tools.pkt_gen.trafficgen.trafficgenhelper import TRAFFIC_DEFAULTS import core.component_factory as component_factory VERBOSITY_LEVELS = { 'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL } _TEMPLATE_RST = {'head' : 'tools/report/report_head.rst', 'foot' : 'tools/report/report_foot.rst', 'final' : 'test_report.rst', 'tmp' : 'tools/report/report_tmp_caption.rst' } _LOGGER = logging.getLogger() def parse_arguments(): """ Parse command line arguments. """ class _SplitTestParamsAction(argparse.Action): """ Parse and split the '--test-params' argument. This expects either 'x=y', 'x=y,z' or 'x' (implicit true) values. For multiple overrides use a ; separated list for e.g. --test-params 'x=z; y=a,b' """ def __call__(self, parser, namespace, values, option_string=None): results = {} for value in values.split(';'): result = [key.strip() for key in value.split('=')] if len(result) == 1: results[result[0]] = True elif len(result) == 2: results[result[0]] = result[1] else: raise argparse.ArgumentTypeError( 'expected \'%s\' to be of format \'key=val\' or' ' \'key\'' % result) setattr(namespace, self.dest, results) class _ValidateFileAction(argparse.Action): """Validate a file can be read from before using it. """ def __call__(self, parser, namespace, values, option_string=None): if not os.path.isfile(values): raise argparse.ArgumentTypeError( 'the path \'%s\' is not a valid path' % values) elif not os.access(values, os.R_OK): raise argparse.ArgumentTypeError( 'the path \'%s\' is not accessible' % values) setattr(namespace, self.dest, values) class _ValidateDirAction(argparse.Action): """Validate a directory can be written to before using it. """ def __call__(self, parser, namespace, values, option_string=None): if not os.path.isdir(values): raise argparse.ArgumentTypeError( 'the path \'%s\' is not a valid path' % values) elif not os.access(values, os.W_OK): raise argparse.ArgumentTypeError( 'the path \'%s\' is not accessible' % values) setattr(namespace, self.dest, values) def list_logging_levels(): """Give a summary of all available logging levels. :return: List of verbosity level names in decreasing order of verbosity """ return sorted(VERBOSITY_LEVELS.keys(), key=lambda x: VERBOSITY_LEVELS[x]) parser = argparse.ArgumentParser(prog=__file__, formatter_class= argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--version', action='version', version='%(prog)s 0.2') parser.add_argument('--list', '--list-tests', action='store_true', help='list all tests and exit') parser.add_argument('--list-trafficgens', action='store_true', help='list all traffic generators and exit') parser.add_argument('--list-collectors', action='store_true', help='list all system metrics loggers and exit') parser.add_argument('--list-vswitches', action='store_true', help='list all system vswitches and exit') parser.add_argument('--list-fwdapps', action='store_true', help='list all system forwarding applications and exit') parser.add_argument('--list-vnfs', action='store_true', help='list all system vnfs and exit') parser.add_argument('--list-settings', action='store_true', help='list effective settings configuration and exit') parser.add_argument('exact_test_name', nargs='*', help='Exact names of\ tests to run. E.g "vsperf phy2phy_tput phy2phy_cont"\ runs only the two tests with those exact names.\ To run all tests omit both positional args and --tests arg.') group = parser.add_argument_group('test selection options') group.add_argument('-m', '--mode', help='vsperf mode of operation;\ Values: "normal" - execute vSwitch, VNF and traffic generator;\ "trafficgen" - execute only traffic generator; "trafficgen-off" \ - execute vSwitch and VNF; trafficgen-pause - execute vSwitch \ and VNF but pause before traffic transmission ', default='normal') group.add_argument('-f', '--test-spec', help='test specification file') group.add_argument('-d', '--test-dir', help='directory containing tests') group.add_argument('-t', '--tests', help='Comma-separated list of terms \ indicating tests to run. e.g. "RFC2544,!p2p" - run all tests whose\ name contains RFC2544 less those containing "p2p"; "!back2back" - \ run all tests except those containing back2back') group.add_argument('--verbosity', choices=list_logging_levels(), help='debug level') group.add_argument('--integration', action='store_true', help='execute integration tests') group.add_argument('--trafficgen', help='traffic generator to use') group.add_argument('--vswitch', help='vswitch implementation to use') group.add_argument('--fwdapp', help='packet forwarding application to use') group.add_argument('--vnf', help='vnf to use') group.add_argument('--sysmetrics', help='system metrics logger to use') group = parser.add_argument_group('test behavior options') group.add_argument('--xunit', action='store_true', help='enable xUnit-formatted output') group.add_argument('--xunit-dir', actio
heat_template_version: pike

description: >
  OpenStack Neutron openvswitch service

parameters:
  DockerOpenvswitchImage:
    description: image
    type: string
  DockerNeutronConfigImage:
    description: The container image to use for the neutron config_volume
    type: string
  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
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json

resources:

  ContainersCommon:
    type: ./containers-common.yaml

  NeutronOvsAgentBase:
    type: ../../puppet/services/neutron-ovs-agent.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 Neutron openvswitch service
    value:
      service_name: {get_attr: [NeutronOvsAgentBase, role_data, service_name]}
      config_settings: {get_attr: [NeutronOvsAgentBase, role_data, config_settings]}
      step_config: &step_config
        get_attr: [NeutronOvsAgentBase, role_data, step_config]
      puppet_config:
        config_volume: neutron
        puppet_tags: neutron_config,neutron_agent_ovs,neutron_plugin_ml2
        step_config: *step_config
        config_image: {get_param: DockerNeutronConfigImage}
      kolla_config:
        /var/lib/kolla/config_files/neutron_ovs_agent.json:
          command: /usr/bin/neutron-openvswitch-agent --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/openvswitch_agent.ini --config-file /etc/neutron/plugins/ml2/ml2_conf.ini --config-dir /etc/neutron/conf.d/common
          config_files:
            - source: "/var/lib/kolla/config_files/src/*"
              dest: "/"
              merge: true
              preserve_properties: true
          permissions:
            - path: /var/log/neutron
              owner: neutron:neutron
              recurse: true
      docker_config:
        step_4:
          neutron_ovs_agent:
            image: {get_param: DockerOpenvswitchImage}
            net: host
            pid: host
            privileged: true
            restart: always
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, volumes]}
                -
                  -