fetch_ml/scripts/test-native-with-redis.sh
Jeremie Fraeys c89d970210
refactor: migrate from env var to build tags for native libs
Replace FETCHML_NATIVE_LIBS=1 environment variable with -tags native_libs:

Changes:
- internal/queue/native_queue.go: UseNativeQueue is now const true
- internal/queue/native_queue_stub.go: UseNativeQueue is now const false
- build/docker/simple.Dockerfile: Add -tags native_libs to go build
- deployments/docker-compose.dev.yml: Remove FETCHML_NATIVE_LIBS env var
- native/README.md: Update documentation for build tags
- scripts/test-native-with-redis.sh: New test script with Redis via docker-compose

Benefits:
- Compile-time enforcement (no runtime checks needed)
- Cleaner deployment (no env var management)
- Type safety (const vs var)
- Simpler testing with docker-compose Redis integration
2026-02-21 13:43:58 -05:00

53 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# Test script for native libraries with Redis via docker-compose
# Usage: ./scripts/test-native-with-redis.sh
set -e
echo "=== FetchML Native Library Test with Redis ==="
echo ""
# Check if native libraries are built
if [ ! -f "native/build/libqueue_index.so" ] && [ ! -f "native/build/libqueue_index.dylib" ]; then
echo "Building native libraries..."
make native-build
fi
# Start Redis via docker-compose
echo "Starting Redis..."
cd deployments
docker-compose -f docker-compose.dev.yml up -d redis
cd ..
# Wait for Redis to be ready
echo "Waiting for Redis to be ready..."
sleep 2
until docker exec ml-experiments-redis redis-cli ping | grep -q PONG; do
echo " Redis not ready yet, waiting..."
sleep 1
done
echo " Redis is ready!"
echo ""
# Run tests with native_libs build tag
echo "Running tests with -tags native_libs..."
CGO_ENABLED=1 go test -tags native_libs -v ./tests/... 2>&1 | head -100
TEST_EXIT=${PIPESTATUS[0]}
echo ""
echo "=== Test Summary ==="
if [ $TEST_EXIT -eq 0 ]; then
echo "✅ All tests passed with native libraries enabled"
else
echo "❌ Tests failed with exit code: $TEST_EXIT"
fi
# Cleanup
echo ""
echo "Stopping Redis..."
cd deployments
docker-compose -f docker-compose.dev.yml stop redis
cd ..
exit $TEST_EXIT