Merge "Bugfix: task_id parameter from API can not pass to yardstick core"
[yardstick.git] / yardstick / benchmark / scenarios / networking / vtc_instantiation_validation_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 VtcInstantiationValidationNoisy(base.Scenario):
21     """Execute Instantiation Validation TC on the vTC
22     """
23     __scenario_type__ = "vtc_instantiation_validation_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'] = 'instantiation_validation_noisy_neighbors_' \
69                             'benchmark.' \
70                             'InstantiationValidationNoisyNeighborsBenchmark'
71         test_case['params'] = dict()
72         test_case['params']['throughput'] = '1'
73         test_case['params']['vlan_sender'] = str(self.options['vlan_sender'])
74         test_case['params']['vlan_receiver'] = \
75             str(self.options['vlan_receiver'])
76         test_case['params']['num_of_neighbours'] = \
77             str(self.options['num_of_neighbours'])
78         test_case['params']['amount_of_ram'] = \
79             str(self.options['amount_of_ram'])
80         test_case['params']['number_of_cores'] = \
81             str(self.options['number_of_cores'])
82         test_case['params']['network'] = \
83             str(self.options['default_net_name'])
84         test_case['params']['subnet'] = \
85             str(self.options['default_subnet_name'])
86
87         res = dict()
88         try:
89             res = api.FrameworkApi.execute_framework(
90                 [test_case],
91                 iterations,
92                 heat_template,
93                 heat_template_parameters,
94                 deployment_configuration,
95                 openstack_credentials)
96         except Exception:
97             LOG.exception('Exception')
98         LOG.info('Got output: %s', res)
99         result.update(res)