1 # Copyright (C) 2021 Wind River Systems, Inc.
\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
7 # http://www.apache.org/licenses/LICENSE-2.0
\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
19 from o2common.config import config
\r
20 from o2ims.adapter.clients.ocloud_sa_client import StxSaClientImp
\r
21 from cgtsclient.client import get_client
\r
25 def real_stx_aio_client():
\r
26 os_client_args = config.get_stx_access_info()
\r
27 config_client = get_client(**os_client_args)
\r
30 # pytestmark = pytest.mark.usefixtures("mappers")
\r
33 def test_get_instanceinfo(real_stx_aio_client):
\r
34 # logger = logging.getLogger(__name__)
\r
35 stxclientimp = StxSaClientImp(real_stx_aio_client)
\r
36 assert stxclientimp is not None
\r
37 systeminfo = stxclientimp.getInstanceInfo()
\r
38 assert systeminfo is not None
\r
39 assert systeminfo.id is not None
\r
40 assert systeminfo.name is not None
\r
41 assert systeminfo.content is not None
\r
44 def test_get_pserverlist(real_stx_aio_client):
\r
45 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
\r
46 assert stxSaClientImp is not None
\r
47 hosts = stxSaClientImp.getPserverList()
\r
48 assert hosts is not None
\r
49 assert len(hosts) > 0
\r
52 def test_get_pserver(real_stx_aio_client):
\r
53 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
\r
54 assert stxSaClientImp is not None
\r
55 hosts = stxSaClientImp.getPserverList()
\r
56 assert hosts is not None
\r
57 assert len(hosts) > 0
\r
59 host2 = stxSaClientImp.getPserver(host1.id)
\r
60 assert host1 != host2
\r
61 assert host1.id == host2.id
\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
71 k8s2 = stxSaClientImp.getK8sDetail(k8s1.name)
\r
73 assert k8s1.name == k8s2.name
\r
74 assert k8s1.id == k8s2.id
\r
77 def test_get_cpu_list(real_stx_aio_client):
\r
78 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
\r
79 assert stxSaClientImp is not None
\r
80 hostlist = stxSaClientImp.getPserverList()
\r
81 assert len(hostlist) > 0
\r
83 cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)
\r
84 assert len(cpulist) > 0
\r
86 cpu2 = stxSaClientImp.getCpu(cpu1.id)
\r
88 assert cpu1.id == cpu2.id
\r
91 def test_get_mem_list(real_stx_aio_client):
\r
92 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
\r
93 assert stxSaClientImp is not None
\r
94 hostlist = stxSaClientImp.getPserverList()
\r
95 assert len(hostlist) > 0
\r
97 memlist = stxSaClientImp.getMemList(hostid=hostlist[0].id)
\r
98 assert len(memlist) > 0
\r
100 mem2 = stxSaClientImp.getMem(mem1.id)
\r
101 assert mem1 != mem2
\r
102 assert mem1.id == mem2.id
\r
105 def test_get_if_list(real_stx_aio_client):
\r
106 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
\r
107 assert stxSaClientImp is not None
\r
108 hostlist = stxSaClientImp.getPserverList()
\r
109 assert len(hostlist) > 0
\r
111 iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)
\r
112 assert len(iflist) > 0
\r
114 if2 = stxSaClientImp.getIf(if1.id)
\r
116 assert if1.id == if2.id
\r
119 def test_get_port_list(real_stx_aio_client):
\r
120 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
\r
121 assert stxSaClientImp is not None
\r
122 hostlist = stxSaClientImp.getPserverList()
\r
123 assert len(hostlist) > 0
\r
125 portlist = stxSaClientImp.getPortList(hostid=hostlist[0].id)
\r
126 assert len(portlist) > 0
\r
127 port1 = portlist[0]
\r
128 port2 = stxSaClientImp.getPort(port1.id)
\r
129 assert port1 != port2
\r
130 assert port1.id == port2.id
\r