Skip to content

Commit

Permalink
add monitor docker-compose and readme (nebula-contrib#25)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HarrisChu authored Jul 22, 2021
1 parent 275a08e commit 80c86cd
Show file tree
Hide file tree
Showing 20 changed files with 1,920 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ trim_trailing_whitespace = false

[{*.js,*.j2}]
indent_style = space
indent_size = 2

[{*.yaml, *.yml}]
indent_style = space
indent_size = 2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ mysql/data
.env
nebula-bench.db
.vscode
output
output
third/*/data
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ python3 run.py stress run
# run all scenarios with 10 virtual users, every scenario lasts 3 seconds.
python3 run.py stress run -vu 10 -d 3

# list all stress test scenarios
python3 run.py stress scenarios

# run go.Go1Step scenarios with 10 virtual users, every scenario lasts 3 seconds.
python3 run.py stress run -vu 10 -d 3 -s go.Go1Step
python3 run.py stress run -vu 10 -d 3 -scenario go.Go1Step
```

k6 config file, summary result and outputs are in `output` folder. e.g.
Expand Down
5 changes: 4 additions & 1 deletion README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ python3 run.py stress run
# run all scenarios with 10 virtual users, every scenario lasts 3 seconds.
python3 run.py stress run -vu 10 -d 3

# list all stress test scenarios
python3 run.py stress scenarios

# run go.Go1Step scenarios with 10 virtual users, every scenario lasts 3 seconds.
python3 run.py stress run -vu 10 -d 3 -s go.Go1Step
python3 run.py stress run -vu 10 -d 3 -scenario go.Go1Step
```

k6 config file, summary result and outputs are in `output` folder. e.g.
Expand Down
2 changes: 1 addition & 1 deletion env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
#NEBULA_PASSWORD=nebula
#NEBULA_ADDRESS=127.0.0.1:9669
#NEBULA_MAX_CONNECTION=100

#INFLUXDB_URL=http://192.168.8.60:8086/k6
19 changes: 15 additions & 4 deletions nebula_bench/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nebula_bench.utils import logger
from nebula_bench.controller import NebulaController
from nebula_bench.utils import run_process
from nebula_bench.stress import StressFactory
from nebula_bench.stress import StressFactory, load_scenarios


SH_COMMAND = "/bin/bash"
Expand Down Expand Up @@ -136,7 +136,7 @@ def stress():
@click.option(
"-d", "--duration", default=60, help="duration for every scenario, unit: second, default: 60"
)
@click.option("-s", "--scenarioes", default="all", help="special scenarioes, e.g. go.Go1Step")
@click.option("-scenario", default="all", help="run special scenario, e.g. go.Go1Step")
@click.option("-c", "--controller", default="k6", help="using which test tool")
@click.option(
"--dry-run",
Expand All @@ -145,7 +145,7 @@ def stress():
help="Dry run, just dump stress testing config file, default: False",
)
def run(
folder, address, user, password, space, vid_type, scenarioes, controller, vu, duration, dry_run
folder, address, user, password, space, vid_type, scenario, controller, vu, duration, dry_run
):
stress = StressFactory.gen_stress(
_type=controller,
Expand All @@ -155,11 +155,22 @@ def run(
password=password,
space=space,
vid_type=vid_type,
scenarios=scenarioes,
scenarios=scenario,
vu=vu,
duration=duration,
dry_run=dry_run,
)
stress.run()

pass


@stress.command()
def scenarios():
click.echo("All scenarios as below:")

scenarios = load_scenarios("all")
for s in scenarios:
module = s.__module__.split(".")[-1]
name = s.__name__
click.echo("\t{}.{}".format(module, name))
1 change: 1 addition & 0 deletions nebula_bench/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
NEBULA_MAX_CONNECTION = 400

SQLALCHEMY_URI = os.environ.get("SQLALCHEMY_URI") or "sqlite:///./nebula-bench.db"
INFLUXDB_URL = os.environ.get("INFLUXDB_URL") or "http://127.0.0.1:8086/k6"
28 changes: 19 additions & 9 deletions nebula_bench/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@
import inspect
from pathlib import Path

import click

from nebula_bench.utils import load_class, jinja_dump, run_process
from nebula_bench.common.base import BaseScenario
from nebula_bench.utils import logger
from nebula_bench import setting


def load_scenarios(scenarios):
if scenarios.strip().upper() == "ALL":
r = load_class("nebula_bench.scenarios", True, BaseScenario)
else:
r = load_class("nebula_bench.scenarios", False, BaseScenario, scenarios)

r = [x for x in r if x.abstract == False]
return r


class Stress(object):
def __init__(
self,
Expand All @@ -35,15 +47,7 @@ def __init__(
self.vu = vu
self.duration = duration
self.dry_run = dry_run
self.load_scenarios(scenarios)

def load_scenarios(self, scenarios):
if scenarios.strip().upper() == "ALL":
self.scenarios = load_class("nebula_bench.scenarios", True, BaseScenario)
else:
self.scenarios = load_class("nebula_bench.scenarios", False, BaseScenario, scenarios)

self.scenarios = [x for x in self.scenarios if x.abstract == False]
self.scenarios = load_scenarios(scenarios)
logger.info("total stress test scenarios is {}".format(len(self.scenarios)))

# dump config file
Expand Down Expand Up @@ -141,9 +145,15 @@ def run(self):
str(self.vu),
"-d",
"{}s".format(self.duration),
"--summary-trend-stats",
"min,avg,med,max,p(90),p(95),p(99)",
"--out",
"influxdb={}".format(setting.INFLUXDB_URL),
"--summary-export",
"{}/result_{}.json".format(self.output_folder, scenario.name),
]
click.echo("run command as below:")
click.echo(" ".join(command))
if self.dry_run is not None and self.dry_run:
continue
run_process(command)
35 changes: 35 additions & 0 deletions third/exporter/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

version: '3.7'


services:
node-exporter:
image: prom/node-exporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- --collector.filesystem.ignored-mount-points
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
network_mode: host
restart: always

process-exporter:
image: ncabatoff/process-exporter
volumes:
- /proc:/host/proc
- ./filename.yml:/config/filename.yml
command:
- --procfs
- /host/proc
- -config.path
- /config/filename.yml

network_mode: host


restart: always
privileged: true
6 changes: 6 additions & 0 deletions third/exporter/filename.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process_names:
- name: "qa-61-{{.Comm}}"
comm:
- nebula-metad
- nebula-storaged
- nebula-graphd
Binary file added third/images/k6_result_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added third/images/node_exporter_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added third/images/node_exporter_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added third/images/process_exporter_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions mysql/docker-compose.yaml → third/mysql/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: '3.4'
services:
mysql:
image: mysql:5.6
ports:
- 3306:3306
# ports:
# - 3306:3306
environment:
- MYSQL_ROOT_PASSWORD=admin
- TZ=Asiz/Shanghai
Expand All @@ -12,3 +12,4 @@ services:
- ./mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf:rw
- ./data:/var/lib/mysql

network_mode: host
File renamed without changes.
58 changes: 58 additions & 0 deletions third/promethues/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

version: '3.7'


networks:
monitor:

services:
prometheus:
image: prom/prometheus:v2.1.0
user: root
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- ./data/prometheus:/prometheus:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--storage.tsdb.retention=15d'
ports:
- 9090:9090
# links:
# - alertmanager:alertmanager
# depends_on:
networks:
- monitor
restart: always

grafana:
image: grafana/grafana
user: root
depends_on:
- prometheus
ports:
- 3000:3000

networks:
- monitor
restart: always

volumes:
- ./data/grafana:/var/lib/grafana:rw


influxdb:
image: influxdb:1.8
container_name: influxdb
ports:
- "8086:8086"
- "8083:8083"
environment:
- INFLUXDB_DATA_ENGINE=tsm1
- INFLUXDB_DB=k6

volumes:
# Data persistency
- ./data/influxdb:/var/lib/influxdb
Loading

0 comments on commit 80c86cd

Please sign in to comment.