7ece56b9a6e823e03205c41acfde06890354304a
[pti/o2.git] / tests / integration-ocloud / test_clientdriver_stx_sa.py
1 # Copyright (C) 2021 Wind River Systems, Inc.\r
2 #\r
3 #  Licensed under the Apache License, Version 2.0 (the "License");\r
4 #  you may not use this file except in compliance with the License.\r
5 #  You may obtain a copy of the License at\r
6 #\r
7 #      http://www.apache.org/licenses/LICENSE-2.0\r
8 #\r
9 #  Unless required by applicable law or agreed to in writing, software\r
10 #  distributed under the License is distributed on an "AS IS" BASIS,\r
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 #  See the License for the specific language governing permissions and\r
13 #  limitations under the License.\r
14 \r
15 import sys\r
16 import pytest\r
17 \r
18 from o2common.config import config\r
19 from o2ims.adapter.clients.ocloud_sa_client import StxSaClientImp\r
20 from cgtsclient.client import get_client\r
21 \r
22 import logging\r
23 \r
24 \r
25 @pytest.fixture\r
26 def real_stx_aio_client():\r
27     os_client_args = config.get_stx_access_info()\r
28     config_client = get_client(**os_client_args)\r
29     yield config_client\r
30 \r
31 # pytestmark = pytest.mark.usefixtures("mappers")\r
32 \r
33 \r
34 def test_get_instanceinfo(real_stx_aio_client):\r
35     logger = logging.getLogger(__name__)\r
36     stxclientimp = StxSaClientImp(real_stx_aio_client)\r
37     assert stxclientimp is not None\r
38     systeminfo = stxclientimp.getInstanceInfo()\r
39     assert systeminfo is not None\r
40     assert systeminfo.id is not None\r
41     assert systeminfo.name is not None\r
42     assert systeminfo.content is not None\r
43 \r
44 \r
45 def test_get_pserverlist(real_stx_aio_client):\r
46     stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
47     assert stxSaClientImp is not None\r
48     hosts = stxSaClientImp.getPserverList()\r
49     assert hosts is not None\r
50     assert len(hosts) > 0\r
51 \r
52 \r
53 def test_get_pserver(real_stx_aio_client):\r
54     stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
55     assert stxSaClientImp is not None\r
56     hosts = stxSaClientImp.getPserverList()\r
57     assert hosts is not None\r
58     assert len(hosts) > 0\r
59     host1 = hosts[0]\r
60     host2 = stxSaClientImp.getPserver(host1.id)\r
61     assert host1 != host2\r
62     assert host1.id == host2.id\r
63 \r
64 def test_get_k8s_list(real_stx_aio_client):\r
65     stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
66     assert stxSaClientImp is not None\r
67     k8slist = stxSaClientImp.getK8sList()\r
68     assert k8slist is not None\r
69     assert len(k8slist) > 0\r
70     k8s1 = k8slist[0]\r
71     k8s2 = stxSaClientImp.getK8sDetail(k8s1.name)\r
72     assert k8s1 != k8s2\r
73     assert k8s1.name == k8s2.name\r
74     assert k8s1.id == k8s2.id\r
75 \r
76 def test_get_cpu_list(real_stx_aio_client):\r
77     stxSaClientImp = StxSaClientImp(real_stx_aio_client)\r
78     assert stxSaClientImp is not None\r
79     hostlist = stxSaClientImp.getPserverList()\r
80     assert len(hostlist) > 0\r
81 \r
82     cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)\r
83     assert len(cpulist) > 0\r
84     cpu1 = cpulist[0]\r
85     cpu2 = stxSaClientImp.getCpu(cpu1.id)\r
86     assert cpu1 != cpu2\r
87     assert cpu1.id == cpu2.id\r