Skip to content

Commit 6a946da

Browse files
SloNNclaude
andcommitted
Fix run-tests.sh: use --config-path to reliably apply config patches
Replace docker cp + restart approach with a two-phase startup: 1. Start YDB once to generate the default config 2. Patch the config on the host (feature flags + replication service) 3. Restart with --config-path so local_ydb deploy uses the patched file Also switch from port_open to health_check for readiness detection, and add enable_topic_transfer: true to unblock CREATE TRANSFER. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 32dc816 commit 6a946da

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

integration-tests/run-tests.sh

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ $RT run -d \
6363
-e MINIO_ROOT_PASSWORD=minioadmin \
6464
"${MINIO_IMAGE}" server /data --address ":${MINIO_PORT}" >/dev/null
6565

66-
# ── start YDB ────────────────────────────────────────────────────────────────
66+
# ── start YDB (first time) to generate default config ────────────────────────
6767
# YDB_USE_IN_MEMORY_PDISKS=false is required: Topics, Views, and Resource Pools
6868
# do not work with in-memory pdisks. YDB_PDISK_SIZE is in bytes (64 GB sparse).
69-
log "Starting YDB ${YDB_IMAGE} ..."
69+
log "Starting YDB ${YDB_IMAGE} to generate config ..."
7070
$RT run -d \
7171
--name "${YDB_CONTAINER}" \
7272
--network=host \
@@ -76,10 +76,9 @@ $RT run -d \
7676
-e GRPC_PORT="${YDB_PORT}" \
7777
"${YDB_IMAGE}" >/dev/null
7878

79-
# ── wait for YDB to become available ─────────────────────────────────────────
80-
log "Waiting for YDB on port ${YDB_PORT} ..."
79+
log "Waiting for YDB (health_check) ..."
8180
for i in $(seq 1 "${WAIT_TIMEOUT}"); do
82-
if port_open "${YDB_PORT}"; then
81+
if $RT exec "${YDB_CONTAINER}" /health_check >/dev/null 2>&1; then
8382
log "YDB ready after ${i}s"
8483
break
8584
fi
@@ -90,31 +89,42 @@ for i in $(seq 1 "${WAIT_TIMEOUT}"); do
9089
sleep 1
9190
done
9291

93-
# ── enable required feature flags ────────────────────────────────────────────
94-
# Copy config out, patch on host, copy back, restart container.
95-
log "Enabling feature flags and grpc replication service ..."
96-
TMP_CONFIG="/tmp/ydb-it-config.yaml"
97-
$RT cp "${YDB_CONTAINER}:${YDB_CONFIG_PATH}" "${TMP_CONFIG}"
98-
99-
# Add feature flags if not already present
100-
if ! grep -q 'enable_resource_pools' "${TMP_CONFIG}"; then
101-
sed -i '/^feature_flags:/a\ enable_resource_pools: true\n enable_external_data_sources: true\n enable_streaming_queries: true' "${TMP_CONFIG}"
92+
# ── patch config, then re-run with --config-path ─────────────────────────────
93+
# local_ydb deploy regenerates config.yaml on every start UNLESS --config-path
94+
# is given — in that case it copies the provided file instead of generating.
95+
# We patch the generated config on the host, save it to a separate path,
96+
# then re-run the container pointing --config-path at that file (mounted via -v).
97+
log "Patching config: enabling feature flags and replication gRPC service ..."
98+
GENERATED_CONFIG="${YDB_DATA_DIR}/cluster/kikimr_configs/config.yaml"
99+
PATCHED_CONFIG="/tmp/ydb-it-patched-config.yaml"
100+
cp "${GENERATED_CONFIG}" "${PATCHED_CONFIG}"
101+
102+
if ! grep -q 'enable_resource_pools' "${PATCHED_CONFIG}"; then
103+
sed -i '/^feature_flags:/a\ enable_resource_pools: true\n enable_external_data_sources: true\n enable_streaming_queries: true\n enable_topic_transfer: true' "${PATCHED_CONFIG}"
102104
fi
103-
104-
# Add grpc replication service if not already present
105-
if ! grep -q 'replication' "${TMP_CONFIG}"; then
106-
sed -i '/^grpc_config:/,/^[^ ]/ { /services:/a\ - replication
107-
}' "${TMP_CONFIG}"
105+
if ! grep -q '^\s*- replication' "${PATCHED_CONFIG}"; then
106+
sed -i '/^ services:$/a\ - replication' "${PATCHED_CONFIG}"
108107
fi
109108

110-
$RT cp "${TMP_CONFIG}" "${YDB_CONTAINER}:${YDB_CONFIG_PATH}"
111-
rm -f "${TMP_CONFIG}"
109+
$RT rm -f "${YDB_CONTAINER}" >/dev/null 2>&1
110+
rm -rf "${YDB_DATA_DIR}"
111+
mkdir -p "${YDB_DATA_DIR}"
112+
113+
log "Restarting YDB with patched config ..."
114+
$RT run -d \
115+
--name "${YDB_CONTAINER}" \
116+
--network=host \
117+
-v "${YDB_DATA_DIR}:/ydb_data" \
118+
-v "${PATCHED_CONFIG}:/tmp/ydb-custom-config.yaml:ro" \
119+
-e YDB_USE_IN_MEMORY_PDISKS=false \
120+
-e YDB_PDISK_SIZE=68719476736 \
121+
-e GRPC_PORT="${YDB_PORT}" \
122+
"${YDB_IMAGE}" \
123+
--config-path /tmp/ydb-custom-config.yaml >/dev/null
112124

113-
# Restart the container so ydbd picks up the new config.
114-
$RT restart "${YDB_CONTAINER}"
115125
log "Waiting for YDB to restart with updated config ..."
116126
for i in $(seq 1 "${WAIT_TIMEOUT}"); do
117-
if port_open "${YDB_PORT}"; then
127+
if $RT exec "${YDB_CONTAINER}" /health_check >/dev/null 2>&1; then
118128
log "YDB restarted after ${i}s"
119129
break
120130
fi

0 commit comments

Comments
 (0)