Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
2b7a59c1
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
32
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b7a59c1
编写于
8月 11, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
8月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
!70 文档补充删除 tracking 用法,补充删除接口测试用例
Merge pull request !70 from chenyanpanHW/master
上级
06169b9b
6553740a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
121 addition
and
33 deletion
+121
-33
patch-tracking/README.md
patch-tracking/README.md
+15
-1
patch-tracking/patch_tracking/api/constant.py
patch-tracking/patch_tracking/api/constant.py
+3
-1
patch-tracking/patch_tracking/api/tracking.py
patch-tracking/patch_tracking/api/tracking.py
+12
-3
patch-tracking/patch_tracking/app.py
patch-tracking/patch_tracking/app.py
+3
-1
patch-tracking/patch_tracking/cli/patch_tracking_cli.py
patch-tracking/patch_tracking/cli/patch_tracking_cli.py
+37
-25
patch-tracking/patch_tracking/tests/settings.conf
patch-tracking/patch_tracking/tests/settings.conf
+17
-0
patch-tracking/patch_tracking/tests/tracking_test.py
patch-tracking/patch_tracking/tests/tracking_test.py
+34
-2
未找到文件。
patch-tracking/README.md
浏览文件 @
2b7a59c1
...
...
@@ -261,7 +261,21 @@ patch-tracking-cli query --server <LISTEN> --table issue
patch-tracking-cli query --server 127.0.0.1:5001 --table issue
```
### 4.4 码云查看 issue 及 PR
### 4.4 删除 Tracking 跟踪项数据
```
shell script
patch-tracking-cli delete --server SERVER --user USER --password PWD --table TABLE --repo REPO [--branch BRANCH]
```
可以删除指定repo和branch的单条数据;也可直接删除指定repo下所有branch的数据。
例如:
```
shell script
patch-tracking-cli delete --server 127.0.0.1:5001 --user admin --password Test@123 --repo testPatchTrack/testPatch1 --branch master
```
### 4.5 码云查看 issue 及 PR
登录Gitee上进行跟踪的软件项目,在该项目的Issues和Pull Requests页签下,可以查看到名为
`[patch tracking] TIME`
,例如
` [patch tracking] 20200713101548`
的条目。
...
...
patch-tracking/patch_tracking/api/constant.py
浏览文件 @
2b7a59c1
...
...
@@ -24,6 +24,7 @@ class ResponseCode:
DELETE_DB_ERROR
=
"6001"
CONFIGFILE_PATH_EMPTY
=
"6002"
DIS_CONNECTION_DB
=
"6003"
DELETE_DB_NOT_FOUND
=
"6005"
CODE_MSG_MAP
=
{
SUCCESS
:
"Successful Operation!"
,
...
...
@@ -36,7 +37,8 @@ class ResponseCode:
GITEE_CONNECTION_ERROR
:
"Unable to connect to the gitee"
,
DELETE_DB_ERROR
:
"Failed to delete database"
,
CONFIGFILE_PATH_EMPTY
:
"Initialization profile does not exist or cannot be found"
,
DIS_CONNECTION_DB
:
"Unable to connect to the database, check the database configuration"
DIS_CONNECTION_DB
:
"Unable to connect to the database, check the database configuration"
,
DELETE_DB_NOT_FOUND
:
"The tracking you want to delete does not exist"
}
@
classmethod
...
...
patch-tracking/patch_tracking/api/tracking.py
浏览文件 @
2b7a59c1
...
...
@@ -30,14 +30,23 @@ def delete():
try
:
if
"branch"
in
keys
:
if
Tracking
.
query
.
filter
(
Tracking
.
repo
==
input_params
[
'repo'
],
Tracking
.
branch
==
input_params
[
'branch'
]):
if
Tracking
.
query
.
filter
(
Tracking
.
repo
==
input_params
[
'repo'
],
Tracking
.
branch
==
input_params
[
'branch'
]).
first
():
delete_tracking
(
input_params
[
'repo'
],
input_params
[
'branch'
])
logger
.
info
(
'Delete tracking repo: %s, branch: %s'
,
input_params
[
'repo'
],
input_params
[
'branch'
])
return
ResponseCode
.
ret_message
(
code
=
ResponseCode
.
SUCCESS
)
else
:
logger
.
info
(
'Delete tracking repo: %s, branch: %s not found.'
,
input_params
[
'repo'
],
input_params
[
'branch'
])
return
ResponseCode
.
ret_message
(
code
=
ResponseCode
.
DELETE_DB_NOT_FOUND
)
else
:
if
Tracking
.
query
.
filter
(
Tracking
.
repo
==
input_params
[
'repo'
]):
if
Tracking
.
query
.
filter
(
Tracking
.
repo
==
input_params
[
'repo'
])
.
first
()
:
delete_tracking
(
input_params
[
'repo'
])
logger
.
info
(
'Delete tracking repo: %s'
,
input_params
[
'repo'
])
return
ResponseCode
.
ret_message
(
code
=
ResponseCode
.
SUCCESS
)
return
ResponseCode
.
ret_message
(
code
=
ResponseCode
.
SUCCESS
)
else
:
logger
.
info
(
'Delete tracking repo: %s not found.'
,
input_params
[
'repo'
])
return
ResponseCode
.
ret_message
(
code
=
ResponseCode
.
DELETE_DB_NOT_FOUND
)
except
SQLAlchemyError
as
err
:
return
ResponseCode
.
ret_message
(
code
=
ResponseCode
.
DELETE_DB_ERROR
,
data
=
err
)
...
...
patch-tracking/patch_tracking/app.py
浏览文件 @
2b7a59c1
...
...
@@ -2,6 +2,7 @@
flask app
"""
import
logging.config
import
os
import
sys
from
flask
import
Flask
from
patch_tracking.api.issue
import
issue
...
...
@@ -33,7 +34,8 @@ def check_settings_conf():
sys
.
exit
()
app
.
config
.
from_pyfile
(
"settings.conf"
)
settings_file
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
curdir
),
"settings.conf"
)
app
.
config
.
from_pyfile
(
settings_file
)
check_settings_conf
()
GITHUB_ACCESS_TOKEN
=
app
.
config
[
'GITHUB_ACCESS_TOKEN'
]
...
...
patch-tracking/patch_tracking/cli/patch_tracking_cli.py
浏览文件 @
2b7a59c1
...
...
@@ -21,10 +21,7 @@ def query_table(args):
if
args
.
table
==
"tracking"
:
url
=
'/'
.
join
([
'https:/'
,
server
,
'tracking'
])
if
args
.
branch
and
args
.
repo
:
params
=
{
'repo'
:
args
.
repo
,
'branch'
:
args
.
branch
}
else
:
params
=
{
'repo'
:
args
.
repo
}
params
=
{
'repo'
:
args
.
repo
,
'branch'
:
args
.
branch
}
try
:
ret
=
requests
.
get
(
url
,
params
=
params
,
verify
=
False
)
if
ret
.
status_code
==
200
and
ret
.
json
()[
'code'
]
==
'2001'
:
...
...
@@ -119,6 +116,9 @@ def params_input_track(params, file_path=None):
"""
load tracking from command line arguments
"""
if
not
check_add_param
(
params
):
return
'error'
,
'Check input params error'
if
add_param_check_url
(
params
,
file_path
)
==
'error'
:
return
'error'
,
'Check input params error.'
...
...
@@ -156,6 +156,19 @@ def params_input_track(params, file_path=None):
return
'error'
,
'Unexpected Error.'
def
check_add_param
(
params
):
success
=
True
required_params
=
[
"repo"
,
"branch"
,
"scm_repo"
,
"scm_branch"
,
"version_control"
,
"enabled"
]
miss_params
=
list
()
for
param
in
required_params
:
if
param
not
in
params
or
not
params
[
param
]:
miss_params
.
append
(
param
)
success
=
False
if
not
success
:
print
(
"patch_tracking_cli add: error: the following arguments are required: --{}"
.
format
(
", --"
.
join
(
miss_params
)))
return
success
def
add
(
args
):
"""
add tracking
...
...
@@ -212,20 +225,19 @@ def delete(args):
if
ret
.
status_code
==
200
and
ret
.
json
()[
'code'
]
==
'2001'
:
print
(
'Tracking delete successfully.'
)
return
elif
ret
.
status_code
==
200
and
ret
.
json
()[
'code'
]
==
'6005'
:
print
(
'Delete Nothing. Tracking not exist.'
)
return
print
(
"Tracking delete failed. Error:
%s"
,
ret
)
print
(
"Tracking delete failed. Error:
{}"
.
format
(
ret
.
text
)
)
except
Exception
as
exception
:
print
(
'
Error: Connect server error: %s'
,
str
(
exception
))
print
(
'
Connect server error: '
+
str
(
exception
))
def
query
(
args
):
"""
query table data
"""
if
args
.
branch
and
not
args
.
repo
:
print
(
query_usage
)
return
query table data
"""
status
,
ret
=
query_table
(
args
)
if
status
==
"success"
:
df
=
pandas
.
DataFrame
.
from_dict
(
ret
.
json
()[
"data"
],
orient
=
"columns"
)
...
...
@@ -266,16 +278,16 @@ def dir_input_track(dir_path, args):
load tracking from dir
"""
if
os
.
path
.
exists
(
dir_path
)
and
os
.
path
.
isdir
(
dir_path
):
for
root
,
_
,
files
in
os
.
walk
(
dir_path
):
if
not
files
:
print
(
'error: dir path empty'
)
return
for
file
in
files
:
if
os
.
path
.
splitext
(
file
)[
-
1
]
==
".yaml"
:
file_path
=
os
.
path
.
join
(
root
,
file
)
file_input_track
(
file_path
,
args
)
else
:
print
(
'Please input yaml file. Error in {}'
.
format
(
file
))
dir_files
=
os
.
listdir
(
dir_path
)
if
not
dir_
files
:
print
(
'error: dir path empty'
)
return
for
file
in
dir_
files
:
if
os
.
path
.
isfile
(
os
.
path
.
join
(
dir_path
,
file
))
and
os
.
path
.
splitext
(
file
)[
-
1
]
==
".yaml"
:
file_path
=
os
.
path
.
join
(
dir_path
,
file
)
file_input_track
(
file_path
,
args
)
else
:
print
(
'Please input yaml file. Error in {}'
.
format
(
file
))
else
:
print
(
'error: dir path error. Params error in {}'
.
format
(
dir_path
))
...
...
@@ -304,7 +316,7 @@ add_usage = """
%(prog)s --server SERVER --user USER --password PASSWORD --file FILE
%(prog)s --server SERVER --user USER --password PASSWORD --dir DIR"""
parser_add
=
subparsers
.
add_parser
(
'add'
,
parents
=
[
common_parser
,
authentication_parser
],
help
=
"add tracking"
,
usage
=
add_usage
'add'
,
parents
=
[
common_parser
,
authentication_parser
],
help
=
"add tracking"
,
usage
=
add_usage
,
allow_abbrev
=
False
)
parser_add
.
set_defaults
(
func
=
add
)
parser_add
.
add_argument
(
"--version_control"
,
choices
=
[
'github'
],
help
=
"upstream version control system"
)
...
...
@@ -319,7 +331,7 @@ parser_add.add_argument('--dir', help='import patch tracking from files in direc
# delete
del_usage
=
"""
%(prog)s --server SERVER --table TABLE --repo REPO [--branch BRANCH]"""
parser_delete
=
subparsers
.
add_parser
(
'delete'
,
parents
=
[
common_parser
,
authentication_parser
],
help
=
"delete tracking"
)
parser_delete
=
subparsers
.
add_parser
(
'delete'
,
parents
=
[
common_parser
,
authentication_parser
],
help
=
"delete tracking"
,
allow_abbrev
=
False
)
parser_delete
.
set_defaults
(
func
=
delete
)
parser_delete
.
add_argument
(
"--repo"
,
required
=
True
,
help
=
"source package repository"
)
parser_delete
.
add_argument
(
"--branch"
,
help
=
"source package branch"
)
...
...
@@ -327,7 +339,7 @@ parser_delete.add_argument("--branch", help="source package branch")
# query
query_usage
=
"""
%(prog)s --server SERVER --table {tracking,issue} [--repo REPO] [--branch BRANCH]"""
parser_query
=
subparsers
.
add_parser
(
'query'
,
parents
=
[
common_parser
],
help
=
"query tracking/issue"
)
parser_query
=
subparsers
.
add_parser
(
'query'
,
parents
=
[
common_parser
],
help
=
"query tracking/issue"
,
allow_abbrev
=
False
)
parser_query
.
set_defaults
(
func
=
query
)
parser_query
.
add_argument
(
"--table"
,
required
=
True
,
choices
=
[
"tracking"
,
"issue"
],
help
=
"query tracking or issue"
)
parser_query
.
add_argument
(
"--repo"
,
help
=
"source package repository"
)
...
...
patch-tracking/patch_tracking/tests/settings.conf
0 → 100644
浏览文件 @
2b7a59c1
# server settings
LISTEN
=
"127.0.0.1:5001"
# GitHub API settings
GITHUB_ACCESS_TOKEN
=
"<GITHUB_ACCESS_TOKEN>"
# Gitee API settings
GITEE_ACCESS_TOKEN
=
"<GITEE_ACCESS_TOKEN>"
# Time interval
SCAN_DB_INTERVAL
=
3600
# username
USER
=
"<USER>"
# password
PASSWORD
=
"<PASSWORD>"
patch-tracking/patch_tracking/tests/tracking_test.py
浏览文件 @
2b7a59c1
...
...
@@ -167,12 +167,12 @@ class TestTracking(unittest.TestCase):
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
INPUT_PARAMETERS_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
ResponseCode
.
SUCCESS
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
INPUT_PARAMETERS_ERROR
),
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
SUCCESS
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
...
...
@@ -395,6 +395,38 @@ class TestTracking(unittest.TestCase):
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
resp_dict
.
get
(
"data"
),
None
,
msg
=
"Error in data information return"
)
def
test_delete_data
(
self
):
"""
The POST interface inserts data
:return:
"""
data
=
{
"version_control"
:
"github"
,
"scm_repo"
:
"test_delete"
,
"scm_branch"
:
"test_delete"
,
"scm_commit"
:
"test_delete"
,
"repo"
:
"test_delete1"
,
"branch"
:
"test_delete1"
,
"enabled"
:
0
}
self
.
client
.
post
(
"/tracking"
,
json
=
data
,
content_type
=
"application/json"
,
headers
=
self
.
auth
)
resp
=
self
.
client
.
delete
(
"/tracking?repo=test_delete1&branch=test_delete1"
,
content_type
=
"application/json"
,
headers
=
self
.
auth
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
SUCCESS
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
def
test_delete_not_found
(
self
):
"""
The POST interface inserts data
:return:
"""
resp
=
self
.
client
.
delete
(
"/tracking?repo=not_found1&branch=not_found1"
,
content_type
=
"application/json"
,
headers
=
self
.
auth
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
DELETE_DB_NOT_FOUND
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录