Skip to content

Commit b686a30

Browse files
committed
Fix building mz-debug in the background
This reverts commit f53418b.
1 parent 8278ea1 commit b686a30

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

ci/plugins/mzcompose/hooks/pre-exit

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ ci_collapsed_heading ":docker: Purging all existing docker containers and volume
149149
docker ps --all --quiet | xargs --no-run-if-empty docker rm --force --volumes
150150

151151
if [ "$BUILDKITE_STEP_KEY" = "terraform-aws" ]; then
152-
run run aws-temporary --no-setup --no-test --no-mz-debug || true
152+
run run aws-temporary --no-setup --no-test --no-run-mz-debug || CI_ANNOTATE_ERRORS_RESULT=1
153153
elif [ "$BUILDKITE_STEP_KEY" = "terraform-aws-upgrade" ]; then
154-
run run aws-upgrade --no-setup --no-test --no-mz-debug || true
154+
run run aws-upgrade --no-setup --no-test --no-run-mz-debug || CI_ANNOTATE_ERRORS_RESULT=1
155155
elif [ "$BUILDKITE_STEP_KEY" = "terraform-gcp" ]; then
156-
run run gcp-temporary --no-setup --no-test --no-mz-debug || true
156+
run run gcp-temporary --no-setup --no-test --no-run-mz-debug || CI_ANNOTATE_ERRORS_RESULT=1
157157
elif [ "$BUILDKITE_STEP_KEY" = "terraform-azure" ]; then
158-
run run azure-temporary --no-setup --no-test --no-mz-debug || true
158+
run run azure-temporary --no-setup --no-test --no-run-mz-debug || CI_ANNOTATE_ERRORS_RESULT=1
159159
fi
160160
rm -rf ~/.kube # Remove potential state from E2E Terraform tests
161161

test/terraform/mzcompose.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import signal
1717
import subprocess
18+
import threading
1819
import time
1920
from collections.abc import Sequence
2021
from pathlib import Path
@@ -84,7 +85,8 @@
8485
"joins.td",
8586
"jsonb.td",
8687
"list.td",
87-
"load-generator-key-value.td",
88+
# Flaky on Azure: https://buildkite.com/materialize/nightly/builds/11906#019661aa-2f41-43e1-b08f-6195c66a7ab9
89+
# "load-generator-key-value.td",
8890
"logging.td",
8991
"map.td",
9092
"multijoins.td",
@@ -142,6 +144,25 @@ def get_tag(tag: str | None) -> str:
142144
return tag or f"v{ci_util.get_mz_version()}--pr.g{git.rev_parse('HEAD')}"
143145

144146

147+
def build_mz_debug_async(env: dict[str, str] | None = None) -> threading.Thread:
148+
def run():
149+
spawn.capture(
150+
[
151+
"cargo",
152+
"build",
153+
"--bin",
154+
"mz-debug",
155+
],
156+
cwd=MZ_ROOT,
157+
stderr=subprocess.STDOUT,
158+
env=env,
159+
)
160+
161+
thread = threading.Thread(target=run)
162+
thread.start()
163+
return thread
164+
165+
145166
def run_mz_debug(env: dict[str, str] | None = None) -> None:
146167
print("--- Running mz-debug")
147168
try:
@@ -686,7 +707,10 @@ def workflow_aws_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
686707
tag = get_tag(args.tag)
687708
path = MZ_ROOT / "test" / "terraform" / "aws-temporary"
688709
aws = AWS(path)
710+
mz_debug_build_thread: threading.Thread | None = None
689711
try:
712+
if args.run_mz_debug:
713+
mz_debug_build_thread = build_mz_debug_async()
690714
aws.setup("aws-test", args.setup, tag)
691715
if args.test:
692716
print("--- Running tests")
@@ -718,6 +742,8 @@ def workflow_aws_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
718742
aws.cleanup()
719743

720744
if args.run_mz_debug:
745+
assert mz_debug_build_thread
746+
mz_debug_build_thread.join()
721747
run_mz_debug()
722748

723749
if args.cleanup:
@@ -775,7 +801,10 @@ def workflow_aws_upgrade(c: Composition, parser: WorkflowArgumentParser) -> None
775801
tag = get_tag(args.tag)
776802
path = MZ_ROOT / "test" / "terraform" / "aws-upgrade"
777803
aws = AWS(path)
804+
mz_debug_build_thread: threading.Thread | None = None
778805
try:
806+
if args.run_mz_debug:
807+
mz_debug_build_thread = build_mz_debug_async()
779808
aws.setup("aws-upgrade", args.setup, previous_tag)
780809
aws.upgrade(tag)
781810
if args.test:
@@ -812,6 +841,8 @@ def workflow_aws_upgrade(c: Composition, parser: WorkflowArgumentParser) -> None
812841
aws.cleanup()
813842

814843
if args.run_mz_debug:
844+
assert mz_debug_build_thread
845+
mz_debug_build_thread.join()
815846
run_mz_debug()
816847

817848
if args.cleanup:
@@ -997,7 +1028,10 @@ def workflow_gcp_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
9971028
f.write(gcp_service_account_json)
9981029
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(gcloud_creds_path)
9991030

1031+
mz_debug_build_thread: threading.Thread | None = None
10001032
try:
1033+
if args.run_mz_debug:
1034+
mz_debug_build_thread = build_mz_debug_async()
10011035
spawn.runv(["gcloud", "config", "set", "project", "materialize-ci"])
10021036

10031037
spawn.runv(
@@ -1398,6 +1432,8 @@ def workflow_gcp_temporary(c: Composition, parser: WorkflowArgumentParser) -> No
13981432
os.killpg(os.getpgid(balancerd_port_forward_process.pid), signal.SIGTERM)
13991433

14001434
if args.run_mz_debug:
1435+
assert mz_debug_build_thread
1436+
mz_debug_build_thread.join()
14011437
run_mz_debug()
14021438

14031439
if args.cleanup:
@@ -1485,7 +1521,10 @@ def workflow_azure_temporary(c: Composition, parser: WorkflowArgumentParser) ->
14851521
env=venv_env,
14861522
)
14871523

1524+
mz_debug_build_thread: threading.Thread | None = None
14881525
try:
1526+
if args.run_mz_debug:
1527+
mz_debug_build_thread = build_mz_debug_async()
14891528
if os.getenv("CI"):
14901529
username = os.getenv("AZURE_SERVICE_ACCOUNT_USERNAME")
14911530
password = os.getenv("AZURE_SERVICE_ACCOUNT_PASSWORD")
@@ -1914,6 +1953,8 @@ def workflow_azure_temporary(c: Composition, parser: WorkflowArgumentParser) ->
19141953
os.killpg(os.getpgid(balancerd_port_forward_process.pid), signal.SIGTERM)
19151954

19161955
if args.run_mz_debug:
1956+
assert mz_debug_build_thread
1957+
mz_debug_build_thread.join()
19171958
run_mz_debug(env=venv_env)
19181959

19191960
if args.cleanup:

0 commit comments

Comments
 (0)