Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zmops-test
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sanshi
zmops-test
Commits
644de9d1
Commit
644de9d1
authored
Nov 29, 2019
by
sanshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化主机接口模块用例
parent
df81db82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
249 additions
and
32 deletions
+249
-32
test_hostinterface_create.py
WorkCase/API/HostInterface/test_hostinterface_create.py
+8
-1
test_hostinterface_delete.py
WorkCase/API/HostInterface/test_hostinterface_delete.py
+76
-6
test_hostinterface_get.py
WorkCase/API/HostInterface/test_hostinterface_get.py
+76
-6
test_hostinterface_update.py
WorkCase/API/HostInterface/test_hostinterface_update.py
+89
-19
No files found.
WorkCase/API/HostInterface/test_hostinterface_create.py
View file @
644de9d1
...
@@ -33,6 +33,7 @@ class TestHostInterfaceCreate(object):
...
@@ -33,6 +33,7 @@ class TestHostInterfaceCreate(object):
base_host_name
=
"SS TEST HOST"
base_host_name
=
"SS TEST HOST"
base_description
=
"SS TEST HOST-interface"
base_description
=
"SS TEST HOST-interface"
base_groupid
=
101
base_name
=
"SS测试主机接口"
base_name
=
"SS测试主机接口"
base_ip
=
"10.0.0.28"
base_ip
=
"10.0.0.28"
...
@@ -172,8 +173,14 @@ class TestHostInterfaceCreate(object):
...
@@ -172,8 +173,14 @@ class TestHostInterfaceCreate(object):
}])
}])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
delete_interfaces
()
return
self
.
hostid
return
self
.
hostid
@allure.step
(
"删除所有已存在的接口"
)
def
delete_interfaces
(
self
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
self
.
db_url
,
db_port
=
self
.
db_port
,
db_base
=
self
.
db_base
,
db_user
=
self
.
db_user
,
db_pw
=
self
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
self
.
hostid
)
@allure.title
(
"hostinterface.create:IP地址相应信息"
)
@allure.title
(
"hostinterface.create:IP地址相应信息"
)
@allure.story
(
"创建主机接口:IP地址相应信息"
)
@allure.story
(
"创建主机接口:IP地址相应信息"
)
@allure.severity
(
"blocker"
)
@allure.severity
(
"blocker"
)
...
@@ -226,7 +233,7 @@ class TestHostInterfaceCreate(object):
...
@@ -226,7 +233,7 @@ class TestHostInterfaceCreate(object):
self
.
case_create
(
num
=
"05"
)
self
.
case_create
(
num
=
"05"
)
response
=
self
.
hostinterface_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
1
,
bulk
=
1
)
self
.
check_code
(
response
=
response
,
code
=
100
)
self
.
check_code
(
response
=
response
,
code
=
100
)
self
.
check_msg
(
response
=
response
,
msg
=
"主机
11
的类型[Unknown interface type]没有默认接口"
)
self
.
check_msg
(
response
=
response
,
msg
=
"主机
SS TEST HOST05
的类型[Unknown interface type]没有默认接口"
)
@allure.title
(
"hostinterface.create:useip=0, bulk=1"
)
@allure.title
(
"hostinterface.create:useip=0, bulk=1"
)
@allure.story
(
"创建主机接口:useip=0, bulk=1"
)
@allure.story
(
"创建主机接口:useip=0, bulk=1"
)
...
...
WorkCase/API/HostInterface/test_hostinterface_delete.py
View file @
644de9d1
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
from
__future__
import
division
from
__future__
import
division
from
WorkApi.API.Host.host_create
import
HostCreate
from
WorkCase
import
CaseBase
from
WorkCase
import
CaseBase
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
...
@@ -14,6 +15,8 @@ from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
...
@@ -14,6 +15,8 @@ from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
from
WorkApi.API.HostInterface.hostInterface_delete
import
HostInterfaceDelete
from
WorkApi.API.HostInterface.hostInterface_delete
import
HostInterfaceDelete
from
WorkData.Zabbix.interface
import
DataInterface
from
WorkData.Zabbix.interface
import
DataInterface
from
WorkData.Zabbix.hosts
import
DataHosts
from
WorkData.Zabbix.items
import
DataItems
import
allure
import
allure
...
@@ -36,6 +39,10 @@ class TestHostInterfaceDelete(object):
...
@@ -36,6 +39,10 @@ class TestHostInterfaceDelete(object):
base_dns
=
"sanshi.zmops.cn"
base_dns
=
"sanshi.zmops.cn"
base_port
=
"127"
base_port
=
"127"
base_host_name
=
"SS TEST HOST"
base_description
=
"SS TEST HOST-interface"
base_groupid
=
101
new_ip
=
"192.168.1.28"
new_ip
=
"192.168.1.28"
new_port
=
"721"
new_port
=
"721"
...
@@ -43,7 +50,14 @@ class TestHostInterfaceDelete(object):
...
@@ -43,7 +50,14 @@ class TestHostInterfaceDelete(object):
def
setup_class
(
cls
):
def
setup_class
(
cls
):
cls
.
log
.
debug
(
"开始执行测试套件......."
)
cls
.
log
.
debug
(
"开始执行测试套件......."
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
cls
.
base_hostid
)
sql
=
DataHosts
()
.
select_like_name
(
session
=
session
,
name
=
cls
.
base_host_name
)
for
x
,
y
in
enumerate
(
sql
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataItems
()
.
delete_hostid
(
session
=
session
,
hostid
=
y
.
hostid
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataHosts
()
.
delete_like_name
(
session
=
session
,
name
=
cls
.
base_host_name
)
@classmethod
@classmethod
def
teardown_class
(
cls
):
def
teardown_class
(
cls
):
...
@@ -124,11 +138,65 @@ class TestHostInterfaceDelete(object):
...
@@ -124,11 +138,65 @@ class TestHostInterfaceDelete(object):
_status
=
UtilsResponse
()
.
get_status
(
response
=
response
)
_status
=
UtilsResponse
()
.
get_status
(
response
=
response
)
assert
_status
==
status
assert
_status
==
status
@allure.step
(
"调用接口:host.create"
)
def
host_create
(
self
,
host
=
None
,
name
=
None
,
description
=
None
,
groupids
=
None
,
interfaces
=
None
,
tags
=
None
,
templateids
=
None
,
macros
=
None
,
inventory
=
None
,
status
=
None
,
inventory_mode
=
None
):
api
=
HostCreate
(
_host
=
self
.
host
)
api
.
host
=
host
api
.
name
=
name
api
.
description
=
description
api
.
groupids
=
groupids
api
.
interfaces
=
interfaces
api
.
tags
=
tags
api
.
templateids
=
templateids
api
.
macros
=
macros
api
.
inventory
=
inventory
api
.
status
=
status
api
.
inventory_mode
=
inventory_mode
api
.
tls_connect
=
1
api
.
tls_accept
=
1
api
.
tls_psk_identity
=
"Test"
api
.
tls_psk
=
"Test"
api
.
get_response
()
return
api
.
response
@allure.step
(
"创建测试数据"
)
def
case_host_create
(
self
,
num
):
templateid
=
10001
host
=
self
.
base_host_name
+
num
description
=
self
.
base_description
+
num
interfaces
=
{
"type"
:
2
,
"main"
:
1
,
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_groupid
],
interfaces
=
[
interfaces
],
status
=
0
,
templateids
=
[
templateid
],
macros
=
[{
"macro"
:
"{$SNMP_COMMUNITY}"
,
"value"
:
"public"
}])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
delete_interfaces
()
return
self
.
hostid
@allure.step
(
"删除所有已存在的接口"
)
def
delete_interfaces
(
self
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
self
.
db_url
,
db_port
=
self
.
db_port
,
db_base
=
self
.
db_base
,
db_user
=
self
.
db_user
,
db_pw
=
self
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
self
.
hostid
)
@allure.title
(
"hostinterface.delete:删除的ID存在"
)
@allure.title
(
"hostinterface.delete:删除的ID存在"
)
@allure.story
(
"删除主机接口:删除的ID存在"
)
@allure.story
(
"删除主机接口:删除的ID存在"
)
@allure.severity
(
"blocker"
)
@allure.severity
(
"blocker"
)
def
test_case_01
(
self
):
def
test_case_01
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"01"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_delete
(
interfaceids
=
[
interfaceid
])
response
=
self
.
hostinterface_delete
(
interfaceids
=
[
interfaceid
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
...
@@ -137,7 +205,8 @@ class TestHostInterfaceDelete(object):
...
@@ -137,7 +205,8 @@ class TestHostInterfaceDelete(object):
@allure.title
(
"hostinterface.delete:删除的ID不存在 500"
)
@allure.title
(
"hostinterface.delete:删除的ID不存在 500"
)
@allure.story
(
"删除主机接口:删除的ID不存在 500"
)
@allure.story
(
"删除主机接口:删除的ID不存在 500"
)
def
test_case_02
(
self
):
def
test_case_02
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"02"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_delete
(
interfaceids
=
[
interfaceid
])
response
=
self
.
hostinterface_delete
(
interfaceids
=
[
interfaceid
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
...
@@ -149,9 +218,10 @@ class TestHostInterfaceDelete(object):
...
@@ -149,9 +218,10 @@ class TestHostInterfaceDelete(object):
@allure.title
(
"hostinterface.delete:删除多个ID"
)
@allure.title
(
"hostinterface.delete:删除多个ID"
)
@allure.story
(
"删除主机接口:删除多个ID"
)
@allure.story
(
"删除主机接口:删除多个ID"
)
def
test_case_03
(
self
):
def
test_case_03
(
self
):
interfaceid_1
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"03"
)
interfaceid_2
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
interfaceid_1
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
interfaceid_3
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
interfaceid_2
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
interfaceid_3
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_delete
(
interfaceids
=
[
interfaceid_1
,
interfaceid_2
,
interfaceid_3
])
response
=
self
.
hostinterface_delete
(
interfaceids
=
[
interfaceid_1
,
interfaceid_2
,
interfaceid_3
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
...
...
WorkCase/API/HostInterface/test_hostinterface_get.py
View file @
644de9d1
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
from
__future__
import
division
from
__future__
import
division
from
WorkApi.API.Host.host_create
import
HostCreate
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
from
WorkUtils.UtilsResponse
import
UtilsResponse
from
WorkUtils.UtilsResponse
import
UtilsResponse
...
@@ -12,13 +14,13 @@ from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
...
@@ -12,13 +14,13 @@ from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
from
WorkApi.API.HostInterface.hostInterface_get
import
HostInterfaceGet
from
WorkApi.API.HostInterface.hostInterface_get
import
HostInterfaceGet
from
WorkData.Zabbix.interface
import
DataInterface
from
WorkData.Zabbix.interface
import
DataInterface
from
WorkData.Zabbix.hosts
import
DataHosts
from
WorkData.Zabbix.items
import
DataItems
from
WorkCase
import
CaseBase
from
WorkCase
import
CaseBase
import
allure
import
allure
# allure.label("")
@allure.feature
(
"测试模块:hostinterface.get"
)
@allure.feature
(
"测试模块:hostinterface.get"
)
class
TestHostInterfaceGet
(
object
):
class
TestHostInterfaceGet
(
object
):
...
@@ -36,11 +38,22 @@ class TestHostInterfaceGet(object):
...
@@ -36,11 +38,22 @@ class TestHostInterfaceGet(object):
base_dns
=
"sanshi.zmops.cn"
base_dns
=
"sanshi.zmops.cn"
base_port
=
"127"
base_port
=
"127"
base_host_name
=
"SS TEST HOST"
base_description
=
"SS TEST HOST-interface"
base_groupid
=
101
@classmethod
@classmethod
def
setup_class
(
cls
):
def
setup_class
(
cls
):
cls
.
log
.
debug
(
"开始执行测试套件......."
)
cls
.
log
.
debug
(
"开始执行测试套件......."
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
cls
.
base_hostid
)
sql
=
DataHosts
()
.
select_like_name
(
session
=
session
,
name
=
cls
.
base_host_name
)
for
x
,
y
in
enumerate
(
sql
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataItems
()
.
delete_hostid
(
session
=
session
,
hostid
=
y
.
hostid
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataHosts
()
.
delete_like_name
(
session
=
session
,
name
=
cls
.
base_host_name
)
@classmethod
@classmethod
def
teardown_class
(
cls
):
def
teardown_class
(
cls
):
...
@@ -149,6 +162,59 @@ class TestHostInterfaceGet(object):
...
@@ -149,6 +162,59 @@ class TestHostInterfaceGet(object):
assert
y
[
"useip"
]
in
UtilsResponse
()
.
get_values_from_sql
(
_sql
=
sql
,
key
=
"useip"
)
assert
y
[
"useip"
]
in
UtilsResponse
()
.
get_values_from_sql
(
_sql
=
sql
,
key
=
"useip"
)
assert
y
[
"bulk"
]
in
UtilsResponse
()
.
get_values_from_sql
(
_sql
=
sql
,
key
=
"bulk"
)
assert
y
[
"bulk"
]
in
UtilsResponse
()
.
get_values_from_sql
(
_sql
=
sql
,
key
=
"bulk"
)
@allure.step
(
"调用接口:host.create"
)
def
host_create
(
self
,
host
=
None
,
name
=
None
,
description
=
None
,
groupids
=
None
,
interfaces
=
None
,
tags
=
None
,
templateids
=
None
,
macros
=
None
,
inventory
=
None
,
status
=
None
,
inventory_mode
=
None
):
api
=
HostCreate
(
_host
=
self
.
host
)
api
.
host
=
host
api
.
name
=
name
api
.
description
=
description
api
.
groupids
=
groupids
api
.
interfaces
=
interfaces
api
.
tags
=
tags
api
.
templateids
=
templateids
api
.
macros
=
macros
api
.
inventory
=
inventory
api
.
status
=
status
api
.
inventory_mode
=
inventory_mode
api
.
tls_connect
=
1
api
.
tls_accept
=
1
api
.
tls_psk_identity
=
"Test"
api
.
tls_psk
=
"Test"
api
.
get_response
()
return
api
.
response
@allure.step
(
"创建测试数据"
)
def
case_host_create
(
self
,
num
):
templateid
=
10001
host
=
self
.
base_host_name
+
num
description
=
self
.
base_description
+
num
interfaces
=
{
"type"
:
2
,
"main"
:
1
,
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_groupid
],
interfaces
=
[
interfaces
],
status
=
0
,
templateids
=
[
templateid
],
macros
=
[{
"macro"
:
"{$SNMP_COMMUNITY}"
,
"value"
:
"public"
}])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
delete_interfaces
()
return
self
.
hostid
@allure.step
(
"删除所有已存在的接口"
)
def
delete_interfaces
(
self
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
self
.
db_url
,
db_port
=
self
.
db_port
,
db_base
=
self
.
db_base
,
db_user
=
self
.
db_user
,
db_pw
=
self
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
self
.
hostid
)
@allure.title
(
"hostinterface.get:无参数调用"
)
@allure.title
(
"hostinterface.get:无参数调用"
)
@allure.story
(
"查询主机接口:无参数调用"
)
@allure.story
(
"查询主机接口:无参数调用"
)
@allure.severity
(
"blocker"
)
@allure.severity
(
"blocker"
)
...
@@ -165,19 +231,22 @@ class TestHostInterfaceGet(object):
...
@@ -165,19 +231,22 @@ class TestHostInterfaceGet(object):
@allure.title
(
"hostinterface.get:hostids=特定IDs"
)
@allure.title
(
"hostinterface.get:hostids=特定IDs"
)
@allure.story
(
"查询主机接口:hostids=特定IDs"
)
@allure.story
(
"查询主机接口:hostids=特定IDs"
)
def
test_case_03
(
self
):
def
test_case_03
(
self
):
response
=
self
.
hostinterface_get
(
hostids
=
[
self
.
base_hostid
])
self
.
case_host_create
(
num
=
"03"
)
response
=
self
.
hostinterface_get
(
hostids
=
[
self
.
hostid
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
@allure.title
(
"hostinterface.get:output=[ip]"
)
@allure.title
(
"hostinterface.get:output=[ip]"
)
@allure.story
(
"查询主机接口:output=[ip]"
)
@allure.story
(
"查询主机接口:output=[ip]"
)
def
test_case_04
(
self
):
def
test_case_04
(
self
):
self
.
case_host_create
(
num
=
"04"
)
response
=
self
.
hostinterface_get
(
output
=
[
"ip"
])
response
=
self
.
hostinterface_get
(
output
=
[
"ip"
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
@allure.title
(
"hostinterface.get:interfaceids=特定IDs, output=[ip, port, type, main, useip, bulk]"
)
@allure.title
(
"hostinterface.get:interfaceids=特定IDs, output=[ip, port, type, main, useip, bulk]"
)
@allure.story
(
"查询主机接口:interfaceids=特定IDs, output=[ip, port, type, main, useip, bulk]"
)
@allure.story
(
"查询主机接口:interfaceids=特定IDs, output=[ip, port, type, main, useip, bulk]"
)
def
test_case_05
(
self
):
def
test_case_05
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"05"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_get
(
interfaceids
=
[
interfaceid
],
output
=
[
"ip"
,
"port"
,
"type"
,
"main"
,
"useip"
,
"bulk"
])
response
=
self
.
hostinterface_get
(
interfaceids
=
[
interfaceid
],
output
=
[
"ip"
,
"port"
,
"type"
,
"main"
,
"useip"
,
"bulk"
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
...
@@ -186,7 +255,8 @@ class TestHostInterfaceGet(object):
...
@@ -186,7 +255,8 @@ class TestHostInterfaceGet(object):
@allure.title
(
"hostinterface.get:limit=1"
)
@allure.title
(
"hostinterface.get:limit=1"
)
@allure.story
(
"查询主机接口:limit=1"
)
@allure.story
(
"查询主机接口:limit=1"
)
def
test_case_06
(
self
):
def
test_case_06
(
self
):
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"06"
)
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_get
(
limit
=
1
)
response
=
self
.
hostinterface_get
(
limit
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
...
...
WorkCase/API/HostInterface/test_hostinterface_update.py
View file @
644de9d1
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
from
__future__
import
division
from
__future__
import
division
from
WorkApi.API.Host.host_create
import
HostCreate
from
WorkCase
import
CaseBase
from
WorkCase
import
CaseBase
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
...
@@ -14,11 +15,11 @@ from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
...
@@ -14,11 +15,11 @@ from WorkApi.API.HostInterface.hostInterface_create import HostInterfaceCreate
from
WorkApi.API.HostInterface.hostInterface_update
import
HostInterfaceUpdate
from
WorkApi.API.HostInterface.hostInterface_update
import
HostInterfaceUpdate
from
WorkData.Zabbix.interface
import
DataInterface
from
WorkData.Zabbix.interface
import
DataInterface
from
WorkData.Zabbix.items
import
DataItems
from
WorkData.Zabbix.hosts
import
DataHosts
import
allure
import
allure
# allure.label("")
@allure.feature
(
"测试模块:hostinterface.update"
)
@allure.feature
(
"测试模块:hostinterface.update"
)
class
TestHostInterfaceUpdate
(
object
):
class
TestHostInterfaceUpdate
(
object
):
...
@@ -36,6 +37,10 @@ class TestHostInterfaceUpdate(object):
...
@@ -36,6 +37,10 @@ class TestHostInterfaceUpdate(object):
base_dns
=
"sanshi.zmops.cn"
base_dns
=
"sanshi.zmops.cn"
base_port
=
"127"
base_port
=
"127"
base_host_name
=
"SS TEST HOST"
base_description
=
"SS TEST HOST-interface"
base_groupid
=
101
new_ip
=
"192.168.1.28"
new_ip
=
"192.168.1.28"
new_port
=
"721"
new_port
=
"721"
...
@@ -43,7 +48,14 @@ class TestHostInterfaceUpdate(object):
...
@@ -43,7 +48,14 @@ class TestHostInterfaceUpdate(object):
def
setup_class
(
cls
):
def
setup_class
(
cls
):
cls
.
log
.
debug
(
"开始执行测试套件......."
)
cls
.
log
.
debug
(
"开始执行测试套件......."
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
cls
.
base_hostid
)
sql
=
DataHosts
()
.
select_like_name
(
session
=
session
,
name
=
cls
.
base_host_name
)
for
x
,
y
in
enumerate
(
sql
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataItems
()
.
delete_hostid
(
session
=
session
,
hostid
=
y
.
hostid
)
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
cls
.
db_url
,
db_port
=
cls
.
db_port
,
db_base
=
cls
.
db_base
,
db_user
=
cls
.
db_user
,
db_pw
=
cls
.
db_pw
)
DataHosts
()
.
delete_like_name
(
session
=
session
,
name
=
cls
.
base_host_name
)
@classmethod
@classmethod
def
teardown_class
(
cls
):
def
teardown_class
(
cls
):
...
@@ -142,57 +154,115 @@ class TestHostInterfaceUpdate(object):
...
@@ -142,57 +154,115 @@ class TestHostInterfaceUpdate(object):
_status
=
UtilsResponse
()
.
get_status
(
response
=
response
)
_status
=
UtilsResponse
()
.
get_status
(
response
=
response
)
assert
_status
==
status
assert
_status
==
status
@allure.step
(
"调用接口:host.create"
)
def
host_create
(
self
,
host
=
None
,
name
=
None
,
description
=
None
,
groupids
=
None
,
interfaces
=
None
,
tags
=
None
,
templateids
=
None
,
macros
=
None
,
inventory
=
None
,
status
=
None
,
inventory_mode
=
None
):
api
=
HostCreate
(
_host
=
self
.
host
)
api
.
host
=
host
api
.
name
=
name
api
.
description
=
description
api
.
groupids
=
groupids
api
.
interfaces
=
interfaces
api
.
tags
=
tags
api
.
templateids
=
templateids
api
.
macros
=
macros
api
.
inventory
=
inventory
api
.
status
=
status
api
.
inventory_mode
=
inventory_mode
api
.
tls_connect
=
1
api
.
tls_accept
=
1
api
.
tls_psk_identity
=
"Test"
api
.
tls_psk
=
"Test"
api
.
get_response
()
return
api
.
response
@allure.step
(
"创建测试数据"
)
def
case_host_create
(
self
,
num
):
templateid
=
10001
host
=
self
.
base_host_name
+
num
description
=
self
.
base_description
+
num
interfaces
=
{
"type"
:
2
,
"main"
:
1
,
"useip"
:
1
,
"ip"
:
self
.
base_ip
,
"dns"
:
""
,
"port"
:
100
,
"bulk"
:
1
}
response
=
self
.
host_create
(
host
=
host
,
description
=
description
,
groupids
=
[
self
.
base_groupid
],
interfaces
=
[
interfaces
],
status
=
0
,
templateids
=
[
templateid
],
macros
=
[{
"macro"
:
"{$SNMP_COMMUNITY}"
,
"value"
:
"public"
}])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
hostid
=
UtilsResponse
()
.
get_result
(
response
=
response
)[
"hostids"
][
0
]
self
.
delete_interfaces
()
return
self
.
hostid
@allure.step
(
"删除所有已存在的接口"
)
def
delete_interfaces
(
self
):
session
=
UtilsDataBase
()
.
conn_mysql
(
db_url
=
self
.
db_url
,
db_port
=
self
.
db_port
,
db_base
=
self
.
db_base
,
db_user
=
self
.
db_user
,
db_pw
=
self
.
db_pw
)
DataInterface
()
.
delete_hostid
(
session
=
session
,
hostid
=
self
.
hostid
)
@allure.title
(
"hostinterface.update:修改ip, port"
)
@allure.title
(
"hostinterface.update:修改ip, port"
)
@allure.story
(
"更新主机接口:修改ip, port"
)
@allure.story
(
"更新主机接口:修改ip, port"
)
@allure.severity
(
"blocker"
)
@allure.severity
(
"blocker"
)
def
test_case_01
(
self
):
def
test_case_01
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"01"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
1
,
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
useip
=
1
,
bulk
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
1
,
useip
=
1
,
bulk
=
1
)
@allure.title
(
"hostinterface.update:修改dns"
)
@allure.title
(
"hostinterface.update:修改dns"
)
@allure.story
(
"更新主机接口:修改dns"
)
@allure.story
(
"更新主机接口:修改dns"
)
def
test_case_02
(
self
):
def
test_case_02
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"02"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
""
,
dns
=
self
.
base_dns
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
2
,
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
""
,
dns
=
self
.
base_dns
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
useip
=
1
,
bulk
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
""
,
dns
=
self
.
base_dns
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
""
,
dns
=
self
.
base_dns
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
2
,
useip
=
1
,
bulk
=
1
)
@allure.title
(
"hostinterface.update:默认接口无法修改成非默认接口"
)
@allure.title
(
"hostinterface.update:默认接口无法修改成非默认接口"
)
@allure.story
(
"更新主机接口:默认接口无法修改成非默认接口"
)
@allure.story
(
"更新主机接口:默认接口无法修改成非默认接口"
)
def
test_case_03
(
self
):
def
test_case_03
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
3
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"03"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
3
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
0
,
port
=
self
.
new_port
,
_type
=
3
,
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
new_port
,
_type
=
3
,
useip
=
1
,
bulk
=
1
)
useip
=
1
,
bulk
=
1
)
self
.
check_code
(
response
=
response
,
code
=
100
)
self
.
check_code
(
response
=
response
,
code
=
100
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
3
,
useip
=
1
,
bulk
=
1
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
3
,
useip
=
1
,
bulk
=
1
)
@allure.title
(
"hostinterface.update:非默认接口无法修改成默认接口"
)
@allure.title
(
"hostinterface.update:非默认接口无法修改成默认接口"
)
@allure.story
(
"更新主机接口:非默认接口无法修改成默认接口"
)
@allure.story
(
"更新主机接口:非默认接口无法修改成默认接口"
)
def
test_case_04
(
self
):
def
test_case_04
(
self
):
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"04"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
4
,
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
new_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
new_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
useip
=
1
,
bulk
=
1
)
self
.
check_code
(
response
=
response
,
code
=
100
)
self
.
check_code
(
response
=
response
,
code
=
100
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
0
,
port
=
self
.
base_port
,
_type
=
4
,
useip
=
1
,
bulk
=
1
)
@allure.title
(
"hostinterface.update:修改useip, bulk"
)
@allure.title
(
"hostinterface.update:修改useip, bulk"
)
@allure.story
(
"更新主机接口:修改useip, bulk"
)
@allure.story
(
"更新主机接口:修改useip, bulk"
)
def
test_case_05
(
self
):
def
test_case_05
(
self
):
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
1
,
bulk
=
1
)
self
.
case_host_create
(
num
=
"05"
)
interfaceid
=
self
.
case_create
(
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
1
,
bulk
=
1
)
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
5
,
response
=
self
.
hostinterface_update
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
0
,
bulk
=
0
)
useip
=
0
,
bulk
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
base_
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
0
,
bulk
=
0
)
self
.
check_select
(
interfaceid
=
interfaceid
,
ip
=
self
.
base_ip
,
dns
=
""
,
hostid
=
self
.
hostid
,
main
=
1
,
port
=
self
.
base_port
,
_type
=
5
,
useip
=
0
,
bulk
=
0
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment