-
Notifications
You must be signed in to change notification settings - Fork 50
/
sample.yaml
151 lines (116 loc) · 6.04 KB
/
sample.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
title: zendata config syntax
desc:
# File composition
# zendata defines the format for each field in YAML file.
# YAML file is composed of file description and field definition.
# File description
# title: A short text to summarize the data type defined by this file.
# desc: Detailed text to describe the data type defined in this file, optional.
# author: Optional.
# version: Version number, optional.
# Field list
# Field is defined in fields.
# A YAML file contains one or more fields.
# Field list starts from -field.
# A child field can be defined by fields.
# Field definition
# field: Field name; letters, digits, underlines and dots only.
# range: List range; the most important definition.
# loop: The number of loops; define how many times a field can loop.
# loopfix: The connector for each loop.
# format: Support formatted output.
# prefix: Prefix of this field.
# postfix: Postfix of this field.
# length: The length of this field. If separators are not used, specify the field length in bytes.
# leftpad: Left-padded characters. If the length is not enough, specify a character. The default is space.
# rightpad: Right-padded characters. If the length is not enough, specify a character.
# config: Refer to the definition in other file.
# from: Refer to a definition file.
# use: Use instances defined in the referred file.
# select: If refer to an excel table, you can query a field in it.
# where: If refer to an excel table, you can use query conditions.
# Loop Definition
# Define the loop times of a field with a number, e.g. loop:2.
# Define the loop times of a field with an interval, e.g. loop:2-10.
# range definition
# Use commas to connect elements. e.g. range: 1,2,3.
# Elements can be a range, e.g. range:1-10, A-Z.
# Use colons to define steps, e.g. range:1-10:2.
# Steps can be decimals, e.g. range: 1-10:0.1.
# Steps can be negative, e.g. range: 9-1:-1
# Intervals can be set as random by R, e.g. range: 1-10:R. Set either random or a specified step.
# Use a file to specify a list, e.g. range: list.txt. If the file name is a relative path, it is based on the config file.
# Use {n} to repeat a element, e.g. range: user1{100},user2{100}.
# Use [], if intervals and elements are repeated, e.g. range: [user1,user2,user3]{100}, [1-100]{10}.
author: zentao
version: 1.0
fields:
- field: field_common # The list type by default. Separated by commas.
range: 1-10, 20-25, 27, 29, 30 # 1,2,3...,10,20,21,22...,25,27,29.30
prefix: int_ # Prefix
postfix: "\t" # Postfix
divider: "," # Divider between the fields, only works for text output format.
- field: field_step # Interval steps can be specified.
range: 1-10:2, 1-2:0.1,9-1:-1 # 1,3,5,7,9,1, 1.1,1.2...,2,9,8,7,...,1
postfix: "\t"
- field: field_random # Use R to specify randomly. Set either R or a specified step.
range: 1-10:R # 1,5,8...
postfix: "\t"
- field: field_loop # Self-loop field.
range: a-z # a_b_c | d_e_f | g_h_i
loop: 3 # Loop three times.
loopfix: _ # The connector for each loop.
postfix: "\t"
- field: field_repeat # Use {} to define repeated elements.
range: u-1{3},[u2,u3]{2},[1-3]{3} # u-1,u-1,u-1,u2,u2,u3,u3,1,1,1,2,2,2,3,3,3
postfix: "\t"
- field: field_format # Output as formatted strings.
range: 1-10 # passwd 1,passwd 2,passwd 3 ... passwd10。
format: "passwd%02d"
postfix: "\t"
- field: field_length # Fixed length field.
range: 1-99 # 01\t,02\t,03\t..., 99\t
length: 3 # the length in Byte including prefix and postfix.
leftpad: 0 # Using 0 to pad.
postfix: "\t"
- field: field_text # Read a list from a file and set it as random.
range: users.txt:R # Using the lines of users.txt as range and set it as random.
postfix: "\t"
- field: field_yaml # use another yaml file's data.
range: 01_range.yaml{3} # related path.
postfix: "\t"
- field: field_use_config # Other definition file can be referred.
config: number.yaml # Refer to the definition in number.yaml of the current directory.
postfix: "\t"
- field: field_use_ranges # Other definition file can be referred, in which more than one ranges are defined.
from: zentao.number.v1.yaml # Refer to the ranges in yaml/zentao/number/v1.yaml.
use: medium # use medium range.
postfix: "\t"
- field: field_use_instance # Refer to other definition file which defines multiple instances.
from: ip.v1.yaml # Refer to yaml/ip/v1.yaml.
use: privateB,privateC # Use the two instances of privateC and privateB defined in this file.
postfix: "\t"
- field: field_use_excel # Read the data from the data source of excel.
from: city.v1.city # Read the sheet named 'china' in data/address/cn.v1.xlsx.
select: name # Query the field city.
where: code = 532 # Query condition.
rand: true # Random for query
postfix: "\t"
- field: field_with_children # nested fields.
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: