-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_all_examples.sh
More file actions
executable file
·147 lines (126 loc) · 4.4 KB
/
run_all_examples.sh
File metadata and controls
executable file
·147 lines (126 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# Script to run all Rust Hyper API examples
#
# This script runs the pure-Rust hyperdb-api examples.
# It sets up HYPERD_PATH to point to the hyperd executable.
# Make sure to build the release version of hyperd otherwise the benchmark runs
# much slower
#
# Don't exit on error - we want to continue running other examples even if one fails
set +e
cd "$(dirname "$0")"
# Set up HYPERD_PATH if not already set.
# Priority: 1) user-set HYPERD_PATH, 2) .hyperd/current/hyperd (written by
# `make download-hyperd`). If neither is present, auto-run the downloader
# — this script only exists to run the examples, so `hyperd` is always
# required.
if [ -z "$HYPERD_PATH" ]; then
HYPERD_DOWNLOAD="$(pwd)/.hyperd/current/hyperd"
if [ -f "$HYPERD_DOWNLOAD" ] && [ -x "$HYPERD_DOWNLOAD" ]; then
HYPERD_PATH="$HYPERD_DOWNLOAD"
else
echo "hyperd not found; running download-hyperd first..."
if ! cargo run --release -p hyperdb-bootstrap --bin hyperdb-bootstrap -- download; then
echo "Auto-download of hyperd failed. Set HYPERD_PATH to an existing hyperd and retry." >&2
exit 1
fi
HYPERD_PATH="$HYPERD_DOWNLOAD"
fi
export HYPERD_PATH
fi
echo "Running all Rust Hyper API examples (pure-Rust)"
echo "================================================"
echo "Environment:"
echo " HYPERD_PATH=$HYPERD_PATH"
echo ""
# List of examples in hyperdb-api
examples=(
# Core canonical examples (matching C++/Python APIs)
"insert_data_into_single_table"
"insert_data_into_multiple_tables"
"create_hyper_file_from_csv"
"delete_data_in_existing_hyper_file"
"update_data_in_existing_hyper_file"
"read_and_print_data_from_existing_hyper_file"
"insert_data_with_expressions"
"insert_geospatial_data_to_a_hyper_file"
# Rust-specific value-add examples
"arrow"
"async_usage"
"threaded_inserter"
"grpc_query"
"connection_pool"
"transactions"
"async_parity_smoke"
"prepared_statements"
)
# Examples that require additional feature flags
# Format: "example_name:feature1,feature2"
feature_examples=(
)
failed=()
passed=()
for example in "${examples[@]}"; do
echo "----------------------------------------"
echo "Running example: $example"
echo "----------------------------------------"
# Capture start time using bash's built-in SECONDS variable
start_seconds=$SECONDS
# Run the example with HYPERD_PATH set
env HYPERD_PATH="$HYPERD_PATH" \
cargo run --release -p hyperdb-api --example "$example" > /tmp/hyper_example_${example}.log 2>&1
exit_code=$?
# Calculate duration
duration=$((SECONDS - start_seconds))
if [ $exit_code -eq 0 ]; then
echo "✓ $example passed (${duration}s)"
passed+=("$example")
else
echo "✗ $example failed after ${duration}s (see /tmp/hyper_example_${example}.log)"
# Show last few lines of error log for debugging
echo " Last few lines of error:"
tail -10 /tmp/hyper_example_${example}.log | sed 's/^/ /'
failed+=("$example")
fi
echo ""
done
# Run examples that require feature flags
for entry in "${feature_examples[@]}"; do
# Parse "example_name:features" format
example="${entry%%:*}"
features="${entry#*:}"
echo "----------------------------------------"
echo "Running example: $example (features: $features)"
echo "----------------------------------------"
start_seconds=$SECONDS
# Run the example with features enabled
env HYPERD_PATH="$HYPERD_PATH" \
cargo run --release -p hyperdb-api --features "$features" --example "$example" > /tmp/hyper_example_${example}.log 2>&1
exit_code=$?
duration=$((SECONDS - start_seconds))
if [ $exit_code -eq 0 ]; then
echo "✓ $example passed (${duration}s)"
passed+=("$example")
else
echo "✗ $example failed after ${duration}s (see /tmp/hyper_example_${example}.log)"
echo " Last few lines of error:"
tail -10 /tmp/hyper_example_${example}.log | sed 's/^/ /'
failed+=("$example")
fi
echo ""
done
echo "================================================"
echo "Summary:"
echo " Passed: ${#passed[@]}"
echo " Failed: ${#failed[@]}"
echo ""
if [ ${#failed[@]} -gt 0 ]; then
echo "Failed examples:"
for ex in "${failed[@]}"; do
echo " - $ex"
done
exit 1
else
echo "All examples passed!"
exit 0
fi