def main() -> None: desc = scratch.MachineDesc( name="chbench monthly", launch_script="MZ_WORKERS=4 bin/mzcompose --mz-find chbench run cloud-load-test", instance_type="r5ad.4xlarge", ami="ami-0b29b6e62f2343b46", tags={ "scrape_benchmark_numbers": "true", "lt_name": "monthly-chbench", "purpose": "load_test_monthly", "mzconduct_workflow": "cloud-load-test", "test": "chbench", "environment": "scratch", }, size_gb=64, ) now = datetime.datetime.utcnow() scratch.launch_cluster( [desc], now.replace(tzinfo=datetime.timezone.utc).isoformat(), DEFAULT_SUBNET_ID, None, DEFAULT_SG_ID, DEFAULT_INSTPROF_NAME, {}, # Keep alive for at least a day int(datetime.datetime.now(datetime.timezone.utc).timestamp()) + 3600 * 24, "HEAD", {}, )
def main() -> None: desc = scratch.MachineDesc( name="chbench monthly", launch_script="MZ_WORKERS=4 bin/mzcompose --preserve-ports --find chbench run load-test", instance_type="r5ad.4xlarge", ami="ami-0b29b6e62f2343b46", tags={ "scrape_benchmark_numbers": "true", "lt_name": "monthly-chbench", "purpose": "load_test_monthly", "mzconduct_workflow": "load-test", "test": "chbench", "environment": "scratch", }, size_gb=64, ) now = datetime.datetime.utcnow() scratch.launch_cluster( [desc], nonce=now.replace(tzinfo=datetime.timezone.utc).isoformat(), # Keep alive for at least a day. delete_after=datetime.datetime.utcnow() + datetime.timedelta(days=1), )
def start(ns: argparse.Namespace) -> None: check_required_vars() revs = ns.revs.split(",") clusters = list( itertools.product(range(ns.trials), (git.rev_parse(rev) for rev in revs))) bench_script = ns.bench_script script_name = bench_script[0] script_args = " ".join((shlex.quote(arg) for arg in bench_script[1:])) # zip up the `misc` repository, for shipment to the remote machine os.chdir("misc/python") spawn.runv(["python3", "./setup.py", "sdist"]) with open("./dist/materialize-0.0.0.tar.gz", "rb") as f: pkg_data = f.read() os.chdir(os.environ["MZ_ROOT"]) if ns.append_metadata: munge_result = 'awk \'{ if (NR == 1) { print $0 ",Timestamp,BenchId,ClusterId,GitRef,S3Root" } else { print $0 ",\'$(date +%s)",$MZ_CB_BENCH_ID,$MZ_CB_CLUSTER_ID,$MZ_CB_GIT_REV,$MZ_CB_S3_ROOT"\'"}}\'' else: munge_result = "cat" mz_launch_script = f"""echo {shlex.quote(base64.b64encode(pkg_data).decode('utf-8'))} | base64 -d > mz.tar.gz python3 -m venv /tmp/mzenv >&2 . /tmp/mzenv/bin/activate >&2 python3 -m pip install --upgrade pip >&2 pip3 install ./mz.tar.gz[dev] >&2 MZ_ROOT=/home/ubuntu/materialize python3 -u -m {script_name} {script_args} result=$? echo $result > ~/bench_exit_code if [ $result -eq 0 ]; then {munge_result} < ~/mzscratch-startup.out | aws s3 cp - s3://{ns.s3_root}/$MZ_CB_BENCH_ID/$MZ_CB_CLUSTER_ID.csv >&2 else aws s3 cp - s3://{ns.s3_root}/$MZ_CB_BENCH_ID/$MZ_CB_CLUSTER_ID-FAILURE.out < ~/mzscratch-startup.out >&2 aws s3 cp - s3://{ns.s3_root}/$MZ_CB_BENCH_ID/$MZ_CB_CLUSTER_ID-FAILURE.err < ~/mzscratch-startup.err fi sudo shutdown -h now # save some money """ if ns.profile == "basic": descs = [ scratch.MachineDesc( name="materialized", launch_script=mz_launch_script, instance_type="r5a.4xlarge", ami="ami-0b29b6e62f2343b46", tags={}, size_gb=64, ), ] elif ns.profile == "confluent": confluent_launch_script = f"""bin/mzcompose --mz-find load-tests up""" descs = [ scratch.MachineDesc( name="materialized", launch_script=mz_launch_script, instance_type="r5a.4xlarge", ami="ami-0b29b6e62f2343b46", tags={}, size_gb=64, ), scratch.MachineDesc( name="confluent", launch_script=confluent_launch_script, instance_type="r5a.4xlarge", ami="ami-0b29b6e62f2343b46", tags={}, size_gb=1000, checkout=False, ), ] else: raise RuntimeError(f"Profile {ns.profile} is not implemented yet") bench_id = util.nonce(8) manifest_bytes = "".join(f"{i}-{rev}\n" for i, rev in clusters).encode("utf-8") boto3.client("s3").put_object(Body=manifest_bytes, Bucket="mz-cloudbench", Key=f"{bench_id}/MANIFEST") # TODO - Do these in parallel launched = [] for (i, rev) in clusters: launched += scratch.launch_cluster( descs=descs, nonce=f"{bench_id}-{i}-{rev}", subnet_id=DEFAULT_SUBNET_ID, security_group_id=DEFAULT_SG_ID, instance_profile=DEFAULT_INSTPROF_NAME, key_name=None, extra_tags={ "bench_id": bench_id, "bench_rev": rev, "bench_i": str(i), "LaunchedBy": scratch.whoami(), }, extra_env={ "MZ_CB_BENCH_ID": bench_id, "MZ_CB_CLUSTER_ID": f"{i}-{rev}", "MZ_CB_GIT_REV": rev, "MZ_CB_S3_ROOT": ns.s3_root, }, delete_after=scratch.now_plus(timedelta(days=1)), git_rev=rev, ) print("Launched instances:") print_instances(launched, format="table") # todo print(f"""Launched cloud bench with ID {bench_id}. To wait for results, run: bin/cloudbench check {bench_id}""")