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
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
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
31 # pytestmark = pytest.mark.usefixtures("mappers")
\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
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
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
60 host2 = stxSaClientImp.getPserver(host1.id)
\r
61 assert host1 != host2
\r
62 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
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
82 cpulist = stxSaClientImp.getCpuList(hostid=hostlist[0].id)
\r
83 assert len(cpulist) > 0
\r
85 cpu2 = stxSaClientImp.getCpu(cpu1.id)
\r
87 assert cpu1.id == cpu2.id
\r