MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / start

Function start

misc/python/materialize/cli/cloudbench.py:179–297  ·  view source on GitHub ↗
(ns: argparse.Namespace)

Source from the content-addressed store, hash-verified

177
178
179def start(ns: argparse.Namespace) -> None:
180 check_required_vars()
181
182 revs = ns.revs.split(",")
183
184 clusters = list(
185 itertools.product(range(ns.trials), (git.rev_parse(rev) for rev in revs))
186 )
187
188 bench_script = ns.bench_script
189 script_name = bench_script[0]
190 script_args = " ".join(shlex.quote(arg) for arg in bench_script[1:])
191
192 # zip up the `misc` repository, for shipment to the remote machine
193 os.chdir("misc/python")
194 spawn.runv(["python3", "./setup.py", "sdist"])
195
196 with open("./dist/materialize-0.0.0.tar.gz", "rb") as f:
197 pkg_data = f.read()
198 os.chdir(os.environ["MZ_ROOT"])
199
200 if ns.append_metadata:
201 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"\'"}}\''
202 else:
203 munge_result = "cat"
204
205 mz_launch_script = f"""echo {shlex.quote(base64.b64encode(pkg_data).decode('utf-8'))} | base64 -d > mz.tar.gz
206python3 -m venv /tmp/mzenv >&2
207. /tmp/mzenv/bin/activate >&2
208python3 -m pip install --upgrade pip >&2
209pip3 install ./mz.tar.gz[dev] >&2
210MZ_ROOT=/home/ubuntu/materialize python3 -m {script_name} {script_args}
211result=$?
212echo $result > ~/bench_exit_code
213if [ $result -eq 0 ]; then
214 {munge_result} < ~/materialize/results.csv | aws s3 cp - s3://{ns.s3_root}/$MZ_CB_BENCH_ID/$MZ_CB_CLUSTER_ID.csv >&2
215else
216 aws s3 cp - s3://{ns.s3_root}/$MZ_CB_BENCH_ID/$MZ_CB_CLUSTER_ID-FAILURE.log < ~/mzscratch.log >&2
217fi
218sudo shutdown -h now # save some money
219"""
220
221 if ns.profile == "basic":
222 descs = [
223 scratch.MachineDesc(
224 name="materialized",
225 launch_script=mz_launch_script,
226 instance_type="r5a.4xlarge",
227 ami="ami-0aeb7c931a5a61206",
228 tags={},
229 size_gb=64,
230 ),
231 ]
232 elif ns.profile == "confluent":
233 confluent_launch_script = """
234curl https://packages.confluent.io/deb/7.0/archive.key | sudo apt-key add -
235sudo add-apt-repository "deb https://packages.confluent.io/deb/7.0 stable main"
236sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"

Callers 15

connectMethod · 0.85
serve_connectionFunction · 0.85
resetMethod · 0.85
mainFunction · 0.85
rewriteFunction · 0.85
runFunction · 0.85
setup_test_contextFunction · 0.85
test_balancerFunction · 0.85

Calls 10

check_required_varsFunction · 0.90
print_instancesFunction · 0.90
listFunction · 0.50
splitMethod · 0.45
productMethod · 0.45
joinMethod · 0.45
readMethod · 0.45
decodeMethod · 0.45
encodeMethod · 0.45
clientMethod · 0.45

Tested by 15

mainFunction · 0.68
rewriteFunction · 0.68
setup_test_contextFunction · 0.68
test_balancerFunction · 0.68
test_cert_reloadingFunction · 0.68
test_auth_expiryFunction · 0.68