Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fuzzBackEnd
Overview
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
钱炳权
fuzzBackEnd
Commits
d0d52dc1
Commit
d0d52dc1
authored
8 months ago
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
除启动测试外全正常
parent
20f0eabc
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
150 additions
and
13 deletions
+150
-13
TestMissionController.java
...roll/controller/dataController/TestMissionController.java
+31
-2
TestAndParams.java
...ava/com/example/fuzzControll/domain/po/TestAndParams.java
+3
-1
TestMapper.java
...main/java/com/example/fuzzControll/mapper/TestMapper.java
+6
-0
TestMissionService.java
.../com/example/fuzzControll/service/TestMissionService.java
+4
-0
TestMissionServiceImpl.java
...ple/fuzzControll/service/impl/TestMissionServiceImpl.java
+79
-9
TestMapper.xml
fuzzIntegration/src/main/resources/mapper/TestMapper.xml
+13
-0
TestMissionController.java
...e/fuzzbackendmaster/controller/TestMissionController.java
+7
-0
FuzzIntegrationFileApi.java
...ple/fuzzbackendmaster/service/FuzzIntegrationFileApi.java
+7
-1
No files found.
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/TestMissionController.java
View file @
d0d52dc1
...
...
@@ -24,6 +24,20 @@ public class TestMissionController {
TestMissionService
testMissionService
;
/**
*
* @param id 测试id用来获取参数
* @param
*/
@RequestMapping
(
value
=
"/startmission"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
startmission
(
@RequestParam
int
id
)
{
try
{
testMissionService
.
startMission
(
id
);
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"测试启动失败!"
);
}
return
AjaxResult
.
success
(
"测试启动成功!"
);
}
/**
* 测试信息获取
*/
@RequestMapping
(
value
=
"/getAll"
,
method
=
RequestMethod
.
GET
)
...
...
@@ -32,7 +46,7 @@ public class TestMissionController {
try
{
testAndParamsList
=
testMissionService
.
getTestAndParamsList
();
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
();
return
AjaxResult
.
error
(
"测试信息获取失败!"
);
}
return
AjaxResult
.
success
(
testAndParamsList
);
}
...
...
@@ -69,7 +83,7 @@ public class TestMissionController {
}
/**
* 给空白测试配置参数
* 给空白测试配置参数
-aflnet
*/
@RequestMapping
(
value
=
"/insertWithAflnet/{id}"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
insertParmasInTestAflnet
(
@PathVariable
(
"id"
)
int
id
,
@RequestBody
final
CmdStartParams
cmdStartParams
)
{
...
...
@@ -81,6 +95,9 @@ public class TestMissionController {
return
AjaxResult
.
success
(
"参数配置成功!"
);
}
/**
* 给空白测试配置参数-kitty
*/
@RequestMapping
(
value
=
"/insertWithkitty/{id}"
,
method
=
RequestMethod
.
POST
)
public
AjaxResult
insertParmasInTestKitty
(
@PathVariable
(
"id"
)
int
id
,
@RequestBody
TestEntity
testEntity
)
{
try
{
...
...
@@ -90,4 +107,16 @@ public class TestMissionController {
}
return
AjaxResult
.
success
(
"参数配置成功!"
);
}
/**
* 测试名称修改
*/
@RequestMapping
(
value
=
"/editTestName"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
editTestName
(
@RequestParam
String
testName
,
@RequestParam
int
id
)
{
try
{
testMissionService
.
editTestName
(
testName
,
id
);
}
catch
(
Exception
e
)
{
return
AjaxResult
.
error
(
"修改失败!"
);
}
return
AjaxResult
.
success
(
"修改成功!"
);
}
}
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/java/com/example/fuzzControll/domain/po/TestAndParams.java
View file @
d0d52dc1
package
com
.
example
.
fuzzControll
.
domain
.
po
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Getter
;
...
...
@@ -14,7 +15,8 @@ import java.util.Date;
@AllArgsConstructor
public
class
TestAndParams
{
private
int
id
;
private
int
fuzzParamsId
;
@JsonIgnore
private
int
fuzzParamsId
;
//不展示给前端
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/java/com/example/fuzzControll/mapper/TestMapper.java
View file @
d0d52dc1
...
...
@@ -19,4 +19,10 @@ public interface TestMapper {
Test
getTestById
(
int
id
);
void
edit
(
Test
test
);
List
<
Test
>
getTestList
();
boolean
deleteEmptyById
(
int
id
);
boolean
editTestName
(
String
testName
,
int
id
);
}
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/java/com/example/fuzzControll/service/TestMissionService.java
View file @
d0d52dc1
...
...
@@ -19,4 +19,8 @@ public interface TestMissionService {
void
insertParmasInTestAflnet
(
int
id
,
CmdStartParams
cmdStartParams
);
void
insertParmasInTestKitty
(
int
id
,
TestEntity
testEntity
);
boolean
editTestName
(
String
testName
,
int
id
);
void
startMission
(
int
id
)
;
}
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestMissionServiceImpl.java
View file @
d0d52dc1
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.example.fuzzControll.constents.MissionStateEnum
;
import
com.example.fuzzControll.constents.TableClassEnum
;
import
com.example.fuzzControll.domain.bo.CmdStartParams
;
import
com.example.fuzzControll.domain.bo.FuzzParams
;
import
com.example.fuzzControll.domain.bo.TestEntity
;
import
com.example.fuzzControll.domain.po.MissionInfo
;
import
com.example.fuzzControll.domain.po.Test
;
import
com.example.fuzzControll.domain.po.TestAndParams
;
import
com.example.fuzzControll.exception.mysqlException.MysqlException
;
import
com.example.fuzzControll.mapper.FuzzParamsMapper
;
import
com.example.fuzzControll.mapper.MissionInfoMapper
;
import
com.example.fuzzControll.mapper.TestMapper
;
import
com.example.fuzzControll.service.TestMissionService
;
import
com.example.fuzzControll.tools.system.GlobalClass
;
import
com.example.fuzzControll.tools.system.SystemRunningParams
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -20,6 +26,8 @@ import java.text.SimpleDateFormat;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
(
"TestMissionServiceImpl"
)
...
...
@@ -28,32 +36,47 @@ public class TestMissionServiceImpl implements TestMissionService {
TestMapper
testMapper
;
@Autowired
FuzzParamsMapper
fuzzParamsMapper
;
@Autowired
MissionInfoMapper
missionInfoMapper
;
@Override
public
List
<
TestAndParams
>
getTestAndParamsList
()
{
List
<
TestAndParams
>
testParamsList
=
new
ArrayList
();
List
<
TestAndParams
>
testParamsRelevantList
=
new
ArrayList
();
List
<
TestAndParams
>
testParamsListEmpty
=
new
ArrayList
();
try
{
testParamsList
=
testMapper
.
getTestAndParamsList
();
/*查询关联的数据*/
testParamsRelevantList
=
testMapper
.
getTestAndParamsList
();
/*查询空白数据,组合起来是全数据*/
testParamsListEmpty
=
testMapper
.
getTestList
().
stream
().
map
(
test
->
new
TestAndParams
(
test
.
getId
(),
test
.
getFuzzParamsId
(),
test
.
getCreateTime
()
,
test
.
getUpdateTime
(),
test
.
getMissionIds
(),
test
.
getTestName
(),
""
,
""
)).
collect
(
Collectors
.
toList
());
testParamsRelevantList
.
addAll
(
testParamsListEmpty
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Failed to get test and params list:{}"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
if
(
testParams
List
==
null
||
testParams
List
.
size
()
==
0
)
{
if
(
testParams
RelevantList
==
null
||
testParamsRelevant
List
.
size
()
==
0
)
{
log
.
warn
(
"TestAndParams is null!"
);
}
return
testParamsList
;
return
testParams
Relevant
List
;
}
@Override
public
boolean
deleteById
(
int
id
)
{
boolean
flag
=
false
;
try
{
Test
test
=
testMapper
.
getTestById
(
id
);
/*非空白测试级联删除*/
if
(!(
test
.
getFuzzParamsId
()
==
0
))
{
flag
=
testMapper
.
deleteById
(
id
);
}
else
{
/*空白测试删除*/
flag
=
testMapper
.
deleteEmptyById
(
id
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Delete error:{}"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
return
f
alse
;
return
f
lag
;
}
...
...
@@ -76,8 +99,8 @@ public class TestMissionServiceImpl implements TestMissionService {
fuzzParamsId
=
fuzzParams
.
getId
();
test
.
setFuzzParamsId
(
fuzzParamsId
);
}
else
{
//有则更新数据
FuzzParams
fuzzParams
=
new
FuzzParams
(
test
.
getFuzzParamsId
(),
JSON
.
toJSONString
(
cmdStartParams
),
cmdStartParams
.
getProtopcol
());
if
(!
fuzzParamsMapper
.
editFuzzParams
(
fuzzParams
.
getId
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
FuzzParams
fuzzParams
=
new
FuzzParams
(
test
.
getFuzzParamsId
(),
JSON
.
toJSONString
(
cmdStartParams
),
cmdStartParams
.
getProtopcol
());
if
(!
fuzzParamsMapper
.
editFuzzParams
(
fuzzParams
.
getId
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
throw
new
RuntimeException
(
"EditFuzzParams failed!"
);
}
}
...
...
@@ -93,7 +116,54 @@ public class TestMissionServiceImpl implements TestMissionService {
@Transactional
(
rollbackFor
=
MysqlException
.
class
)
@Override
public
void
insertParmasInTestKitty
(
int
id
,
TestEntity
testEntity
)
{
/*插入fuzzparams返回id*/
/*更新对应id的测试数据*/
try
{
/*判断test是否存有paramsId,没数据插入有数据就改变*/
Test
test
=
testMapper
.
getTestById
(
id
);
int
fuzzParamsId
;
if
(
test
.
getFuzzParamsId
()
==
0
)
{
//为0则插入id
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
.
getParamJson
()),
testEntity
.
getTestClassName
());
fuzzParamsMapper
.
insertFuzzParamsReturnId
(
fuzzParams
);
fuzzParamsId
=
fuzzParams
.
getId
();
test
.
setFuzzParamsId
(
fuzzParamsId
);
}
else
{
//有则更新数据
FuzzParams
fuzzParams
=
new
FuzzParams
(
JSON
.
toJSONString
(
testEntity
.
getParamJson
()),
testEntity
.
getTestClassName
());
if
(!
fuzzParamsMapper
.
editFuzzParams
(
fuzzParams
.
getId
(),
fuzzParams
.
getParams
(),
fuzzParams
.
getProtocol
()))
{
throw
new
RuntimeException
(
"EditFuzzParams failed!"
);
}
}
/*更新修改时间*/
test
.
setUpdateTime
(
new
Date
());
testMapper
.
edit
(
test
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Failed to insert:[{}]"
,
e
.
getMessage
());
throw
new
MysqlException
(
""
);
}
}
@Override
public
boolean
editTestName
(
String
testName
,
int
id
)
{
boolean
flag
=
false
;
try
{
flag
=
testMapper
.
editTestName
(
testName
,
id
);
}
catch
(
Exception
e
)
{
log
.
error
(
"EditTestName failed!:[{}]"
,
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
return
flag
;
}
@Override
public
void
startMission
(
int
id
)
{
Test
test
=
testMapper
.
getTestById
(
id
);
if
(!(
test
.
getFuzzParamsId
()
==
0
))
{
log
.
error
(
"This is a empty test!"
);
throw
new
RuntimeException
();
}
/*生成任务*/
int
missionId
=
GlobalClass
.
missionInfoMapper
.
selectTopMissionId
()
+
1
;
SystemRunningParams
.
kittyMissionId
=
missionId
;
MissionInfo
missionInfo
=
new
MissionInfo
(
missionId
,
TableClassEnum
.
KITTY_RESULT
.
getTableId
(),
new
Date
(),
SystemRunningParams
.
kittyData
.
get
(
"missionName"
),
MissionStateEnum
.
RUNNING
.
getStateCode
(),
0L
);
}
}
This diff is collapsed.
Click to expand it.
fuzzIntegration/src/main/resources/mapper/TestMapper.xml
View file @
d0d52dc1
...
...
@@ -25,6 +25,11 @@
set fuzzParamsId = #{fuzzParamsId}, updateTime = #{updateTime}
where id = #{id}
</update>
<update
id=
"editTestName"
>
update test
set testName = #{testName}
where id = #{id}
</update>
<delete
id=
"deleteById"
>
DELETE
t1, t2
...
...
@@ -32,6 +37,9 @@
INNER JOIN fuzz_params t2 ON t1.fuzzParamsId = t2.id
WHERE t1.id = #{id};
</delete>
<delete
id=
"deleteEmptyById"
>
DELETE FROM test where id = #{id}
</delete>
<select
id=
"getTestAndParamsList"
resultType=
"com.example.fuzzControll.domain.po.TestAndParams"
>
select test.id, fuzzParamsId,createTime,updateTime,missionIds,testName,params,protocol from test,fuzz_params
where test.fuzzParamsId = fuzz_params.id
...
...
@@ -40,5 +48,9 @@
<include
refid=
"selectAll"
/>
where id = #{id}
</select>
<select
id=
"getTestList"
resultType=
"com.example.fuzzControll.domain.po.Test"
>
<include
refid=
"selectAll"
/>
where fuzzParamsId = 0
</select>
</mapper>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
fuzzbackendmaster/src/main/java/com/example/fuzzbackendmaster/controller/TestMissionController.java
View file @
d0d52dc1
...
...
@@ -55,4 +55,11 @@ public class TestMissionController {
public
AjaxResult
insertParmasInTestKitty
(
@PathVariable
(
"id"
)
int
id
,
@RequestBody
TestEntity
testEntity
)
{
return
fuzzIntegrationFileApi
.
insertParmasInTestKitty
(
id
,
testEntity
);
}
/**
* 测试名称修改
*/
@RequestMapping
(
value
=
"/editTestName"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
editTestName
(
@RequestParam
String
testName
,
@RequestParam
int
id
)
{
return
fuzzIntegrationFileApi
.
editTestName
(
testName
,
id
);
}
}
This diff is collapsed.
Click to expand it.
fuzzbackendmaster/src/main/java/com/example/fuzzbackendmaster/service/FuzzIntegrationFileApi.java
View file @
d0d52dc1
...
...
@@ -163,7 +163,7 @@ public interface FuzzIntegrationFileApi {
* 跟据id删除测试
*/
@RequestMapping
(
value
=
"/testmission/deleteById"
,
method
=
RequestMethod
.
GET
)
AjaxResult
deleteById
(
int
id
);
AjaxResult
deleteById
(
@RequestParam
int
id
);
/**
* 插入空白测试信息
*/
...
...
@@ -177,4 +177,10 @@ public interface FuzzIntegrationFileApi {
AjaxResult
insertParmasInTestAflnet
(
@PathVariable
(
"id"
)
int
id
,
@RequestBody
final
CmdStartParams
cmdStartParams
);
@RequestMapping
(
value
=
"/testmission/insertWithkitty/{id}"
,
method
=
RequestMethod
.
POST
)
AjaxResult
insertParmasInTestKitty
(
@PathVariable
(
"id"
)
int
id
,
@RequestBody
TestEntity
testEntity
);
/**
* 测试名称修改
*/
@RequestMapping
(
value
=
"/testmission/editTestName"
,
method
=
RequestMethod
.
GET
)
AjaxResult
editTestName
(
@RequestParam
String
testName
,
@RequestParam
int
id
);
}
This diff is collapsed.
Click to expand it.
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