Merge "Bugfix: task_id parameter from API can not pass to yardstick core"
[yardstick.git] / yardstick / benchmark / scenarios / networking / vtc_throughput_noisy.py
1 #############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 from __future__ import absolute_import
11 import logging
12 import os
13
14 from yardstick.benchmark.scenarios import base
15 import experimental_framework.api as api
16
17 LOG = logging.getLogger(__name__)
18
19
20 class VtcThroughputNoisy(base.Scenario):
21     """Execute Instantiation Validation TC on the vTC
22     """
23     __scenario_type__ = "vtc_throughput_noisy"
24
25     def __init__(self, scenario_cfg, context_cfg):
26         self.scenario_cfg = scenario_cfg
27         self.context_cfg = context_cfg
28         self.options = None
29         self.setup_done = False
30
31     def setup(self):
32         """scenario setup"""
33
34         self.options = self.scenario_cfg['options']
35         self.setup_done = True
36
37     def run(self, result):
38         """execute test"""
39
40         if not self.setup_done:
41             self.setup()
42
43         heat_template = 'vTC.yaml'
44         iterations = 1
45
46         openstack_credentials = {
47             'ip_controller': '0.0.0.0',
48             'heat_url': '***',
49             'auth_uri': os.environ.get('OS_AUTH_URL'),
50             'user': os.environ.get('OS_USERNAME'),
51             'password': os.environ.get('OS_PASSWORD'),
52             'project': os.environ.get('OS_TENANT_NAME')
53         }
54         heat_template_parameters = {
55             'default_net': self.options['default_net_name'],
56             'default_subnet': self.options['default_subnet_name'],
57             'source_net': self.options['vlan_net_1_name'],
58             'source_subnet': self.options['vlan_subnet_1_name'],
59             'destination_net': self.options['vlan_net_2_name'],
60             'destination_subnet': self.options['vlan_subnet_2_name']
61         }
62         deployment_configuration = {
63             'vnic_type': [self.options['vnic_type']],
64             'vtc_flavor': [self.options['vtc_flavor']]
65         }
66
67         test_case = dict()
68         test_case['name'] = 'multi_tenancy_throughput_benchmark.' \
69                             'MultiTenancyThroughputBenchmark'
70         test_case['params'] = dict()
71         test_case['params']['packet_size'] = str(self.options['packet_size'])
72         test_case['params']['vlan_sender'] = str(self.options['vlan_sender'])
73         test_case['params']['vlan_receiver'] = \
74             str(self.options['vlan_receiver'])
75         test_case['params']['num_of_neighbours'] = \
76             str(self.options['num_of_neighbours'])
77         test_case['params']['amount_of_ram'] = \
78             str(self.options['amount_of_ram'])
79         test_case['params']['number_of_cores'] = \
80             str(self.options['number_of_cores'])
81         test_case['params']['network'] = \
82             str(self.options['default_net_name'])
83         test_case['params']['subnet'] = \
84             str(self.options['default_subnet_name'])
85
86         res = dict()
87         try:
88             res = api.FrameworkApi.execute_framework(
89                 [test_case],
90                 iterations,
91                 heat_template,
92                 heat_template_parameters,
93                 deployment_configuration,
94                 openstack_credentials)
95         except Exception:
96             LOG.exception('Exception')
97         LOG.info('Got output: %s', res)
98         result.update(res)