Skip to content

Commit 56b10fd

Browse files
authored
add monitor docker-compose and readme (#25)
* enhance jmeter variables * add metrics docker-compose * add p99 for summary output * list scenarios in cli * add influxdb to record k6 test result * add list scenarios readme * enhance doc * enhance data folder * fix influxdb default port
1 parent 9ae5536 commit 56b10fd

20 files changed

+1920
-19
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ trim_trailing_whitespace = false
1818

1919
[{*.js,*.j2}]
2020
indent_style = space
21+
indent_size = 2
22+
23+
[{*.yaml, *.yml}]
24+
indent_style = space
2125
indent_size = 2

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ mysql/data
2525
.env
2626
nebula-bench.db
2727
.vscode
28-
output
28+
output
29+
third/*/data

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ python3 run.py stress run
111111
# run all scenarios with 10 virtual users, every scenario lasts 3 seconds.
112112
python3 run.py stress run -vu 10 -d 3
113113

114+
# list all stress test scenarios
115+
python3 run.py stress scenarios
116+
114117
# run go.Go1Step scenarios with 10 virtual users, every scenario lasts 3 seconds.
115-
python3 run.py stress run -vu 10 -d 3 -s go.Go1Step
118+
python3 run.py stress run -vu 10 -d 3 -scenario go.Go1Step
116119
```
117120

118121
k6 config file, summary result and outputs are in `output` folder. e.g.

README_cn.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ python3 run.py stress run
103103
# run all scenarios with 10 virtual users, every scenario lasts 3 seconds.
104104
python3 run.py stress run -vu 10 -d 3
105105

106+
# list all stress test scenarios
107+
python3 run.py stress scenarios
108+
106109
# run go.Go1Step scenarios with 10 virtual users, every scenario lasts 3 seconds.
107-
python3 run.py stress run -vu 10 -d 3 -s go.Go1Step
110+
python3 run.py stress run -vu 10 -d 3 -scenario go.Go1Step
108111
```
109112

110113
k6 config file, summary result and outputs are in `output` folder. e.g.

env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
#NEBULA_PASSWORD=nebula
55
#NEBULA_ADDRESS=127.0.0.1:9669
66
#NEBULA_MAX_CONNECTION=100
7-
7+
#INFLUXDB_URL=http://192.168.8.60:8086/k6

nebula_bench/cli.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from nebula_bench.utils import logger
66
from nebula_bench.controller import NebulaController
77
from nebula_bench.utils import run_process
8-
from nebula_bench.stress import StressFactory
8+
from nebula_bench.stress import StressFactory, load_scenarios
99

1010

1111
SH_COMMAND = "/bin/bash"
@@ -136,7 +136,7 @@ def stress():
136136
@click.option(
137137
"-d", "--duration", default=60, help="duration for every scenario, unit: second, default: 60"
138138
)
139-
@click.option("-s", "--scenarioes", default="all", help="special scenarioes, e.g. go.Go1Step")
139+
@click.option("-scenario", default="all", help="run special scenario, e.g. go.Go1Step")
140140
@click.option("-c", "--controller", default="k6", help="using which test tool")
141141
@click.option(
142142
"--dry-run",
@@ -145,7 +145,7 @@ def stress():
145145
help="Dry run, just dump stress testing config file, default: False",
146146
)
147147
def run(
148-
folder, address, user, password, space, vid_type, scenarioes, controller, vu, duration, dry_run
148+
folder, address, user, password, space, vid_type, scenario, controller, vu, duration, dry_run
149149
):
150150
stress = StressFactory.gen_stress(
151151
_type=controller,
@@ -155,11 +155,22 @@ def run(
155155
password=password,
156156
space=space,
157157
vid_type=vid_type,
158-
scenarios=scenarioes,
158+
scenarios=scenario,
159159
vu=vu,
160160
duration=duration,
161161
dry_run=dry_run,
162162
)
163163
stress.run()
164164

165165
pass
166+
167+
168+
@stress.command()
169+
def scenarios():
170+
click.echo("All scenarios as below:")
171+
172+
scenarios = load_scenarios("all")
173+
for s in scenarios:
174+
module = s.__module__.split(".")[-1]
175+
name = s.__name__
176+
click.echo("\t{}.{}".format(module, name))

nebula_bench/setting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@
2727
NEBULA_MAX_CONNECTION = 400
2828

2929
SQLALCHEMY_URI = os.environ.get("SQLALCHEMY_URI") or "sqlite:///./nebula-bench.db"
30+
INFLUXDB_URL = os.environ.get("INFLUXDB_URL") or "http://127.0.0.1:8086/k6"

nebula_bench/stress.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@
33
import inspect
44
from pathlib import Path
55

6+
import click
7+
68
from nebula_bench.utils import load_class, jinja_dump, run_process
79
from nebula_bench.common.base import BaseScenario
810
from nebula_bench.utils import logger
911
from nebula_bench import setting
1012

1113

14+
def load_scenarios(scenarios):
15+
if scenarios.strip().upper() == "ALL":
16+
r = load_class("nebula_bench.scenarios", True, BaseScenario)
17+
else:
18+
r = load_class("nebula_bench.scenarios", False, BaseScenario, scenarios)
19+
20+
r = [x for x in r if x.abstract == False]
21+
return r
22+
23+
1224
class Stress(object):
1325
def __init__(
1426
self,
@@ -35,15 +47,7 @@ def __init__(
3547
self.vu = vu
3648
self.duration = duration
3749
self.dry_run = dry_run
38-
self.load_scenarios(scenarios)
39-
40-
def load_scenarios(self, scenarios):
41-
if scenarios.strip().upper() == "ALL":
42-
self.scenarios = load_class("nebula_bench.scenarios", True, BaseScenario)
43-
else:
44-
self.scenarios = load_class("nebula_bench.scenarios", False, BaseScenario, scenarios)
45-
46-
self.scenarios = [x for x in self.scenarios if x.abstract == False]
50+
self.scenarios = load_scenarios(scenarios)
4751
logger.info("total stress test scenarios is {}".format(len(self.scenarios)))
4852

4953
# dump config file
@@ -141,9 +145,15 @@ def run(self):
141145
str(self.vu),
142146
"-d",
143147
"{}s".format(self.duration),
148+
"--summary-trend-stats",
149+
"min,avg,med,max,p(90),p(95),p(99)",
150+
"--out",
151+
"influxdb={}".format(setting.INFLUXDB_URL),
144152
"--summary-export",
145153
"{}/result_{}.json".format(self.output_folder, scenario.name),
146154
]
155+
click.echo("run command as below:")
156+
click.echo(" ".join(command))
147157
if self.dry_run is not None and self.dry_run:
148158
continue
149159
run_process(command)

third/exporter/docker-compose.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
version: '3.7'
3+
4+
5+
services:
6+
node-exporter:
7+
image: prom/node-exporter
8+
volumes:
9+
- /proc:/host/proc:ro
10+
- /sys:/host/sys:ro
11+
- /:/rootfs:ro
12+
command:
13+
- '--path.procfs=/host/proc'
14+
- '--path.sysfs=/host/sys'
15+
- --collector.filesystem.ignored-mount-points
16+
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
17+
network_mode: host
18+
restart: always
19+
20+
process-exporter:
21+
image: ncabatoff/process-exporter
22+
volumes:
23+
- /proc:/host/proc
24+
- ./filename.yml:/config/filename.yml
25+
command:
26+
- --procfs
27+
- /host/proc
28+
- -config.path
29+
- /config/filename.yml
30+
31+
network_mode: host
32+
33+
34+
restart: always
35+
privileged: true

third/exporter/filename.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
process_names:
2+
- name: "qa-61-{{.Comm}}"
3+
comm:
4+
- nebula-metad
5+
- nebula-storaged
6+
- nebula-graphd

0 commit comments

Comments
 (0)