litellm/tests/test_litellm/integrations
Alexsander Hamir 1e89aa3068
Fix: Resolve flakiness in three integration tests (#17594)
Fixed three flaky tests that were intermittently failing in CI:

1. test_no_duplicate_spend_logs (test_litellm/responses/test_no_duplicate_spend_logs.py)
   Problem: Used await asyncio.sleep(1) to wait for async logging completion,
            which created race conditions. The async logging worker queues tasks
            in the background, and sleep() doesn't guarantee completion.

   Fix: Replaced sleep() with GLOBAL_LOGGING_WORKER.flush() which properly waits
        for the logging queue to empty, ensuring all async logging tasks complete
        before assertions run.

2. test_log_langfuse_v2_handles_null_usage_values (test_litellm/integrations/test_langfuse.py)
   Problem: Used datetime.datetime.now() twice for start_time and end_time, which
            could cause timing inconsistencies between test runs, especially in
            CI environments with variable execution speeds.

   Fix: Use fixed timestamps instead of datetime.now() to ensure consistent timing
        across all test runs, eliminating timing-related flakiness.

3. test_watsonx_gpt_oss_prompt_transformation (test_litellm/llms/watsonx/test_watsonx.py)
   Problem: Directly accessed mock_post.call_args without checking if it exists,
            which could be None if the mock wasn't called or if an exception
            occurred before the POST request. The test catches exceptions and
            continues, making this a potential failure point.

   Fix: Added proper assertions and use call_args_list[0] for safer access:
        - Assert that call_args_list has at least one call
        - Assert that call_args is not None
        - Assert that 'data' key exists in kwargs
        This ensures the test fails with clear error messages rather than
        intermittent AttributeError exceptions.

All fixes maintain the original test intent while making them deterministic
and reliable in CI environments.
2025-12-06 07:57:03 -08:00
..
arize ArizePhoenixConfig 2025-11-22 09:28:37 -08:00
bitbucket
cloudzero [Bug] Updated spend would not be sent to CloudZero (#16201) 2025-11-10 19:43:15 -08:00
datadog test_dd_llms_obs_redaction 2025-11-08 14:23:42 -08:00
dotprompt test_dotprompt_with_prompt_version 2025-11-22 11:00:47 -08:00
gcs_bucket
gcs_pubsub
gitlab Add GitlabPromptCache and enable subfolder access (#15712) 2025-10-28 14:46:50 -07:00
langfuse
open_telemetry/data
SlackAlerting
test_agentops.py
test_anthropic_cache_control_hook.py
test_athina.py
test_braintrust_logging.py
test_braintrust_span_name.py
test_custom_guardrail.py Permission Management - disable global guardrails by key/team (#16983) 2025-11-22 15:43:50 -08:00
test_custom_prompt_management.py
test_deepeval.py
test_langfuse_otel.py build: Squashed commit of the following: (#16176) 2025-11-02 09:46:40 -08:00
test_langfuse.py Fix: Resolve flakiness in three integration tests (#17594) 2025-12-06 07:57:03 -08:00
test_langsmith_init.py
test_mlflow.py Fix: MLflow streaming spans for Anthropic passthrough (#17288) 2025-12-05 14:59:36 -08:00
test_openmeter.py
test_opentelemetry.py [Feat] OTEL - Log Cost Breakdown on OTEL Logger (#16334) 2025-11-06 13:53:53 -08:00
test_prometheus_labels.py
test_prometheus_services.py
test_s3_v2.py Add allowing Key based prefix to s3 path (#16237) 2025-11-05 14:43:21 -08:00
test_weave_otel.py feat: Basic Weave OTEL integration (#17439) 2025-12-03 21:26:22 -08:00