Skip to content

fix: avoid flaky test_trigger_run_history by polling for first execution#2493

Open
trygveu wants to merge 3 commits intomasterfrom
trig/fix-flaky-list-workflow-executions-test
Open

fix: avoid flaky test_trigger_run_history by polling for first execution#2493
trygveu wants to merge 3 commits intomasterfrom
trig/fix-flaky-list-workflow-executions-test

Conversation

@trygveu
Copy link
Contributor

@trygveu trygveu commented Feb 26, 2026

Summary

  • test_trigger_run_history immediately called get_trigger_run_history() after fixture setup, but the cron trigger (* * * * *) may not have fired yet (up to ~60 s until the next tick).
  • Replaced the immediate assert len(history) > 0 with a polling loop (every 5 s, up to 90 s) that breaks once history is non-empty and fails with a clear message on timeout.
  • No SDK code changed — test-only fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@trygveu trygveu requested review from a team as code owners February 26, 2026 20:44
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @trygveu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an intermittent failure in an integration test by introducing a robust polling mechanism. The test_trigger_run_history test previously assumed immediate execution of a scheduled cron trigger, leading to flakiness. The updated approach now patiently waits for the trigger to fire, significantly improving test reliability without altering any core SDK functionality.

Highlights

  • Flaky Test Fix: Addressed flakiness in test_trigger_run_history where the test would sometimes fail because the cron trigger had not yet fired after setup.
  • Polling Mechanism: Implemented a polling loop with a 5-second interval and a 90-second timeout to wait for the scheduled trigger's first execution, replacing an immediate assertion.
  • Test-Only Change: Confirmed that no SDK code was modified, ensuring this fix is isolated to the test suite.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/tests_integration/test_api/test_workflows.py
    • Replaced an immediate assertion for trigger run history with a polling loop to account for the asynchronous nature of cron job execution.
    • Added a timeout mechanism to the polling loop to prevent indefinite waiting and provide clear failure messages.
Activity
  • CI integration tests are expected to pass, validating the fix for the timing gap.
  • Local testing confirms the logic is straightforward and aligns with existing polling patterns in the codebase.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a flaky test, test_trigger_run_history, by introducing a polling mechanism to wait for a scheduled trigger to execute. The approach is sound and correctly uses a timeout to prevent the test from hanging. I've added one comment regarding the use of hardcoded values for the timeout and polling interval, suggesting they be defined as constants for better maintainability, in line with the repository's style guide.

trygveu and others added 2 commits February 26, 2026 21:59
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lastUpdatedTime is server-managed and can be bumped by a concurrent CI
job upserting the same long-lived shared workflow between the fixture
capture and the retrieve call.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.86%. Comparing base (8fb5f58) to head (4181470).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2493   +/-   ##
=======================================
  Coverage   48.86%   48.86%           
=======================================
  Files         191      191           
  Lines       26162    26162           
=======================================
  Hits        12783    12783           
  Misses      13379    13379           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant