---
title: 执行ESRally测试
description: "1. 修改“challenges/default.json”文件。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengbds/testguide/tstg/kunpengbdsest_11_0004.html
sourcePath: /source/zh/kunpengbds/testguide/tstg/kunpengbdsest_11_0004.html
indexId: 73565c6bea8b5c11a8eb296cf2ed40da0655e2dfdbdfd0a9e62531b38193409863
---
# 执行ESRally测试

1. 修改“challenges/default.json”文件。

  a. 打开文件。
    1 vi ~/.rally/benchmarks/tracks/default/geonames/challenges/default.json

    由于测试中的default查询文档项目波动较大，测试前需要删除该项目。

  b. 按“i”进入编辑模式，删除文件中如下代码。

```
{
"operation": "default",
"clients": 200,
"warmup-iterations": 500,
"iterations": 1000,
"target-throughput": 7000
},
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
2. 修改“operations/default.json”文件。

  a. 打开文件。
    1 vi ~/.rally/benchmarks/tracks/default/geonames/operations/default.json

  b. 按“i”进入编辑模式，修改如下内容。
由于官方默认的测试用例配置在term、phrase和country_agg_cached，3个用例下不能发挥鲲鹏处理器的最大性能，故对term、phrase的查询条件和country_agg_cached的查询size进行调整。


    - term修改后如下。

```
{
"name": "term",
"operation-type": "search",
"body": {
"query": {
"term": {
"country_code": "us"
}
}
}
},
```


    - phrase修改后如下所示。

```
{
"name": "phrase",
"operation-type": "search",
"body": {
"query": {
"match_phrase": {
"country_code": "us"
}
}
}
},
```


    - country_agg_cached修改后如下所示。

```
{
"name": "country_agg_cached",
"operation-type": "search",
"cache": true,
"body": {
"size": 1000,
"aggs": {
"country_population": {
"terms": {
"field": "country_code"
},
"aggs": {
"sum_population": {
"sum": {
"field": "population"
}
}
}
}
}
}
}
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
3. 修改配置文件“~/.rally/benchmarks/tracks/default/geonames/challenges/default.json”中的各个用例的clients数和target-throughput数达到最佳性能。

  a. 打开配置文件。
    1 vi ~/.rally/benchmarks/tracks/default/geonames/challenges/default.json

  b. 以term用例为例进行说明，按“i”进入编辑模式，修改配置文件如下所示。

```
{
"operation": "term",
"clients": 200,
"warmup-iterations": 500,
"iterations": 1000,
"target-throughput": 60000
},
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
4. 执行测试脚本。
  1 2 cd esrally-test-tools/bin bin/run_test.sh
