Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/gha-e2e/mooncake/image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libnuma1 \
liburing2 \
curl \
jq \
&& rm -rf /var/lib/apt/lists/*

# Install from wheels only (--only-binary) so no package build or setup script
Expand Down
21 changes: 7 additions & 14 deletions test/gha-e2e/mooncake/image/custom-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,18 @@ case "$ROLE" in
;;

worker)
# Read the runtime config JSON that Fluid mounts into the component pod.
if [[ -z "$FLUID_RUNTIME_CONFIG_PATH" ]] || [[ ! -f "$FLUID_RUNTIME_CONFIG_PATH" ]]; then
echo "Error: FLUID_RUNTIME_CONFIG_PATH not set or file not found"
exit 1
fi

CONFIG=$(cat "$FLUID_RUNTIME_CONFIG_PATH")

MASTER_SVC=$(echo "$CONFIG" | jq -r '.master.service.name')
WORKER_SVC=$(echo "$CONFIG" | jq -r '.worker.service.name')
QUOTA=$(echo "$CONFIG" | jq -r '.worker.tieredStoreLevels[0].quotas[0] // "1GiB"')
# Fluid mounts runtime.sh alongside the runtime.json named by this variable.
: "${FLUID_RUNTIME_CONFIG_PATH:?missing runtime config path}"
source "$(dirname "$FLUID_RUNTIME_CONFIG_PATH")/runtime.sh"
QUOTA="${WORKER_TIEREDSTORE_LEVEL_0_QUOTA_0:-1GiB}"

# Fluid reports the quota in Kubernetes units ("1Gi"); Mooncake expects "1GB".
SEGMENT_SIZE=$(echo "$QUOTA" | sed 's/Gi$/GB/; s/Mi$/MB/')

NAMESPACE="${FLUID_DATASET_NAMESPACE:-default}"
MASTER_ADDR="${MASTER_SVC}.${NAMESPACE}.svc.cluster.local:50051"
METADATA_ADDR="http://${MASTER_SVC}.${NAMESPACE}.svc.cluster.local:8080/metadata"
WORKER_HOST="${POD_NAME}.${WORKER_SVC}.${NAMESPACE}.svc.cluster.local"
MASTER_ADDR="${MASTER_SERVICE_NAME}.${NAMESPACE}.svc.cluster.local:50051"
METADATA_ADDR="http://${MASTER_SERVICE_NAME}.${NAMESPACE}.svc.cluster.local:8080/metadata"
WORKER_HOST="${POD_NAME}.${WORKER_SERVICE_NAME}.${NAMESPACE}.svc.cluster.local"

echo "Starting worker: master=$MASTER_ADDR, segment_size=$SEGMENT_SIZE, host=$WORKER_HOST"

Expand Down
16 changes: 10 additions & 6 deletions test/gha-e2e/mooncake/rw_job.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Verifies the data path: read and write against the master directly through
# Mooncake's own Python client. Note that the pod declares no volumes /
# volumeMounts — without a client component there is no FUSE mount point, so the
# data path goes entirely through Mooncake's own client protocol, not the PVC.
# The webhook supplies the runtime config. The application uses it to discover
# the master and read and write via Mooncake's Python client.
apiVersion: batch/v1
kind: Job
metadata:
Expand All @@ -16,6 +14,9 @@ spec:
name: mooncake-rw-job
labels:
app: mooncake-rw-job
clientless.fluid.io/inject: "true"
annotations:
fluid.io/datasets: mooncake-demo
spec:
restartPolicy: Never
automountServiceAccountToken: false
Expand All @@ -35,16 +36,18 @@ spec:
fieldPath: status.podIP
# Override the image's default entrypoint so it is not started as a
# master or a worker
command: ["python3", "-c"]
command: ["/bin/sh", "-ec"]
args:
- |
. "${FLUID_RUNTIME_CONFIG_PATH_MOONCAKE_DEMO:?missing injected runtime config}"
exec python3 - <<'PY'
import hashlib
import os
import sys

from mooncake.store import MooncakeDistributedStore

MASTER = "mooncake-demo-master-0.svc-mooncake-demo-master"
MASTER = f"{os.environ['MASTER_NAME']}-0.{os.environ['MASTER_SERVICE_NAME']}"

store = MooncakeDistributedStore()
rc = store.setup(
Expand Down Expand Up @@ -84,3 +87,4 @@ spec:
sys.exit("md5 mismatch: got %s, want %s" % (have, want))

print("mooncake put/get verified")
PY
34 changes: 34 additions & 0 deletions test/gha-e2e/mooncake/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,38 @@ function wait_job_completed() {
kubectl logs job/"$job_name" --tail=20 2>&1 || true
}

# Inspect the admitted Pod. The Job template itself never passes through the Pod webhook.
function check_runtime_config_injection() {
local pods
pods=$(kubectl get pods -l "job-name=$rw_job_name" --field-selector=status.phase=Succeeded -o json) ||
panic "could not read the completed Pod for $rw_job_name"
if ! jq -e --arg volume "fluid-runtime-config-$dataset_name" --arg dir "/etc/fluid/config/$dataset_name" '
any(.items[].spec;
any(.volumes[]?; .name == $volume and .configMap.name == $volume) and
any(.containers[]; .name == "rw" and
any(.volumeMounts[]?; .name == $volume and .mountPath == $dir and .readOnly == true) and
any(.env[]?; .name == "FLUID_RUNTIME_CONFIG_PATH_MOONCAKE_DEMO" and .value == ($dir + "/runtime.sh"))))
' <<< "$pods" >/dev/null; then
panic "expected the rw container to receive the runtime ConfigMap, read-only mount and runtime.sh environment variable"
fi
syslog "Verified runtime config injection on the completed Mooncake app Pod"
}

function check_missing_dataset_rejected() {
local missing_dataset="mooncake-missing"
local result
if result=$(kubectl run mooncake-rejection-check --image=fluidcloudnative/mooncake:e2e --restart=Never \
--labels='clientless.fluid.io/inject=true' --annotations="fluid.io/datasets=$missing_dataset" \
--dry-run=server 2>&1); then
panic "expected admission to reject the missing dataset $missing_dataset"
fi
if [[ "$result" != *'admission webhook "clientless.fluid.io" denied the request'* ||
"$result" != *"\"$missing_dataset\" not found"* ]]; then
panic "unexpected admission error for $missing_dataset: $result"
fi
syslog "Verified the webhook rejected the missing dataset $missing_dataset"
}

# After a write, cached should reflect the actual usage. ReportSummary runs
# periodically, so one round has to elapse first.
function check_cached_after_write() {
Expand Down Expand Up @@ -380,9 +412,11 @@ function main() {
wait_cache_worker_ready
check_no_client_component
check_dataset_cache_state
check_missing_dataset_rejected

create_job $testdir/rw_job.yaml $rw_job_name
wait_job_completed $rw_job_name
check_runtime_config_injection
check_cached_after_write

check_pvc_not_mountable
Expand Down
Loading