-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_all_examples.ps1
More file actions
160 lines (137 loc) · 5.44 KB
/
run_all_examples.ps1
File metadata and controls
160 lines (137 loc) · 5.44 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
148
149
150
151
152
153
154
155
156
157
158
159
160
# PowerShell 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 use the release version of hyperd otherwise the benchmark runs
# much slower.
#
# Error action preference - continue on errors
$ErrorActionPreference = "Continue"
# Change to script directory
Set-Location $PSScriptRoot
# Set up HYPERD_PATH if not already set
# Priority: 1) Use HYPERD_PATH if already set, 2) Check known locations
if (-not $env:HYPERD_PATH) {
$HyperdDownload = Join-Path $PSScriptRoot ".hyperd\current\hyperd.exe"
if (Test-Path $HyperdDownload) {
$env:HYPERD_PATH = $HyperdDownload
} else {
Write-Host "hyperd not found; running download-hyperd first..." -ForegroundColor Cyan
& cargo run --release -p hyperdb-bootstrap --bin hyperdb-bootstrap -- download
if ($LASTEXITCODE -ne 0) {
Write-Host "Auto-download of hyperd failed. Set HYPERD_PATH to an existing hyperd and retry." -ForegroundColor Red
exit $LASTEXITCODE
}
$env:HYPERD_PATH = $HyperdDownload
}
}
Write-Host "Running all Rust Hyper API examples (pure-Rust)" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Environment:"
Write-Host " HYPERD_PATH=$env:HYPERD_PATH"
Write-Host ""
# List of examples in hyperdb-api
# These match the [[example]] targets defined in hyperdb-api/Cargo.toml
$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"
)
# No feature-gated examples — hyperdb-api has zero feature flags.
# All capabilities (TLS, pooling, transactions, gRPC) are always available.
$featureExamples = @()
$failed = @()
$passed = @()
# Create temp directory for logs
$TempDir = $env:TEMP
if (-not $TempDir) {
$TempDir = "C:\Temp"
}
foreach ($example in $examples) {
Write-Host "----------------------------------------" -ForegroundColor Gray
Write-Host "Running example: $example" -ForegroundColor Yellow
Write-Host "----------------------------------------" -ForegroundColor Gray
# Capture start time
$startTime = Get-Date
# Log file path
$logFile = Join-Path $TempDir "hyper_example_$example.log"
# Run the example with HYPERD_PATH set
$env:HYPERD_PATH = $env:HYPERD_PATH
& cargo run --release -p hyperdb-api --example $example > $logFile 2>&1
$exitCode = $LASTEXITCODE
# Calculate duration
$endTime = Get-Date
$duration = ($endTime - $startTime).TotalSeconds
if ($exitCode -eq 0) {
Write-Host "[PASS] $example passed ($([math]::Round($duration, 2))s)" -ForegroundColor Green
$passed += $example
} else {
Write-Host "[FAIL] $example failed after $([math]::Round($duration, 2))s (see $logFile)" -ForegroundColor Red
# Show last few lines of error log for debugging
Write-Host " Last few lines of error:" -ForegroundColor Yellow
if (Test-Path $logFile) {
Get-Content $logFile -Tail 10 | ForEach-Object {
Write-Host " $_" -ForegroundColor Gray
}
}
$failed += $example
}
Write-Host ""
}
# Run examples that require feature flags
foreach ($entry in $featureExamples) {
$example = $entry.Example
$features = $entry.Features
Write-Host "----------------------------------------" -ForegroundColor Gray
Write-Host "Running example: $example (features: $features)" -ForegroundColor Yellow
Write-Host "----------------------------------------" -ForegroundColor Gray
$startTime = Get-Date
$logFile = Join-Path $TempDir "hyper_example_$example.log"
# Run the example with features enabled
& cargo run --release -p hyperdb-api --features $features --example $example > $logFile 2>&1
$exitCode = $LASTEXITCODE
$endTime = Get-Date
$duration = ($endTime - $startTime).TotalSeconds
if ($exitCode -eq 0) {
Write-Host "[PASS] $example passed ($([math]::Round($duration, 2))s)" -ForegroundColor Green
$passed += $example
} else {
Write-Host "[FAIL] $example failed after $([math]::Round($duration, 2))s (see $logFile)" -ForegroundColor Red
Write-Host " Last few lines of error:" -ForegroundColor Yellow
if (Test-Path $logFile) {
Get-Content $logFile -Tail 10 | ForEach-Object {
Write-Host " $_" -ForegroundColor Gray
}
}
$failed += $example
}
Write-Host ""
}
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Summary:" -ForegroundColor Cyan
Write-Host " Passed: $($passed.Count)" -ForegroundColor Green
Write-Host " Failed: $($failed.Count)" -ForegroundColor Red
Write-Host ""
if ($failed.Count -gt 0) {
Write-Host "Failed examples:" -ForegroundColor Red
foreach ($ex in $failed) {
Write-Host " - $ex" -ForegroundColor Red
}
exit 1
} else {
Write-Host "All examples passed!" -ForegroundColor Green
exit 0
}