README.md 3.1 KB
Newer Older
B
Bomin Zhang 已提交
1 2
# STRESS

B
Bomin Zhang 已提交
3 4 5 6
Stress test tool for TDengine. It run a set of test cases randomly and show statistics.

## COMMAND LINE

B
Bomin Zhang 已提交
7
``` bash
B
Bomin Zhang 已提交
8
$ ./stress [-h=<localhost>] [-P=<0>] [-d=<test>] [-u=<root>] [-p=<taosdata>] [-c=<4>] [-f=<true>] [-l=<logPath>] [path_or_sql]
B
Bomin Zhang 已提交
9 10
```

B
Bomin Zhang 已提交
11 12 13 14 15 16
* **-h**: host name or IP address of TDengine server (default: localhost).
* **-P**: port number of TDengine server (default: 0).
* **-u**: user name (default: root).
* **-p**: password (default: taosdata).
* **-c**: concurrency, number of concurrent goroutines for query (default: 4).
* **-f**: fetch data or not (default: true).
B
Bomin Zhang 已提交
17
* **-l**: log file path (default: no log).
18
* **path_or_sql**: a SQL statement or path of a JSON file which contains the test cases (default: cases.json).
B
Bomin Zhang 已提交
19 20

## TEST CASE FILE
B
Bomin Zhang 已提交
21 22 23

```json
[{
B
Bomin Zhang 已提交
24 25
    "weight": 1,
    "sql": "select * from meters where ts>=now+%dm and ts<=now-%dm and c1=%v and c2=%d and c3='%s' and tbname='%s'",
B
Bomin Zhang 已提交
26 27 28 29
    "args": [{
        "type": "range",
        "min": 30,
        "max": 60
B
Bomin Zhang 已提交
30 31 32 33 34 35
    }, {
        "type": "bool"
    }, {
        "type": "int",
        "min": -10,
        "max": 20
B
Bomin Zhang 已提交
36 37 38 39
    }, {
        "type": "string",
        "min": 0,
        "max": 10,
B
Bomin Zhang 已提交
40 41
    }, {
        "type": "list",
B
Bomin Zhang 已提交
42 43 44 45 46 47 48 49
        "list": [
            "table1",
            "table2",
            "table3",
            "table4"
        ]
    }]
}]
B
Bomin Zhang 已提交
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
```

The test case file is a standard JSON file which contains an array of test cases. For test cases, field `sql` is mandatory, and it can optionally include a `weight` field and an `args` field which is an array of arguments.

`sql` is a SQL statement, it can include zero or more arguments (placeholders).

`weight` defines the possibility of the case being selected, the greater value the higher possibility. It must be an non-negative integer and the default value is zero, but, if all cases have a zero weight, all the weights are regarded as 1. 

Placeholders of `sql` are replaced by arguments in `args` at runtime. There are 5 types of arguments currently:

* **bool**: generate a `boolean` value randomly.
* **int**: generate an `integer` between [`min`, `max`] randomly, the default value of `min` is 0 and `max` is 100.
* **range**: generate two `integer`s between [`min`, `max`] randomly, the first is less than the second, the default value of `min` is 0 and `max` is 100.
* **string**: generate a `string` with length between [`min`, `max`] randomly, the default value of `min` is 0 and `max` is 100.
* **list**: select an item from `list` randomly.

## OUTPUT

```
 00:00:08 | TOTAL REQ | TOTAL TIME(us) | TOTAL AVG(us) | REQUEST |  TIME(us)  |  AVERAGE(us)  |
    TOTAL |      3027 |       26183890 |       8650.11 |     287 |    3060935 |      10665.28 |
  SUCCESS |      3027 |       26183890 |       8650.11 |     287 |    3060935 |      10665.28 |
     FAIL |         0 |              0 |          0.00 |       0 |          0 |          0.00 |
```

* **Col 2**: total number of request since test start.
* **Col 3**: total time of all request since test start.
* **Col 4**: average time of all request since test start.
* **Col 5**: number of request in last second.
* **Col 6**: time of all request in last second.
* **Col 7**: average time of all request in last second.