Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offline package #29

Merged
merged 1 commit into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to go back to the directory where the user executed the command

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cd is used in shell context, it won't impact original user workspace.
just like sh -c 'cd code;echo $PWD'.

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.