rubbos installation guide
[bottlenecks.git] / vstf / vstf / agent / unittest / perf / test_vstfperf.py
1 """
2 Created on 2015-9-28
3
4 @author: y00228926
5 """
6 import unittest
7
8 from vstf.agent.perf.vstfperf import Vstfperf
9 from vstf.agent.unittest.perf import model
10
11
12 class Test(model.Model):
13     def setUp(self):
14         super(Test, self).setUp()
15         
16         for ns, dev, ip_setting in zip(self.ns_list, self.device_list, self.ip_setting_list):
17             net_dev = {
18                   "namespace":ns,
19                   "iface":dev,
20                   'ip_setting':ip_setting
21             }
22             self.mgr.config_dev(net_dev)
23             
24         self.start = {
25             "operation": "start",
26             "action": "send",
27             "tool": "netperf",
28             "params":{
29                 "namespace": self.ns_list[0],
30                 "protocol": "tcp_lat",
31                 "dst":[
32                         {"ip": self.ip_list[1]}
33                     ],
34                 "size": 64,
35                 "threads": 1,
36                 "time": 1,  
37             },
38         }
39         self.stop = {
40             "operation": "stop",
41             "action": "send",
42             "tool": "netperf",
43             "params":{
44                 "namespace": self.ns_list[1],
45             },
46         }
47         
48     def tearDown(self):
49         super(Test, self).tearDown()
50
51     def testNetperf(self):
52         perf = Vstfperf()
53         self.start['tool'] = 'netperf'
54         self.stop['tool'] = 'netperf'
55         self.start['action'] = 'receive'
56         self.start['operation'] = 'start'
57         self.start['params']['namespace'] = self.ns_list[1]
58         self.start['params']['protocol'] = 'udp_bw'
59         perf.run(**self.start)
60         self.start['action'] = 'send'
61         self.start['operation'] = 'start'
62         self.start['params']['namespace'] = self.ns_list[0]
63         perf.run(**self.start)
64         self.stop['action'] = 'send'
65         self.stop['operation'] = 'stop'
66         self.stop['params']['namespace'] = self.ns_list[0]
67         perf.run(**self.stop)
68         self.stop['action'] = 'receive'
69         self.stop['operation'] = 'stop'
70         self.stop['params']['namespace'] = self.ns_list[1]
71         perf.run(**self.stop)
72         
73     def testQperf(self):
74         perf = Vstfperf()
75         self.start['tool'] = 'qperf'
76         self.stop['tool'] = 'qperf'
77         self.start['action'] = 'receive'
78         self.start['operation'] = 'start'
79         self.start['params']['namespace'] = self.ns_list[1]
80         perf.run(**self.start)
81         self.start['action'] = 'send'
82         self.start['operation'] = 'start'
83         self.start['params']['namespace'] = self.ns_list[0]
84         perf.run(**self.start)
85         self.stop['action'] = 'send'
86         self.stop['operation'] = 'stop'
87         self.stop['params']['namespace'] = self.ns_list[0]
88         perf.run(**self.stop)
89         self.stop['action'] = 'receive'
90         self.stop['operation'] = 'stop'
91         self.stop['params']['namespace'] = self.ns_list[1]
92         perf.run(**self.stop)
93
94
95 if __name__ == "__main__":
96     import logging
97     logging.basicConfig(level = logging.DEBUG)
98     unittest.main()