Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
dc5cb685
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
11 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dc5cb685
编写于
8月 15, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get and save last record id after result submition for bug report
上级
daf0331d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
102 addition
and
53 deletion
+102
-53
src/model/test.go
src/model/test.go
+5
-4
src/service/testing/result.go
src/service/testing/result.go
+8
-47
src/service/zentao/result.go
src/service/zentao/result.go
+88
-0
src/test/submitResult.go
src/test/submitResult.go
+1
-2
未找到文件。
src/model/test.go
浏览文件 @
dc5cb685
...
...
@@ -59,10 +59,11 @@ type TestReport struct {
Cases
[]
CaseLog
}
type
CaseLog
struct
{
Id
int
IdInTask
int
Path
string
Status
string
Id
int
IdInTask
int
ZentaoRunId
int
Path
string
Status
string
Steps
[]
StepLog
}
...
...
src/service/testing/result.go
浏览文件 @
dc5cb685
...
...
@@ -2,62 +2,15 @@ package testingService
import
(
"encoding/json"
"fmt"
"github.com/easysoft/zentaoatf/src/model"
httpClient
"github.com/easysoft/zentaoatf/src/service/client"
scriptService
"github.com/easysoft/zentaoatf/src/service/script"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
constant
"github.com/easysoft/zentaoatf/src/utils/const"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
printUtils
"github.com/easysoft/zentaoatf/src/utils/print"
"github.com/easysoft/zentaoatf/src/utils/vari"
"os"
"strconv"
"strings"
)
func
SubmitResult
(
assert
string
,
date
string
)
{
conf
:=
configUtils
.
ReadCurrConfig
()
report
:=
GetTestTestReportForSubmit
(
assert
,
date
)
for
_
,
cs
:=
range
report
.
Cases
{
id
:=
cs
.
Id
runId
:=
cs
.
IdInTask
var
uri
string
uri
=
fmt
.
Sprintf
(
"testtask-runCase-%d-%d-1.json"
,
runId
,
id
)
requestObj
:=
map
[
string
]
string
{
"case"
:
strconv
.
Itoa
(
id
),
"version"
:
"0"
}
for
_
,
step
:=
range
cs
.
Steps
{
var
stepStatus
string
if
step
.
Status
{
stepStatus
=
constant
.
PASS
.
String
()
}
else
{
stepStatus
=
constant
.
FAIL
.
String
()
}
stepResults
:=
""
for
_
,
checkpoint
:=
range
step
.
CheckPoints
{
stepResults
+=
checkpoint
.
Actual
// strconv.FormatBool(checkpoint.Status) + ": " + checkpoint.Actual
}
requestObj
[
"steps["
+
strconv
.
Itoa
(
step
.
Id
)
+
"]"
]
=
stepStatus
requestObj
[
"reals["
+
strconv
.
Itoa
(
step
.
Id
)
+
"]"
]
=
stepResults
}
reqStr
,
_
:=
json
.
Marshal
(
requestObj
)
printUtils
.
PrintToCmd
(
string
(
reqStr
))
url
:=
conf
.
Url
+
uri
_
,
ok
:=
httpClient
.
PostStr
(
url
,
requestObj
)
if
ok
{
printUtils
.
PrintToCmd
(
fmt
.
Sprintf
(
"success to submit the results for case %d"
,
id
))
}
}
}
func
GetTestTestReportForSubmit
(
assert
string
,
date
string
)
model
.
TestReport
{
mode
,
name
:=
scriptService
.
GetRunModeAndName
(
assert
)
resultPath
:=
vari
.
Prefer
.
WorkDir
+
constant
.
LogDir
+
scriptService
.
LogFolder
(
mode
,
name
,
date
)
+
...
...
@@ -71,3 +24,11 @@ func GetTestTestReportForSubmit(assert string, date string) model.TestReport {
return
report
}
func
SaveTestTestReportAfterSubmit
(
assert
string
,
date
string
,
content
string
)
{
mode
,
name
:=
scriptService
.
GetRunModeAndName
(
assert
)
resultPath
:=
vari
.
Prefer
.
WorkDir
+
constant
.
LogDir
+
scriptService
.
LogFolder
(
mode
,
name
,
date
)
+
string
(
os
.
PathSeparator
)
+
"result.json"
fileUtils
.
WriteFile
(
resultPath
,
content
)
}
src/service/zentao/result.go
0 → 100644
浏览文件 @
dc5cb685
package
zentaoService
import
(
"encoding/json"
"fmt"
"github.com/bitly/go-simplejson"
"github.com/easysoft/zentaoatf/src/service/client"
testingService
"github.com/easysoft/zentaoatf/src/service/testing"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
constant
"github.com/easysoft/zentaoatf/src/utils/const"
printUtils
"github.com/easysoft/zentaoatf/src/utils/print"
"github.com/easysoft/zentaoatf/src/utils/zentao"
"strconv"
)
func
SubmitResult
(
assert
string
,
date
string
)
{
conf
:=
configUtils
.
ReadCurrConfig
()
report
:=
testingService
.
GetTestTestReportForSubmit
(
assert
,
date
)
for
idx
,
cs
:=
range
report
.
Cases
{
id
:=
cs
.
Id
idInTask
:=
cs
.
IdInTask
var
uri
string
uri
=
fmt
.
Sprintf
(
"testtask-runCase-%d-%d-1.json"
,
idInTask
,
id
)
requestObj
:=
map
[
string
]
string
{
"case"
:
strconv
.
Itoa
(
id
),
"version"
:
"0"
}
for
_
,
step
:=
range
cs
.
Steps
{
var
stepStatus
string
if
step
.
Status
{
stepStatus
=
constant
.
PASS
.
String
()
}
else
{
stepStatus
=
constant
.
FAIL
.
String
()
}
stepResults
:=
""
for
_
,
checkpoint
:=
range
step
.
CheckPoints
{
stepResults
+=
checkpoint
.
Actual
// strconv.FormatBool(checkpoint.Status) + ": " + checkpoint.Actual
}
requestObj
[
"steps["
+
strconv
.
Itoa
(
step
.
Id
)
+
"]"
]
=
stepStatus
requestObj
[
"reals["
+
strconv
.
Itoa
(
step
.
Id
)
+
"]"
]
=
stepResults
}
reqStr
,
_
:=
json
.
Marshal
(
requestObj
)
printUtils
.
PrintToCmd
(
string
(
reqStr
))
url
:=
conf
.
Url
+
uri
_
,
ok
:=
client
.
PostStr
(
url
,
requestObj
)
if
ok
{
resultId
:=
GetLastResult
(
conf
.
Url
,
idInTask
,
id
)
report
.
Cases
[
idx
]
.
ZentaoRunId
=
resultId
json
,
_
:=
json
.
Marshal
(
report
)
testingService
.
SaveTestTestReportAfterSubmit
(
assert
,
date
,
string
(
json
))
printUtils
.
PrintToCmd
(
fmt
.
Sprintf
(
"success to submit the results for case %d, resultId is %d"
,
id
,
resultId
))
}
}
}
func
GetLastResult
(
baseUrl
string
,
caseInTaskId
int
,
caseId
int
)
int
{
params
:=
fmt
.
Sprintf
(
"%d-%d-1.json"
,
caseInTaskId
,
caseId
)
url
:=
baseUrl
+
zentaoUtils
.
GenApiUri
(
"testtask"
,
"results"
,
params
)
dataStr
,
ok
:=
client
.
Get
(
url
,
nil
)
resultId
:=
-
1
if
ok
{
jsonData
,
err
:=
simplejson
.
NewJson
([]
byte
(
dataStr
))
if
err
==
nil
{
results
,
_
:=
jsonData
.
Get
(
"results"
)
.
Map
()
for
key
,
_
:=
range
results
{
numb
,
_
:=
strconv
.
Atoi
(
key
)
if
resultId
<
numb
{
resultId
=
numb
}
}
}
}
return
resultId
}
src/test/submitResult.go
浏览文件 @
dc5cb685
package
main
import
(
testingService
"github.com/easysoft/zentaoatf/src/service/testing"
zentaoService
"github.com/easysoft/zentaoatf/src/service/zentao"
)
func
main
()
{
zentaoService
.
Login
(
"http://ztpmp.ngtesting.org/"
,
"admin"
,
"P2ssw0rd"
)
testingService
.
SubmitResult
(
"scripts/all.suite"
,
"2019-08-15T082332
"
)
zentaoService
.
SubmitResult
(
"scripts/all.suite"
,
"2019-08-15T090121
"
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录