Skip to content

Commit

Permalink
offline package (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisChu authored Aug 2, 2021
1 parent 9837690 commit 51ade28
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ nebula-bench.db
output
third/*/data
scripts/k6
scripts/nebula-importer
scripts/nebula-importer

dist
build
43 changes: 43 additions & 0 deletions nebula-bench.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None
PATH = os.getcwd()


a = Analysis(['run.py'],
pathex=[PATH],
binaries=[],
datas=[
(os.path.join(PATH, 'scripts'), 'scripts'),
(os.path.join(PATH, 'templates'), 'templates'),
(os.path.join(PATH, 'env'), '.'),
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='nebula-bench',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='nebula-bench')
2 changes: 2 additions & 0 deletions nebula_bench/scenarios/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from nebula_bench.scenarios import go
from nebula_bench.scenarios import find_path
2 changes: 1 addition & 1 deletion nebula_bench/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +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"
INFLUXDB_URL = os.environ.get("INFLUXDB_URL", None)
6 changes: 4 additions & 2 deletions nebula_bench/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ def run(self):
"{}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),
]
if setting.INFLUXDB_URL is not None:
command.append("--out")
command.append("influxdb={}".format(setting.INFLUXDB_URL))

click.echo("run command as below:")
click.echo(" ".join(command))
if self.dry_run is not None and self.dry_run:
Expand Down
22 changes: 8 additions & 14 deletions nebula_bench/utils.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# -*- coding: utf-8 -*-
import os
import subprocess
import inspect
import importlib
from pathlib import Path
import socket
import json
import logging
import base64
import hashlib
import hmac
import time
import urllib

import jinja2
import click
Expand All @@ -22,15 +16,15 @@ def load_class(package_name, load_all, base_class, class_name=None):
r = []
if load_all:
_package = importlib.import_module(package_name)
for namespace_p in _package.__path__:
p = Path(namespace_p)
break
for _module_path in p.iterdir():
name = _module_path.name.rsplit(".", 1)[0]
_module = importlib.import_module(package_name + "." + name)
for attr in dir(_package):
_module = getattr(_package, attr)
if not inspect.ismodule(_module):
continue

# _module = importlib.import_module(package_name + "." + name)
for name in dir(_module):
_class = getattr(_module, name)
if not isinstance(_class, type):
if not inspect.isclass(_class):
continue
if issubclass(_class, base_class) and _class.__name__ != base_class.__name__:
r.append(_class)
Expand Down
16 changes: 16 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

set -e

pip3 install --user -r requirements.txt
pip3 install --user -r requirements_dev.txt

# compile go tools
/bin/bash scripts/setup.sh

# package python code
pyinstaller -D nebula-bench.spec

# tar
cd dist
tar zcvf nebula-bench.tgz nebula-bench/*
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Jinja2 == 2.11.3
click == 7.1.2
Jinja2
click
nebula2-python == 2.0.0
python-dotenv == 0.16.0
locust
pymysql
python-dotenv
pyinstaller
wheel
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest == 6.2.2
black == 21.5b
pytest
black == 21.5b
1 change: 1 addition & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from nebula_bench.scenarios import *
from nebula_bench import cli

if __name__ == "__main__":
Expand Down
Empty file modified scripts/env.sh
100644 → 100755
Empty file.
Empty file modified scripts/generate-data.sh
100644 → 100755
Empty file.
Empty file modified scripts/setup.sh
100644 → 100755
Empty file.
Empty file modified scripts/split-data.sh
100644 → 100755
Empty file.

0 comments on commit 51ade28

Please sign in to comment.