1 # Copyright (C) 2021 Wind River Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 from o2common.config import config
20 from o2ims.adapter.clients.ocloud_sa_client import StxSaClientImp
21 from cgtsclient.client import get_client
25 def real_stx_aio_client():
26 os_client_args = config.get_stx_access_info()
27 config_client = get_client(**os_client_args)
30 # pytestmark = pytest.mark.usefixtures("mappers")
33 def test_get_instanceinfo(real_stx_aio_client):
34 # logger = logging.getLogger(__name__)
35 stxclientimp = StxSaClientImp(real_stx_aio_client)
36 assert stxclientimp is not None
37 systeminfo = stxclientimp.getInstanceInfo()
38 assert systeminfo is not None
39 assert systeminfo.id is not None
40 assert systeminfo.name is not None
41 assert systeminfo.content is not None
44 def test_get_pserverlist(real_stx_aio_client):
45 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
46 assert stxSaClientImp is not None
47 hosts = stxSaClientImp.getPserverList()
48 assert hosts is not None
52 def test_get_pserver(real_stx_aio_client):
53 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
54 assert stxSaClientImp is not None
55 hosts = stxSaClientImp.getPserverList()
56 assert hosts is not None
59 host2 = stxSaClientImp.getPserver(host1.id)
61 assert host1.id == host2.id
64 def test_get_k8s_list(real_stx_aio_client):
65 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
66 assert stxSaClientImp is not None
67 k8slist = stxSaClientImp.getK8sList()
68 assert k8slist is not None
69 assert len(k8slist) > 0
71 k8s2 = stxSaClientImp.getK8sDetail(k8s1.name)
73 assert k8s1.name == k8s2.name
74 assert k8s1.id == k8s2.id
77 def test_get_cpu_list(real_stx_aio_client):
78 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
79 assert stxSaClientImp is not None
80 hostlist = stxSaClientImp.getPserverList()
81 assert len(hostlist) > 0
83 cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)
84 assert len(cpulist) > 0
86 cpu2 = stxSaClientImp.getCpu(cpu1.id)
88 assert cpu1.id == cpu2.id
91 def test_get_mem_list(real_stx_aio_client):
92 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
93 assert stxSaClientImp is not None
94 hostlist = stxSaClientImp.getPserverList()
95 assert len(hostlist) > 0
97 memlist = stxSaClientImp.getMemList(hostid=hostlist[0].id)
98 assert len(memlist) > 0
100 mem2 = stxSaClientImp.getMem(mem1.id)
102 assert mem1.id == mem2.id
105 def test_get_eth_list(real_stx_aio_client):
106 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
107 assert stxSaClientImp is not None
108 hostlist = stxSaClientImp.getPserverList()
109 assert len(hostlist) > 0
111 ethlist = stxSaClientImp.getEthernetList(hostid=hostlist[0].id)
112 assert len(ethlist) > 0
114 eth2 = stxSaClientImp.getEthernet(eth1.id)
116 assert eth1.id == eth2.id
119 def test_get_if_list(real_stx_aio_client):
120 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
121 assert stxSaClientImp is not None
122 hostlist = stxSaClientImp.getPserverList()
123 assert len(hostlist) > 0
125 iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)
126 assert len(iflist) > 0
128 if2 = stxSaClientImp.getIf(if1.id)
130 assert if1.id == if2.id
133 def test_get_if_port_list(real_stx_aio_client):
134 stxSaClientImp = StxSaClientImp(real_stx_aio_client)
135 assert stxSaClientImp is not None
136 hostlist = stxSaClientImp.getPserverList()
137 assert len(hostlist) > 0
139 iflist = stxSaClientImp.getIfList(hostid=hostlist[0].id)
140 assert len(iflist) > 0
142 portlist = stxSaClientImp.getPortList(interfaceid=iflist[0].id)
143 assert len(portlist) > 0
145 port2 = stxSaClientImp.getPort(port1.id)
146 assert port1 != port2
147 assert port1.id == port2.id