Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
488b3519
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 搜索 >>
提交
488b3519
编写于
8月 06, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add service test scripts
上级
30aa1c92
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
247 addition
and
1 deletion
+247
-1
test/unit/test-server.go
test/unit/test-server.go
+1
-1
test/ztf/._config.yaml
test/ztf/._config.yaml
+44
-0
test/ztf/._default.yaml
test/ztf/._default.yaml
+139
-0
test/ztf/script/lib/zd.php
test/ztf/script/lib/zd.php
+27
-0
test/ztf/script/service/svc_post.exp
test/ztf/script/service/svc_post.exp
+2
-0
test/ztf/script/service/svc_post.php
test/ztf/script/service/svc_post.php
+34
-0
未找到文件。
test/unit/test-server.go
浏览文件 @
488b3519
...
...
@@ -7,7 +7,7 @@ import (
)
func
main
()
{
urlStr
:=
httpUtils
.
GenUrl
(
"10.8.0.134"
,
8848
,
"?
config=&
F=field_common&lines=10"
)
urlStr
:=
httpUtils
.
GenUrl
(
"10.8.0.134"
,
8848
,
"?F=field_common&lines=10"
)
data
:=
url
.
Values
{}
defaultContent
:=
fileUtils
.
ReadFile
(
"demo/default.yaml"
)
...
...
test/ztf/._config.yaml
0 → 100644
浏览文件 @
488b3519
title
:
测试文件
desc
:
author
:
zentao
version
:
1.0
fields
:
-
field
:
field_use_instance
prefix
:
"
"
postfix
:
"
]"
-
field
:
field_use_excel
prefix
:
"
["
postfix
:
"
]====
"
-
field
:
field_with_children
prefix
:
"
["
postfix
:
"
]
"
-
field
:
field_loop
prefix
:
"
["
postfix
:
"
]"
-
field
:
field_loop_range
range
:
1-3{3}
loop
:
2-3
loopfix
:
"
|"
prefix
:
"
["
postfix
:
"
]
\t
"
-
field
:
field_nested_range
from
:
custom.test.number.v1.yaml
use
:
medium
prefix
:
"
["
postfix
:
"
]"
-
field
:
field_nested_instant
from
:
custom.ip.private.yaml
use
:
all
prefix
:
"
["
-
field
:
field_nested_instant
from
:
custom.ip.private.yaml
use
:
all
prefix
:
"
["
\ No newline at end of file
test/ztf/._default.yaml
0 → 100644
浏览文件 @
488b3519
title
:
zendata数据配置语法说明
desc
:
# 文件组成
# zendata以yaml格式的文件来定义各个字段的格式。
# yaml文件整体由文件说明和字段定义两部分组成。
# 文件说明
# title: 标题,可以用简短的文字概要描述该文件定义的数据类型。
# desc: 描述,可以用多行文本来详细描述该文件定义的数据类型,非必选项。
# author: 作者,非必选项。
# version:版本号,非必选项。
# 字段列表
# 字段定义部分都放在fields这个定义里面。
# 一个yaml文件可以包含一个或者多个字段。
# 字段列表以-field定义开始。
# 一个字段可以通过fields属性定义它的子字段。
# 字段定义
# field: 字段名,仅支持英文、数字、下换线和.
# range: 列表范围,最重要的定义。
# loop: 循环次数,可以定义某一字段循环多少次。
# loopfix: 每一次循环时的连接符。
# format: 支持格式化输出。
# prefix: 该字段的前缀。
# postfix: 该字段的后缀。
# length: 该字段的长度。如果不通过分隔符区分,则需要指定字段长度,单位是字节。
# leftpad: 左填充的字符。如果长度不够,可指定左填充的字符。默认是以空格左填充。
# rightpad: 右填充的字符。如果长度不够,可指定右填充的字符。
# config: 可以引用另外一个文件里面的定义。
# from: 引用某一个定义文件。
# use: 使用被引用文件中定义的若干实例。all代表使用所有。
# select: 如果引用的文件是excel表,可以查询里面的某一个字段。
# where: 如果引用的文件是excel表,可以使用查询条件。
# range定义
# 使用逗号连接不同的元素。比如 range: 1,2,3
# 元素也可以是一个区间。比如 range:1-10, A-Z
# 区间可以通过冒号:来指定步长。比如 range:1-10:2。
# 步长可以是小数。比如 range: 1-10:0.1
# 区间可以通过R来指定随机。比如 range: 1-10:R,随机和步长只能二选一。
# 可以通过一个文件来指定列表。比如range: list.txt。文件名是相对路径时,以配置文件为基准计算。
# 可以通过{n}的方式来重复某一个元素。比如 range: user1{100},user2{100}
# 如果区间或者几个元素需要重复,需要用[]括起来。比如 range: [user1,user2,user3]{100}
author
:
zentao
version
:
1.0
fields
:
-
field
:
field_common
# 默认的列表类型,通过逗号隔成若干区段。
range
:
1-10, 20-25, 27, 29,
30
# 1,2,3...,10,20,21,22...,25,27,29.30
prefix
:
int_
# 前缀
postfix
:
"
\t
"
# 后缀,特殊字符加引号,否则无法解析。
-
field
:
field_step
# 区间可以指定步长。
range
:
1-10:2, 1-2:0.1
# 1,3,5,7,9,1, 1.1,1.2...,2
postfix
:
"
\t
"
-
field
:
field_random
# 通过R属性指定随机。R属性和步长不能同时出现。
range
:
1-10:R
# 1,5,8...
postfix
:
"
\t
"
-
field
:
field_file
# 从一个文件中读取列表,并指定随机。
range
:
users.txt:R
# 该文件中一行作为一个元素,并随机。
postfix
:
"
\t
"
-
field
:
field_loop
# 自循环的字段。
range
:
a-z
# a_b_c | d_e_f | g_h_i
loop
:
3
# 循环三次
loopfix
:
_
# 每次循环的连接符。
postfix
:
"
\t
"
-
field
:
field_repeat
# 通过{}定义重复的元素。
range
:
user-1{3},[user2,user3]{2}
# user-1,user-1,user-1,user2,user3,user2,user3
postfix
:
"
\t
"
-
field
:
field_format
# 通过格式化字符串输出。
range
:
1-10
# passwd 1,passwd 2,passwd 3 ... passwd10。
format
:
"
passwd%02d"
# 用%2d补零,使密码整体保持8位,%2d默认补空格。
postfix
:
"
\t
"
-
field
:
field_use_another_file
# 可以引用其他的定义文件。
config
:
number.yaml
# 引用当前目录下面的number.yaml文件里面的定义。
postfix
:
"
\t
"
-
field
:
field_use_ranges
# 引用內置的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
custom.test.number.v1.yaml
# 引用data/custom/number/v1.yaml文件里面的ranges定义。
use
:
medium
# 使用该文件中定义的medium分组。
postfix
:
"
\t
"
-
field
:
field_use_instance
# 引用其他的定义文件,该文件定义了多个实例。
from
:
system.ip.v1.yaml
# 引用data/system/ip/v1.yaml
use
:
privateC,privateC
# 使用该文件中定义的privateC和privateB两个实例。
postfix
:
"
\t
"
-
field
:
field_nested_instant
# 引用其他的定义文件,且该文件引用了其他实例。
from
:
custom.ip.private.yaml
# 引用data/custom/ip/private.yaml
use
:
all
# 使用该文件中的所有实例。
prefix
:
"
{"
postfix
:
"
}
\t
"
-
field
:
field_use_excel
# 从excel数据源里面取数据。
from
:
system.address.v1.china
# 从data/system/address/v1.xlsx文件中读取名为china的工作簿。
select
:
city
# 查询city字段。
where
:
state like '%山东%'
# 条件是省份包含山东。
postfix
:
"
\t
"
-
field
:
field_with_children
# 嵌套字段
fields
:
-
field
:
child1
range
:
a-z
prefix
:
part1_
postfix
:
'
|'
-
field
:
child2
range
:
A-Z
prefix
:
part2_
postfix
:
'
|'
-
field
:
child_with_child
prefix
:
part3_
postfix
:
fields
:
-
field
:
field_grandson
prefix
:
int_
range
:
10-20
postfix
:
test/ztf/script/lib/zd.php
浏览文件 @
488b3519
...
...
@@ -132,6 +132,33 @@ class zendata
return
$resp
;
}
public
function
httpPost
(
$port
,
$default
,
$config
,
$lines
,
$options
=
array
())
{
$url
=
sprintf
(
"http://127.0.0.1:%d/?lines=%d"
,
$port
,
$lines
);
if
(
array_key_exists
(
"fields"
,
$options
))
{
$url
.
=
"&F="
.
$options
[
"fields"
];
}
print
(
"
$url
\n
"
);
$defaultContent
=
file_get_contents
(
$this
->
workDir
.
"/"
.
$default
);
$configContent
=
file_get_contents
(
$this
->
workDir
.
"/"
.
$config
);
$postData
=
http_build_query
(
array
(
"default"
=>
$defaultContent
,
"config"
=>
$configContent
));
$options
=
array
(
'http'
=>
array
(
'method'
=>
'POST'
,
'header'
=>
'Content-type:application/x-www-form-urlencoded'
,
'content'
=>
$postData
,
'timeout'
=>
15
*
60
)
);
$context
=
stream_context_create
(
$options
);
$result
=
file_get_contents
(
$url
,
false
,
$context
);
return
$result
;
}
public
function
cmd
(
$params
)
{
...
...
test/ztf/script/service/svc_post.exp
0 → 100644
浏览文件 @
488b3519
>> 10
>> int_3
\ No newline at end of file
test/ztf/script/service/svc_post.php
0 → 100755
浏览文件 @
488b3519
#!/usr/bin/env php
<?php
/**
[case]
title=
cid=0
pid=0
[group]
>>
>>
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../lib/zd.php'
;
$zd
=
new
zendata
();
$port
=
8848
;
$root
=
dirname
(
dirname
(
dirname
(
__FILE__
)));
$zd
->
startService
(
$port
,
$root
);
$resp
=
$zd
->
httpPost
(
$port
,
"default.yaml"
,
"test.yaml"
,
10
,
array
(
"fields"
=>
"field_common"
));
$jsonArr
=
json_decode
(
$resp
,
TRUE
);
$count
=
sprintf
(
"%d"
,
count
(
$jsonArr
));
print
(
">>
$count
\n
"
);
$field
=
$jsonArr
[
2
][
"field_common"
];
print
(
">>
$field
\n
"
);
$zd
->
stopService
(
8848
);
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录