Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
dc113f05
Z
zendata
项目概览
LinuxSuRen
/
zendata
与 Fork 源项目一致
Fork自
易企天创 / zendata
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dc113f05
编写于
7月 24, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close #task7498,7499
上级
3e9f3bcd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
116 addition
and
58 deletion
+116
-58
demo/smoke.yaml
demo/smoke.yaml
+25
-0
demo/test.yaml
demo/test.yaml
+0
-3
src/gen/charVal.go
src/gen/charVal.go
+20
-18
src/gen/floatVal.go
src/gen/floatVal.go
+20
-16
src/gen/intVal.go
src/gen/intVal.go
+11
-7
src/gen/list.go
src/gen/list.go
+13
-13
src/gen/parser.go
src/gen/parser.go
+10
-1
src/utils/common/utils.go
src/utils/common/utils.go
+17
-0
未找到文件。
demo/smoke.yaml
0 → 100644
浏览文件 @
dc113f05
title
:
测试文件
desc
:
author
:
zentao
version
:
1.0
fields
:
-
field
:
test1
range
:
[
1-9
]
:3{2}
postfix
:
"
\t
"
-
field
:
test2
range
:
Z-A:R{2}
postfix
:
"
\t
"
-
field
:
test3
range
:
1-9.0{2}
postfix
:
"
\t
"
-
field
:
test4
range
:
user-1{3}
postfix
:
"
\t
"
-
field
:
test5
range
:
[
user-2
,
user3
,
user4
,
user6
]
:R{2}
postfix
:
"
\t
"
demo/test.yaml
浏览文件 @
dc113f05
...
...
@@ -4,9 +4,6 @@ author: zentao
version
:
1.0
fields
:
-
field
:
test
range
:
9-1:-2{2}
-
field
:
field_use_instance
# 引用default.xml里的嵌套字段
prefix
:
"
["
# 复写前缀
postfix
:
"
]"
# 特殊字符加引号,否则无法解析
...
...
src/gen/charVal.go
浏览文件 @
dc113f05
package
gen
import
(
commonUtils
"github.com/easysoft/zendata/src/utils/common"
constant
"github.com/easysoft/zendata/src/utils/const"
"math/rand"
)
func
GenerateByteItems
(
start
byte
,
end
byte
,
step
interface
{},
rand
bool
,
repeat
int
)
[]
interface
{}
{
...
...
@@ -17,17 +17,16 @@ func GenerateByteItemsByStep(start byte, end byte, step int, repeat int) []inter
arr
:=
make
([]
interface
{},
0
)
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
true
;
{
val
:=
start
+
byte
(
int
(
i
)
*
step
)
if
val
>
end
{
break
}
for
i
:=
0
;
true
;
{
val
:=
start
+
byte
(
int
(
i
)
*
step
)
if
(
val
>
end
&&
step
>
0
)
||
(
val
<
end
&&
step
<
0
)
{
break
}
for
round
:=
0
;
round
<
repeat
;
round
++
{
arr
=
append
(
arr
,
val
)
i
++
total
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
...
...
@@ -36,26 +35,28 @@ func GenerateByteItemsByStep(start byte, end byte, step int, repeat int) []inter
if
total
>
constant
.
MaxNumb
{
break
}
i
++
}
return
arr
}
func
GenerateByteItemsRand
(
start
byte
,
end
byte
,
step
int
,
repeat
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
countInRound
:=
int
(
end
-
start
)
/
step
+
1
countInRound
:=
int
(
int
(
end
)
-
int
(
start
))
/
step
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
i
<
countInRound
;
{
ran
:=
rand
.
Intn
(
countInRound
)
val
:=
start
+
byte
(
ran
)
for
i
:=
0
;
i
<
countInRound
;
{
rand
:=
commonUtils
.
RandNum
(
countInRound
)
if
step
<
0
{
rand
=
rand
*
-
1
}
val
:=
start
+
byte
(
rand
)
for
round
:=
0
;
round
<
repeat
;
round
++
{
arr
=
append
(
arr
,
val
)
i
++
total
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
...
...
@@ -64,6 +65,7 @@ func GenerateByteItemsRand(start byte, end byte, step int, repeat int) []interfa
if
total
>
constant
.
MaxNumb
{
break
}
i
++
}
return
arr
...
...
src/gen/floatVal.go
浏览文件 @
dc113f05
package
gen
import
(
commonUtils
"github.com/easysoft/zendata/src/utils/common"
constant
"github.com/easysoft/zendata/src/utils/const"
"math/rand"
"strconv"
"strings"
)
...
...
@@ -19,18 +19,17 @@ func GenerateFloatItemsByStep(start float64, end float64, step interface{}, repe
arr
:=
make
([]
interface
{},
0
)
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
0
;
true
;
{
gap
:=
float64
(
i
)
*
step
.
(
float64
)
val
:=
start
+
gap
if
val
>
end
{
break
}
for
i
:=
0
;
true
;
{
val
:=
start
+
float64
(
i
)
*
step
.
(
float64
)
if
(
val
>
end
&&
step
.
(
float64
)
>
0
)
||
(
val
<
end
&&
step
.
(
float64
)
<
0
)
{
break
}
for
round
:=
0
;
round
<
repeat
;
round
++
{
arr
=
append
(
arr
,
val
)
i
++
total
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
...
...
@@ -38,6 +37,7 @@ func GenerateFloatItemsByStep(start float64, end float64, step interface{}, repe
if
total
>
constant
.
MaxNumb
{
break
}
i
++
}
return
arr
...
...
@@ -47,16 +47,19 @@ func GenerateFloatItemsRand(start float64, end float64, step float64, repeat int
arr
:=
make
([]
interface
{},
0
)
countInRound
:=
(
end
-
start
)
/
step
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
float64
(
0
);
i
<
countInRound
;
{
val
:=
start
+
float64
(
rand
.
Int63n
(
int64
(
countInRound
)))
*
step
for
i
:=
float64
(
0
);
i
<
countInRound
;
{
rand
:=
commonUtils
.
RandNum64
(
int64
(
countInRound
))
if
step
<
0
{
rand
=
rand
*
-
1
}
val
:=
start
+
float64
(
rand
)
*
step
for
round
:=
0
;
round
<
repeat
;
round
++
{
arr
=
append
(
arr
,
val
)
i
++
total
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
...
...
@@ -65,6 +68,7 @@ func GenerateFloatItemsRand(start float64, end float64, step float64, repeat int
if
total
>
constant
.
MaxNumb
{
break
}
i
++
}
return
arr
...
...
src/gen/intVal.go
浏览文件 @
dc113f05
package
gen
import
(
commonUtils
"github.com/easysoft/zendata/src/utils/common"
constant
"github.com/easysoft/zendata/src/utils/const"
"math/rand"
)
func
GenerateIntItems
(
start
int64
,
end
int64
,
step
interface
{},
rand
bool
,
limit
int
)
[]
interface
{}
{
...
...
@@ -44,15 +44,18 @@ func GenerateIntItemsByStep(start int64, end int64, step int, repeat int) []inte
func
GenerateIntItemsRand
(
start
int64
,
end
int64
,
step
int
,
repeat
int
)
[]
interface
{}
{
arr
:=
make
([]
interface
{},
0
)
countInRound
:=
(
end
-
start
)
/
int64
(
step
)
+
1
countInRound
:=
(
end
-
start
)
/
int64
(
step
)
total
:=
0
for
round
:=
0
;
round
<
repeat
;
round
++
{
for
i
:=
int64
(
0
);
i
<
countInRound
;
{
val
:=
start
+
rand
.
Int63n
(
countInRound
)
for
i
:=
int64
(
0
);
i
<
countInRound
;
{
rand
:=
commonUtils
.
RandNum64
(
countInRound
)
if
step
<
0
{
rand
=
rand
*
-
1
}
val
:=
start
+
rand
for
round
:=
0
;
round
<
repeat
;
round
++
{
arr
=
append
(
arr
,
val
)
i
++
total
++
if
total
>
constant
.
MaxNumb
{
...
...
@@ -63,6 +66,7 @@ func GenerateIntItemsRand(start int64, end int64, step int, repeat int) []interf
if
total
>
constant
.
MaxNumb
{
break
}
i
++
}
return
arr
...
...
src/gen/list.go
浏览文件 @
dc113f05
...
...
@@ -2,8 +2,8 @@ package gen
import
(
"github.com/easysoft/zendata/src/model"
commonUtils
"github.com/easysoft/zendata/src/utils/common"
constant
"github.com/easysoft/zendata/src/utils/const"
"math/rand"
"strconv"
"strings"
)
...
...
@@ -94,7 +94,7 @@ func CheckRangeType(startStr string, endStr string, stepStr string) (string, int
float1
,
errFloat1
:=
strconv
.
ParseFloat
(
startStr
,
64
)
float2
,
errFloat2
:=
strconv
.
ParseFloat
(
endStr
,
64
)
var
errFloat3
error
if
strings
.
ToLower
(
stepStr
)
!=
"r"
{
if
strings
.
ToLower
(
stepStr
)
!=
"
"
&&
strings
.
ToLower
(
stepStr
)
!=
"
r"
{
_
,
errFloat3
=
strconv
.
ParseFloat
(
stepStr
,
64
)
}
if
errFloat1
==
nil
&&
errFloat2
==
nil
&&
errFloat3
==
nil
{
// is float
...
...
@@ -110,8 +110,8 @@ func CheckRangeType(startStr string, endStr string, stepStr string) (string, int
precision
:=
getPrecision
(
float1
,
step
)
if
(
float1
>
float2
&&
step
.
(
int
)
>
0
)
||
(
float1
<
float2
&&
step
.
(
int
)
<
0
)
{
step
=
-
1
*
step
.
(
int
)
if
(
float1
>
float2
&&
step
.
(
float64
)
>
0
)
||
(
float1
<
float2
&&
step
.
(
float64
)
<
0
)
{
step
=
-
1
*
step
.
(
float64
)
}
return
"float"
,
step
,
precision
,
rand
...
...
@@ -145,18 +145,17 @@ func GenerateValuesFromLiteral(desc string, stepStr string, repeat int) []interf
total
:=
0
for
i
:=
0
;
i
<
len
(
elemArr
);
{
for
round
:=
0
;
round
<
repeat
;
round
++
{
val
:=
""
if
stepStr
==
"r"
{
val
=
elemArr
[
rand
.
Intn
(
len
(
elemArr
))]
}
else
{
val
=
elemArr
[
i
]
}
val
:=
""
if
stepStr
==
"r"
{
val
=
elemArr
[
commonUtils
.
RandNum
(
len
(
elemArr
))]
}
else
{
val
=
elemArr
[
i
]
}
for
round
:=
0
;
round
<
repeat
;
round
++
{
items
=
append
(
items
,
val
)
i
+=
step
total
++
total
++
if
total
>
constant
.
MaxNumb
{
break
}
...
...
@@ -165,6 +164,7 @@ func GenerateValuesFromLiteral(desc string, stepStr string, repeat int) []interf
if
total
>=
constant
.
MaxNumb
{
break
}
i
+=
step
}
return
items
...
...
src/gen/parser.go
浏览文件 @
dc113f05
...
...
@@ -73,6 +73,8 @@ func ParseRangeItem(item string) (entry string, step string, repeat int) {
step
=
strings
.
ToLower
(
sectionArr
[
1
])
}
if
repeat
==
0
{
repeat
=
1
}
if
step
==
""
{
step
=
"1"
}
return
entry
,
step
,
repeat
}
...
...
@@ -107,7 +109,14 @@ func isBoundaryStr(str string) bool {
right
:=
strings
.
TrimSpace
(
arr
[
1
])
if
len
(
left
)
!=
1
||
len
(
right
)
!=
1
{
return
false
leftRune
:=
[]
rune
(
string
(
left
[
0
]))[
0
]
rightRune
:=
[]
rune
(
string
(
right
[
0
]))[
0
]
if
unicode
.
IsNumber
(
leftRune
)
&&
unicode
.
IsNumber
(
rightRune
)
{
return
true
}
else
{
return
false
}
}
else
{
leftRune
:=
[]
rune
(
string
(
left
[
0
]))[
0
]
rightRune
:=
[]
rune
(
string
(
right
[
0
]))[
0
]
...
...
src/utils/common/utils.go
浏览文件 @
dc113f05
...
...
@@ -5,6 +5,7 @@ import (
"github.com/easysoft/zendata/src/utils/const"
stringUtils
"github.com/easysoft/zendata/src/utils/string"
"github.com/emirpasic/gods/maps"
"math/rand"
"net"
"os"
"path"
...
...
@@ -13,6 +14,7 @@ import (
"regexp"
"runtime"
"strings"
"time"
)
func
Base
(
pathStr
string
)
string
{
...
...
@@ -191,4 +193,19 @@ func GetIpType(IP net.IP) string {
}
}
return
""
}
func
RandNum
(
length
int
)
int
{
randSeeds
:=
time
.
Now
()
.
Unix
()
+
int64
(
rand
.
Intn
(
100000000
))
rand
.
Seed
(
randSeeds
)
seedInt
:=
rand
.
Intn
(
length
)
return
seedInt
}
func
RandNum64
(
length
int64
)
int64
{
randSeeds
:=
time
.
Now
()
.
Unix
()
+
int64
(
rand
.
Intn
(
100000000
))
rand
.
Seed
(
randSeeds
)
seedInt
:=
rand
.
Int63n
(
length
)
return
seedInt
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录