sample.yaml 6.0 KB
Newer Older
1
title: zendata config syntax
aaronchen2k2k's avatar
aaronchen2k2k 已提交
2
desc:
aaronchen2k2k's avatar
aaronchen2k2k 已提交
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

  # 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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
42
    # use:      Use instances defined in the referred file.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
43 44
    # 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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
45

46
  # Loop Definition
aaronchen2k2k's avatar
aaronchen2k2k 已提交
47

48 49
    # 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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
50

aaronchen2k2k's avatar
aaronchen2k2k 已提交
51 52 53 54 55 56
  # 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.
57
    # Steps can be negative, e.g. range: 9-1:-1
aaronchen2k2k's avatar
aaronchen2k2k 已提交
58 59 60
    # 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}.
61
    # Use [], if intervals and elements are repeated, e.g. range: [user1,user2,user3]{100}, [1-100]{10}.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
62 63 64 65 66 67 68 69 70

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
aaronchen2k2k's avatar
aaronchen2k2k 已提交
71
    postfix: "\t"                       # Postfix
aaronchen2k2k's avatar
aaronchen2k2k 已提交
72
    divider: ","                        # Divider between the fields, only works for text output format.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
73

74 75
  - 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
aaronchen2k2k's avatar
aaronchen2k2k 已提交
76
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
77

78 79
  - field: field_random                 # Use R to specify randomly. Set either R or a specified step.
    range: 1-10:R                       # 1,5,8...
aaronchen2k2k's avatar
aaronchen2k2k 已提交
80
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
81 82 83 84 85

  - 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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
86
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
87 88

  - field: field_repeat                 # Use {} to define repeated elements.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
89
    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
aaronchen2k2k's avatar
aaronchen2k2k 已提交
90
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
91 92 93 94

  - field: field_format                 # Output as formatted strings.
    range: 1-10                         # passwd 1,passwd 2,passwd 3 ... passwd10。
    format: "passwd%02d"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
95
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
96

97
  - field: field_length                 # Fixed length field.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
98 99
    range: 1-99                         # 01\t,02\t,03\t..., 99\t
    length: 3                           # the length in Byte including prefix and postfix.
100
    leftpad: 0                          # Using 0 to pad.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
101 102 103 104 105 106 107
    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.
陈琦 已提交
108
    range: 01_range.yaml{3}             # related path.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
109
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
110

aaronchen2k2k's avatar
aaronchen2k2k 已提交
111
  - field: field_use_config             # Other definition file can be referred.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
112
    config: number.yaml                 # Refer to the definition in number.yaml of the current directory.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
113
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
114

aaronchen2k2k's avatar
aaronchen2k2k 已提交
115
  - field: field_use_ranges             # Other definition file can be referred, in which more than one ranges are defined.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
116
    from: zentao.number.v1.yaml         # Refer to the ranges in yaml/zentao/number/v1.yaml.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
117
    use: medium                         # use medium range.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
118
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
119 120

  - field: field_use_instance           # Refer to other definition file which defines multiple instances.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
121
    from: ip.v1.yaml                    # Refer to yaml/ip/v1.yaml.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
122
    use: privateB,privateC              # Use the two instances of privateC and privateB defined in this file.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
123
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
124 125

  - field: field_use_excel              # Read the data from the data source of excel.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
126 127 128
    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.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
129
    rand: true                          # Random for query
aaronchen2k2k's avatar
aaronchen2k2k 已提交
130
    postfix: "\t"
aaronchen2k2k's avatar
aaronchen2k2k 已提交
131

aaronchen2k2k's avatar
aaronchen2k2k 已提交
132
  - field: field_with_children          # nested fields.
aaronchen2k2k's avatar
aaronchen2k2k 已提交
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    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: