Skip to content

并发测试如何记录返回结果 #372

@YRXING

Description

@YRXING

General Question

我想在自定义并发测试的Loop中BindJSON,但是好像没有数据

	createResp := api_model.CreateObjRespData{} // 响应体
	logs.Infof("Begin  benchmark....")
	Ids = make([]string, C.Number)
	filter.NewBench().
		Concurrent(C.Concurrent).Number(C.Number).
		Loop(func(c *dataflow.Context) error {
			c.GET(C.Url + "/api/v1/CreateObj").
				SetQuery(NewCreateObjReq()).SetHeader(gout.H{
				"x-jwt-token": token,
			}).BindJSON(&createResp)
			logs.Infof("createResp %+v", createResp) // 打印位置1
		        Ids = append(Ids, createResp.Id)
			return nil
		}).Do()
	logs.Infof("Resp----%+v", createResp) // 打印位置2

示例代码如上,我想把请求返回的数据ID记录下来,不管是在位置1还是位置2都是空的,哪怕我在Loop函数里面执行c.Get.Do()也不行。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions