8d9bf096258d39b1d2e0dd1361fd025159b391b0
[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 import logging
11 import os
12
13 from yardstick.benchmark.scenarios import base
14 import experimental_framework.api as api
15
16 LOG = logging.getLogger(__name__)
17
18
19 class VtcInstantiationValidationNoisy(base.Scenario):
20     """Execute Instantiation Validation TC on the vTC
21     """
22     __scenario_type__ = "vtc_instantiation_validation_noisy"
23
24     def __init__(self, scenario_cfg, context_cfg):
25         self.scenario_cfg = scenario_cfg
26         self.context_cfg = context_cfg
27         self.options = None
28         self.setup_done = False
29
30     def setup(self):
31         '''scenario setup'''
32
33         self.options = self.scenario_cfg['options']
34         self.setup_done = True
35
36     def run(self, result):
37         """execute test"""
38
39         if not self.setup_done:
40             self.setup()
41
42         heat_template = 'vTC.yaml'
43         iterations = 1
44
45         openstack_credentials = {
46             'ip_controller': '0.0.0.0',
47             'heat_url': '***',
48             'auth_uri': os.environ.get('OS_AUTH_URL'),
49             'user': os.environ.get('OS_USERNAME'),
50             'password': os.environ.get('OS_PASSWORD'),
51             'project': os.environ.get('OS_TENANT_NAME')
52         }
53         heat_template_parameters = {
54             'default_net': self.options['default_net_name'],
55             'default_subnet': self.options['default_subnet_name'],
56             'source_net': self.options['vlan_net_1_name'],
57             'source_subnet': self.options['vlan_subnet_1_name'],
58             'destination_net': self.options['vlan_net_2_name'],
59             'destination_subnet': self.options['vlan_subnet_2_name']
60         }
61         deployment_configuration = {
62             'vnic_type': [self.options['vnic_type']],
63             'vtc_flavor': [self.options['vtc_flavor']]
64         }
65
66         test_case = dict()
67         test_case['name'] = 'instantiation_validation_noisy_neighbors_' \
68                             'benchmark.' \
69                             'InstantiationValidationNoisyNeighborsBenchmark'
70         test_case['params'] = dict()
71         test_case['params']['throughput'] = '1'
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 as e:
96             LOG.info('Exception: {}'.format(e.message))
97         LOG.info('Got output: {}'.format(res))
98         result.update(res)