Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ws_log_file, conf_template, proxy_port, \
workers
import os
import time
mkdir_cmd = local["mkdir"]["-p"]
def getLinkFilename(link):
return link.split("#")[0].split("/")[-1]
def getLinkDir(link):
if "#" in link:
return os.path.join(ngx_dir, link.split("#")[1])
return os.path.join(ngx_dir, getLinkFilename(link).replace(".tar.gz", ""))
if local.cwd.split("/")[-1]!= "ngx_http_websocket_stat_module":
print("this script is supposed to be run from repo root dir")
exit(1)
this_dir = "../.."
wget_cmd = local["wget"]
untar_cmd = local["tar"]["xz", "-C", ngx_dir, "-f"]
files_cmd = local["ls"][download_dir]
make_cmd = local["make"]["-j4"]
rm_cmd = local["rm"]["-rf"]
nginx_dir = getLinkDir(links["nginx"])
nginx_cmd = local[os.path.join(nginx_dir, "objs/nginx")]["-p", ngx_dir, "-c", conf_file]
def download(links):
mkdir_cmd(download_dir)
for lib in links:
temp = setup_temp_dir()
# Generate IP addresses to be used by the nodes we will create.
ips = generate_ips()
# Create a standalone Redis node.
standalone_redis_ip = next(ips)
standalone_redis = RedisNode(standalone_redis_ip, REDIS_PORT)
# Create a Dynomite cluster.
dynomite_cluster = DynoCluster(args.request_file, ips)
with ExitStack() as stack:
# Make sure to change the working directory to the temp dir before running the
# tests.
stack.enter_context(local.cwd(temp))
# Launch the standalone Redis node and the dynomite cluster.
stack.enter_context(standalone_redis)
stack.enter_context(dynomite_cluster)
# Wait for a while for the above nodes to start.
sleep_with_animation(SETTLE_TIME, "Waiting for cluster to start")
# Run all the functional comparison tests.
comparison_test(standalone_redis, dynomite_cluster, False)
random_node = random.choice(dynomite_cluster.nodes)
stats_url = 'http://{}:{}/info'.format(random_node.ip, STATS_PORT)
json.loads(urlopen(stats_url).read().decode('ascii'))
def make(links):
for lib in links:
if lib.startswith("nginx"):
continue
filename = getLinkFilename(links[lib])
directory = getLinkDir(links[lib])
local.cwd.chdir(directory)
print("compiling {}".format(directory))
if lib == "openssl":
local["./config"]()
else:
local["./configure"]()
make_cmd()
local.cwd.chdir(this_dir)
'tests against it')
parser.add_argument('request_file', default='test/safe_quorum_request.yaml',
help='YAML file describing desired cluster', nargs='?')
args = parser.parse_args()
# Setup a temporary directory to store logs and configs for this cluster.
temp = setup_temp_dir()
# Generate IP addresses to be used by the nodes we will create.
ips = generate_ips()
# Create a Dynomite cluster.
dynomite_cluster = DynoCluster(args.request_file, ips)
# Make sure to change the working directory to the temp dir.
with local.cwd(temp):
# Launch the dynomite cluster.
dynomite_cluster.launch()
# Wait for a while for the above nodes to start.
sleep_with_animation(SETTLE_TIME, "Waiting for cluster to start")
def test_isort(src_dir):
"""Run Isort."""
isort = plumbum.local["isort"]
with plumbum.local.cwd(PROJECT_ROOT_DIR):
result = isort("--check-only", "-rc", src_dir)
if result:
print("\nIsort:", result)
conn_obj = dbus.Interface(
self.dbus_con.get_object("org.freedesktop.NetworkManager", active_con1),
dbusmock.MOCK_IFACE,
)
conn_obj.AddProperty(
'org.freedesktop.NetworkManager.Connection.Active',
'Dhcp4Config',
'/org/freedesktop/NetworkManager/DHCP4Config/1',
)
# for inspecting the resulting dbus objects
# with plumbum.local.env(DBUS_SYSTEM_BUS_ADDRESS=os.environ['DBUS_SYSTEM_BUS_ADDRESS']):
# gdbus["introspect", "--system", "--recurse", "-d", "org.freedesktop.NetworkManager", "-o", "/"] & FG
# server for wpad.dat
with plumbum.local.cwd(testdir / "wpadserver"):
static_server = python["-m", "http.server", 8080] & BG
# mock upstream proxies
fake_proxy_1 = (serve_once[23130] < testdir / "fake-proxy-1-response") & BG
fake_proxy_2 = (serve_once[23131] < testdir / "fake-proxy-2-response") & BG
# proxy getting its config from DHCP
with plumbum.local.env(DBUS_SYSTEM_BUS_ADDRESS=os.environ['DBUS_SYSTEM_BUS_ADDRESS']):
proxy_to_test = pac4cli["-p", "23129"] & BG(stdout=sys.stdout, stderr=sys.stderr)
sleep(3)
try:
with plumbum.local.env(http_proxy="localhost:23129"):
self.assertEqual(
curl("http://www.booking.com"),
# when changing this string, don't forget to change
def _get_cluster_desc_yaml(self):
yaml_desc = dict(test_dir=str(local.cwd))
cluster_desc = [dict(name='dyno_nodes')]
cluster_desc.append(dict(name='redis_nodes'))
cluster_desc[0]['pids']=[]
cluster_desc[1]['pids']=[]
for node in self.nodes:
cluster_desc[0]['pids'].append(node.get_dyno_node_pid())
cluster_desc[1]['pids'].append(node.get_storage_node_pid())
yaml_desc['cluster_desc'] = cluster_desc
return yaml_desc
def test(filename, *args):
command = local[LOCAL_DIR / filename / filename]
command = command['--nosplash']
for arg in args:
command = command[arg]
colors.info.print('Running', command)
with local.cwd(LOCAL_DIR / filename):
with Timer() as t:
code, stdout, stderr = command & TEE(retcode=None)
if code==0:
colors.success.print(filename, 'Successful')
else:
colors.fatal.print(filename, 'Failed with status code:', code)
return dict(name=filename+' '+' '.join(map(str,args)), code=code, time=t.interval, stdout=stdout, stderr=stderr)
def get_output_cmd(command, minion_path):
with local.cwd(minion_path):
return check_output("vagrant ssh -c \"{0}\"".format(command), shell=True)
def main(self):
with local.cwd(DIR / "../cmake"):
for f in FILES:
download_file(f)