fix(tests): try to resolve last failing integration test
This commit is contained in:
parent
ae70fe4684
commit
5fc88da522
|
|
@ -68,8 +68,10 @@ jobs:
|
||||||
|
|
||||||
- name: Start readur server
|
- name: Start readur server
|
||||||
run: |
|
run: |
|
||||||
./target/release/readur &
|
./target/release/readur > server.log 2>&1 &
|
||||||
echo $! > readur.pid
|
echo $! > readur.pid
|
||||||
|
sleep 2
|
||||||
|
echo "Server started with PID: $(cat readur.pid)"
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: ${{ env.DATABASE_URL }}
|
DATABASE_URL: ${{ env.DATABASE_URL }}
|
||||||
JWT_SECRET: test-secret-key
|
JWT_SECRET: test-secret-key
|
||||||
|
|
@ -88,6 +90,16 @@ jobs:
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Verify the server is actually running
|
||||||
|
if ! curl -f http://localhost:8000/api/health > /dev/null 2>&1; then
|
||||||
|
echo "ERROR: Server failed to start properly!"
|
||||||
|
if [ -f readur.pid ]; then
|
||||||
|
echo "Server PID: $(cat readur.pid)"
|
||||||
|
ps aux | grep $(cat readur.pid) || echo "Process not found"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Wait for PostgreSQL to be ready
|
- name: Wait for PostgreSQL to be ready
|
||||||
run: |
|
run: |
|
||||||
until pg_isready -h localhost -p 5432 -U postgres; do
|
until pg_isready -h localhost -p 5432 -U postgres; do
|
||||||
|
|
@ -108,9 +120,17 @@ jobs:
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: ${{ env.DATABASE_URL }}
|
DATABASE_URL: ${{ env.DATABASE_URL }}
|
||||||
TEST_DATABASE_URL: ${{ env.DATABASE_URL }}
|
TEST_DATABASE_URL: ${{ env.DATABASE_URL }}
|
||||||
|
API_URL: http://localhost:8000
|
||||||
RUST_LOG: debug
|
RUST_LOG: debug
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
|
|
||||||
|
- name: Print server logs on failure
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
echo "=== Server logs ==="
|
||||||
|
cat server.log || echo "No server logs found"
|
||||||
|
echo "=== End of server logs ==="
|
||||||
|
|
||||||
- name: Stop readur server
|
- name: Stop readur server
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,40 @@ impl PipelineDebugger {
|
||||||
async fn new() -> Self {
|
async fn new() -> Self {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
|
|
||||||
// Check server health
|
// Debug: Print the base URL we're trying to connect to
|
||||||
let response = client
|
let base_url = get_base_url();
|
||||||
.get(&format!("{}/api/health", get_base_url()))
|
println!("🔍 DEBUG: Attempting to connect to server at: {}", base_url);
|
||||||
|
|
||||||
|
// Check server health with better error handling
|
||||||
|
println!("🔍 DEBUG: Checking server health at: {}/api/health", base_url);
|
||||||
|
|
||||||
|
let health_check_result = client
|
||||||
|
.get(&format!("{}/api/health", base_url))
|
||||||
.timeout(Duration::from_secs(5))
|
.timeout(Duration::from_secs(5))
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await;
|
||||||
.expect("Server should be running");
|
|
||||||
|
|
||||||
|
match health_check_result {
|
||||||
|
Ok(response) => {
|
||||||
|
println!("🔍 DEBUG: Health check response status: {}", response.status());
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
panic!("Server not healthy");
|
let status = response.status();
|
||||||
|
let body = response.text().await.unwrap_or_else(|_| "Unable to read response body".to_string());
|
||||||
|
panic!("Server not healthy. Status: {}, Body: {}", status, body);
|
||||||
|
}
|
||||||
|
println!("✅ DEBUG: Server health check passed");
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("❌ DEBUG: Failed to connect to server health endpoint");
|
||||||
|
println!("❌ DEBUG: Error type: {:?}", e);
|
||||||
|
if e.is_timeout() {
|
||||||
|
panic!("Health check timed out after 5 seconds");
|
||||||
|
} else if e.is_connect() {
|
||||||
|
panic!("Could not connect to server at {}. Is the server running?", base_url);
|
||||||
|
} else {
|
||||||
|
panic!("Health check failed with error: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create test user
|
// Create test user
|
||||||
|
|
@ -101,18 +125,50 @@ impl PipelineDebugger {
|
||||||
let form = reqwest::multipart::Form::new().part("file", part);
|
let form = reqwest::multipart::Form::new().part("file", part);
|
||||||
|
|
||||||
let upload_start = Instant::now();
|
let upload_start = Instant::now();
|
||||||
let response = self.client
|
let upload_url = format!("{}/api/documents", get_base_url());
|
||||||
.post(&format!("{}/api/documents", get_base_url()))
|
println!(" 🔍 DEBUG: Uploading to URL: {}", upload_url);
|
||||||
|
println!(" 🔍 DEBUG: Using token (first 10 chars): {}...", &self.token[..10.min(self.token.len())]);
|
||||||
|
|
||||||
|
let response_result = self.client
|
||||||
|
.post(&upload_url)
|
||||||
.header("Authorization", format!("Bearer {}", self.token))
|
.header("Authorization", format!("Bearer {}", self.token))
|
||||||
.multipart(form)
|
.multipart(form)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await;
|
||||||
.expect("Upload should work");
|
|
||||||
|
let response = match response_result {
|
||||||
|
Ok(resp) => {
|
||||||
|
println!(" 🔍 DEBUG: Upload request sent successfully");
|
||||||
|
resp
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!(" ❌ DEBUG: Upload request failed");
|
||||||
|
println!(" ❌ DEBUG: Error type: {:?}", e);
|
||||||
|
if e.is_timeout() {
|
||||||
|
panic!("Upload request timed out");
|
||||||
|
} else if e.is_connect() {
|
||||||
|
panic!("Could not connect to server for upload. Error: {}", e);
|
||||||
|
} else if e.is_request() {
|
||||||
|
panic!("Request building failed: {}", e);
|
||||||
|
} else {
|
||||||
|
panic!("Upload failed with network error: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let upload_duration = upload_start.elapsed();
|
let upload_duration = upload_start.elapsed();
|
||||||
|
println!(" 🔍 DEBUG: Upload response received. Status: {}", response.status());
|
||||||
|
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
panic!("Upload failed: {}", response.text().await.unwrap_or_default());
|
let status = response.status();
|
||||||
|
let headers = response.headers().clone();
|
||||||
|
let body = response.text().await.unwrap_or_else(|_| "Unable to read response body".to_string());
|
||||||
|
|
||||||
|
println!(" ❌ DEBUG: Upload failed with status: {}", status);
|
||||||
|
println!(" ❌ DEBUG: Response headers: {:?}", headers);
|
||||||
|
println!(" ❌ DEBUG: Response body: {}", body);
|
||||||
|
|
||||||
|
panic!("Upload failed with status {}: {}", status, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
let document: DocumentResponse = response.json().await.expect("Valid JSON");
|
let document: DocumentResponse = response.json().await.expect("Valid JSON");
|
||||||
|
|
@ -536,6 +592,24 @@ async fn debug_document_upload_race_conditions() {
|
||||||
println!("🔍 DEBUGGING DOCUMENT UPLOAD PROCESS");
|
println!("🔍 DEBUGGING DOCUMENT UPLOAD PROCESS");
|
||||||
println!("====================================");
|
println!("====================================");
|
||||||
|
|
||||||
|
// First, let's do a basic connectivity test
|
||||||
|
println!("🔍 DEBUG: Testing basic network connectivity...");
|
||||||
|
let test_client = reqwest::Client::new();
|
||||||
|
let base_url = get_base_url();
|
||||||
|
println!("🔍 DEBUG: Base URL from environment: {}", base_url);
|
||||||
|
|
||||||
|
// Try a simple GET request first
|
||||||
|
match test_client.get(&base_url).send().await {
|
||||||
|
Ok(resp) => {
|
||||||
|
println!("✅ DEBUG: Basic connectivity test passed. Status: {}", resp.status());
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("❌ DEBUG: Basic connectivity test failed");
|
||||||
|
println!("❌ DEBUG: Error: {:?}", e);
|
||||||
|
panic!("Cannot connect to server at {}. Error: {}", base_url, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let debugger = PipelineDebugger::new().await;
|
let debugger = PipelineDebugger::new().await;
|
||||||
|
|
||||||
// Upload same content with different filenames to test upload race conditions
|
// Upload same content with different filenames to test upload race conditions
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue