Merge "Change PTL informatin in INFO"
[bottlenecks.git] / testsuites / vstf / vstf_scripts / vstf / controller / unittest / test_collect.py
1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd 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 unittest
11 import json
12
13 from vstf.controller.env_build import env_collect
14 from vstf.controller.unittest import model
15
16
17 class TestCollect(model.Test):
18
19     def setUp(self):
20         super(TestCollect, self).setUp()
21         self.obj = env_collect.EnvCollectApi(self.conn)
22
23     def test_collect_host_info(self):
24         ret_str = json.dumps(
25             self.obj.collect_host_info(
26                 self.tester_host), indent=4)
27         for key in ("CPU INFO", "MEMORY INFO", "HW_INFO", "OS INFO"):
28             self.assertTrue(
29                 key in ret_str,
30                 "collect_host_info failed, ret_str = %s" %
31                 ret_str)
32
33     def test_list_nic_devices(self):
34         ret_str = json.dumps(
35             self.obj.list_nic_devices(
36                 self.tester_host), indent=4)
37         for key in ("device", "mac", "bdf", "desc"):
38             self.assertTrue(
39                 key in ret_str,
40                 "list_nic_devices failed, ret_str = %s" %
41                 ret_str)
42         print ret_str
43
44     def test_get_device_detail(self):
45         identity = "01:00.0"
46         ret = self.obj.get_device_detail(self.tester_host, "01:00.0")
47         for key in ("device", "mac", "bdf", "desc"):
48             self.assertTrue(key in ret)
49         self.assertTrue(ret['bdf'] == identity)
50
51
52 if __name__ == "__main__":
53     import logging
54     logging.basicConfig(level=logging.INFO)
55     unittest.main()