Skip to content

Commit 849d5d1

Browse files
authored
docs: add examples of job and template (#674)
* docs: add examples of job and template * Update grpc-manual.md Signed-off-by: Rick <[email protected]> --------- Signed-off-by: Rick <[email protected]> Co-authored-by: rick <[email protected]>
1 parent 403545f commit 849d5d1

File tree

9 files changed

+57
-8
lines changed

9 files changed

+57
-8
lines changed

docs/site/content/zh/latest/tasks/code-generator.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "代码生成"
3+
weight = 103
34
+++
45

56
`atest` 支持把测试用例生成多种开发语言的代码:

docs/site/content/zh/latest/tasks/extension.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
+++
22
title = "插件"
3+
weight = 900
34
+++
45

56
`atest` 会把非核心、可扩展的功能以插件(extension)的形式实现。下面介绍有哪些插件,以及如何使用:
67

78
> 在不同的系统中,插件有着不同的表述,例如:extension、plugin 等。
89
9-
| 类型 | 名称 | 描述 |
10-
|------|------|------|
11-
| 存储 | [orm](https://github.com/LinuxSuRen/atest-ext-store-orm) | 保存数据到关系型数据库中,例如:MySQL |
12-
| 存储 | [s3](https://github.com/LinuxSuRen/atest-ext-store-s3) | 保存数据到对象存储中 |
13-
| 存储 | [etcd](https://github.com/LinuxSuRen/atest-ext-store-etcd) | 保存数据到 Etcd 数据库中 |
14-
| 存储 | [git](https://github.com/LinuxSuRen/atest-ext-store-git) | 保存数据到 Git 仓库中 |
15-
| 存储 | [mongodb](https://github.com/LinuxSuRen/atest-ext-store-mongodb) | 保存数据到 MongDB 中 |
10+
| 类型 | 名称 | 描述 |
11+
|-------|------|----------------------------------|
12+
| 存储 | [orm](https://github.com/LinuxSuRen/atest-ext-store-orm) | 保存数据到关系型数据库中,例如:MySQL、Postgres 等 |
13+
| 存储 | [mongodb](https://github.com/LinuxSuRen/atest-ext-store-mongodb) | 保存数据到 MongDB 中 |
14+
| 存储 | [etcd](https://github.com/LinuxSuRen/atest-ext-store-etcd) | 保存数据到 Etcd 数据库中 |
15+
| 存储 | [iotdb](https://github.com/LinuxSuRen/atest-ext-store-iotdb) | 支持通过 Web UI 查询 IoTDB 数据 |
16+
| 存储 | [Cassandra](https://github.com/LinuxSuRen/atest-ext-store-cassandra) | 支持通过 Web UI 查询 Cassandra 数据 |
17+
| 存储 | [Elasticsearch](https://github.com/LinuxSuRen/atest-ext-store-elasticsearch) | 支持通过 Web UI 查询 Elasticsearch 数据 |
18+
| 存储 | [redis](https://github.com/LinuxSuRen/atest-ext-store-redis) | |
19+
| 存储 | [s3](https://github.com/LinuxSuRen/atest-ext-store-s3) | 保存数据到对象存储中 |
20+
| 存储 | [git](https://github.com/LinuxSuRen/atest-ext-store-git) | 保存数据到 Git 仓库中 |
21+
| 数据 | [Swagger](https://github.com/LinuxSuRen/atest-ext-data-swagger) | |
1622

1723
> `atest` 也是唯一支持如此丰富的存储的接口开发、测试的开源工具。
1824

docs/site/content/zh/latest/tasks/grpc-TLS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "gRPC TLS verification"
3+
weight = 201
34
+++
45

56
If you want to enable gRPC TLS, you need to generate your certificates in the workspace, or you can use an absolute path

docs/site/content/zh/latest/tasks/grpc-manual.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "gRPC测试用例编写指南"
3+
weight = 200
34
+++
45

56
本文档将介绍如何编写`api-testing`的 gRPC API 的测试用例。
@@ -117,4 +118,4 @@ expect:
117118

118119
请注意,对于服务端流和双向流模式,服务器发送多条消息的情况下,此处的`data`字段内的填写的目标数组,需同时满足与待验证数组长度相,两个数组同一下标的内容完全相同。
119120

120-
`gRPC API``verify`功能与`HTTP API`保持一致,此处不再赘述。
121+
`gRPC API` `verify` 功能与 `HTTP API` 保持一致,此处不再赘述。
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
+++
2+
title = "任务"
3+
weight = 101
4+
+++
5+
6+
在特定情况下,执行接口测试用例前需要执行相应的任务,例如:数据初始化、等待服务就绪等等。 `atest` 的任务功能,就是为了满足这类场景而设计的。
7+
8+
> 任务的执行引擎为 [expr](https://expr.medv.io),如果当前页面给出的示例无法满足你的需求,可以查阅相关的官方文档。
9+
10+
## 等待接口响应码为 200
11+
12+
以下的例子会每隔一秒请求一次指定的接口,并检查响应码(Status Code)是否为 200,如果不是的话,则最多会重试 3 次:
13+
14+
```yaml
15+
name: demo
16+
api: http://localhost
17+
items:
18+
- name: login
19+
before:
20+
items:
21+
- httpReady("http://localhost/health", 3)
22+
request:
23+
api: /demo
24+
```
25+
26+
如果希望检查响应体的话,则可以用下面的表达式:
27+
28+
```
29+
httpReady("http://localhost:17001/actuator/health", 3, 'components.discoveryComposite.components.eureka.details.applications["AUTH"] == 1')
30+
```

docs/site/content/zh/latest/tasks/mock.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "Mock 服务"
3+
weight = 104
34
+++
45

56
Mock 服务在前后端并行开发、系统对接、设备对接场景下能起到非常好的作用,可以极大地降低团队之间、系统之间的耦合度。

docs/site/content/zh/latest/tasks/secure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "关于安全"
3+
weight = 8
34
+++
45

56
通常在不使用 TLS 证书认证时,gRPC 客户端与服务端之间进行的是明文通信,信息易被第三方监听或篡改。所以大多数情况下均推荐使用 SSL/TLS 保护 gRPC 服务。目前`atest`已实现服务端 TLS,双向 TLS(mTLS) 需等待后续实现。

docs/site/content/zh/latest/tasks/template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "用例模板"
3+
weight = 100
34
+++
45

56
`atest` 采用 [sprig](https://masterminds.github.io/sprig/) 作为测试用例的模板引擎。通过模板函数可以生成很多随机数据:
@@ -28,6 +29,12 @@ title = "用例模板"
2829
{{ now.Format "2006-01-02T15:04:05Z07:00" }}
2930
```
3031

32+
如果想要获取其他时间,则可以参考如下写法:
33+
34+
```gotemplate
35+
{{(now | date_modify "2h") | date "2006-01-02T15:04:05"}}
36+
```
37+
3138
## 环境变量
3239

3340
下面的代码可以获取环境变量 `SHELL` 的值,在需要使用一个全局变量的时候,可以使用这个模板函数:

docs/site/content/zh/latest/tasks/verify.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
+++
22
title = "测试用例验证"
3+
weight = 102
34
+++
45

56
`atest` 采用 https://expr.medv.io 对 HTTP 请求响应的验证,比如:返回的数据列表长度验证、具体值的验证等等。下面给出一些例子:

0 commit comments

Comments
 (0)