blob: a8837c1d50afbee12170b38d975b5296d0cf344c [file] [log] [blame]
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -e
echo "๐Ÿ Python SDK Test Runner"
echo "========================="
# Wait for server to be ready
echo "โณ Waiting for Iggy server to be ready..."
timeout 60 bash -c "
until timeout 5 bash -c '</dev/tcp/\${IGGY_SERVER_HOST}/\${IGGY_SERVER_TCP_PORT}'; do
echo ' Server not ready, waiting...'
sleep 2
done
"
echo "โœ… Server is ready!"
# Test connection
echo "๐Ÿ”— Testing basic connectivity..."
# Resolve hostname to IP address for Rust client compatibility
SERVER_IP=$(getent hosts "${IGGY_SERVER_HOST}" | awk '{ print $1 }' | head -n1)
if [ -z "$SERVER_IP" ]; then
echo "โŒ Could not resolve hostname: ${IGGY_SERVER_HOST}"
exit 1
fi
echo "๐Ÿ“ Resolved ${IGGY_SERVER_HOST} to ${SERVER_IP}"
if ! python3 -c "
import asyncio
import sys
from apache_iggy import IggyClient
async def test_connection():
try:
client = IggyClient('${SERVER_IP}:${IGGY_SERVER_TCP_PORT}')
await client.connect()
await client.login_user('iggy', 'iggy')
await client.ping()
print('โœ… Connection test passed')
return True
except Exception as e:
print(f'โŒ Connection test failed: {e}')
return False
result = asyncio.run(test_connection())
sys.exit(0 if result else 1)
"; then
echo "โŒ Connection test failed, aborting tests"
exit 1
fi
# Create test results directory
mkdir -p test-results
# Run tests with detailed output
echo "๐Ÿงช Running Python SDK tests..."
python3 -m pytest \
"${PYTEST_ARGS:--v --tb=short}" \
--junit-xml=test-results/pytest.xml \
tests/
TEST_EXIT_CODE=$?
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "โœ… All tests passed!"
else
echo "โŒ Some tests failed (exit code: $TEST_EXIT_CODE)"
fi
echo "๐Ÿ“Š Test results saved to test-results/"
exit $TEST_EXIT_CODE