rubbos installation guide
[bottlenecks.git] / vstf / vstf / agent / unittest / test_callback.py
1 """
2 Created on 2015-9-28
3
4 @author: y00228926
5 """
6 import unittest
7
8 from vstf.agent.unittest.perf import model
9 from vstf.agent import softagent
10
11
12 class TestCallback(model.Model):
13     def setUp(self):
14         super(TestCallback, self).setUp()
15         self.agent = softagent.softAgent()
16         for ns, dev, ip_setting in zip(self.ns_list, self.device_list, self.ip_setting_list):
17             netdev = {
18                 "namespace": ns,
19                 "iface": dev,
20                 'ip_setting': ip_setting
21             }
22             self.mgr.config_dev(netdev)
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(TestCallback, self).tearDown()
50
51     def test_clean(self):
52         agent = self.agent
53         agent.perf_clean()
54         self.start['tool'] = 'netperf'
55         self.stop['tool'] = 'netperf'
56         self.start['action'] = 'receive'
57         self.start['operation'] = 'start'
58         self.start['params']['namespace'] = self.ns_list[1]
59         self.start['params']['protocol'] = 'udp_bw'
60         agent.perf_run(**self.start)
61         self.start['action'] = 'send'
62         self.start['operation'] = 'start'
63         self.start['params']['namespace'] = self.ns_list[0]
64         agent.perf_run(**self.start)
65         agent.perf_clean()
66
67
68 if __name__ == "__main__":
69     import logging
70
71     logging.getLogger(__name__)
72     logging.basicConfig(level=logging.DEBUG)
73     # import sys;sys.argv = ['', 'Test.testName']
74     unittest.main()
75
76 if __name__ == "__main__":
77     import logging
78
79     logging.basicConfig(level=logging.DEBUG)
80     unittest.main()