Skip to content

Reduce test flakiness - #10809

Merged
MarkEWaite merged 4 commits into
jenkinsci:masterfrom
MarkEWaite:reduce-inQueueTaskLookupByAPI-flakiness
Jul 8, 2025
Merged

Reduce test flakiness#10809
MarkEWaite merged 4 commits into
jenkinsci:masterfrom
MarkEWaite:reduce-inQueueTaskLookupByAPI-flakiness

Conversation

@MarkEWaite

@MarkEWaite MarkEWaite commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

Reduce test flakiness

Launchable reports that inQueueTaskLookupByAPI has been flaky in the past 90 days. The flakiness seems to be specific to Windows and seems to be related to the job not being in the queue quickly enough after the call to schedule the build.

If the job is not queued, sleep for 3 seconds to allow it time to queue.

Since the first test run showed another flaky test, I added a Thread.sleep() to that flaky test, along with an explanation of the details. Refer to d5a6e2c for the details.

The SCSS media query was causing HTMLUnit to report a warning that 1x is not the right unit of measure for the media query. https://developer.mozilla.org/en-US/docs/Web/CSS/resolution says that x is an alias for dppx so I replaced 1x with 1dppx in the one place where it occurs. The HTMLUnit warning no longer appears.

Detected while processing the 2.516.1 backporting pull request:

Testing done

Confirmed that the job queues consistently on my Linux computer, so the sleep statement is not executed.

Proposed changelog entries

  • N/A

Proposed changelog category

/label skip-changelog
/label internal

Proposed upgrade guidelines

N/A

Submitter checklist

  • The Jira issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • New or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

N/A

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

https://app.launchableinc.com/organizations/jenkins/workspaces/jenkins/data/test-paths/class%3Dhudson.model.QueueTest%23%23%23testcase%3DinQueueTaskLookupByAPI?dateFilter=90d
reports that inQueueTaskLookupByAPI has been flaky in th epast 90 days.
The flakiness seems to be specific to Windows and seems to be related to
the job not be in the queue quickly enough after the call toe schedule
the build.

If the job is not queued, sleep for 3 seonds to allow it time to queue.

Testing done:

Confirmed that the job queues consistently on my Linux computer, so the
sleep statement is not executed.
@MarkEWaite MarkEWaite added the skip-changelog Should not be shown in the changelog label Jul 6, 2025
Per https://developer.mozilla.org/en-US/docs/Web/CSS/resolution , `x` is
an alias for `dppx`, so let's use `dppx` to avoid warnings from HTMLUnit.
https://app.launchableinc.com/organizations/jenkins/workspaces/jenkins/data/test-paths/class%3Dhudson.cli.ComputerStateTest%23%23%23testcase%3DtestUiForConnected?dateFilter=90d
reports that there have been multiple failures of
ComputerStateTest#testUiForConnected in the last 90 days.  The failures
seem to be related to a race condition that the agent is not yet
disconnected when the state of the agent is checked.  Wait for 1 second
to allow the agent to disconnect before checking agent status.

The average time to run the test is 34 seconds.  This will increase that
average time by 1 second.  Not a significant increase compared to the
benefit of avoiding a flaky test.
@MarkEWaite

MarkEWaite commented Jul 6, 2025

Copy link
Copy Markdown
Contributor Author

Since the first test run showed another flaky test, I added a Thread.sleep() to that flaky test, along with an explanation of the details. Refer to d5a6e2c for the details.

The SCSS media query was causing HTMLUnit to report a warning that 1x is not the right unit of measure for the media query. https://developer.mozilla.org/en-US/docs/Web/CSS/resolution says that x is an alias for dppx so I replaced 1x with 1dppx in the one place where it occurs. The HTMLUnit warning no longer appears.

If that change causes objections because it is bundled inside this pull request, I'm happy to move it to another pull request. @janfaracik and @scherler, is it OK if I leave it in this pull request?

https://app.launchableinc.com/organizations/jenkins/workspaces/jenkins/data/test-paths/class%3Dhudson.model.RunTest%23%23%23testcase%3DpreventXssInBadgeTooltip?dateFilter=90d
shows there have been random test failures of preventXssInBadgeTooltip
in the last 90 days.

Reeduce failures by sleeping before the key assertions in order to allow
Jenkins to complete the initialization of the page.
@MarkEWaite MarkEWaite changed the title Reduce inQueueTaskLookupByAPI flakiness Reduce test flakiness Jul 6, 2025
@MarkEWaite

Copy link
Copy Markdown
Contributor Author

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback.

/label ready-for-merge

@comment-ops-bot comment-ops-bot Bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jul 7, 2025

@A1exKH A1exKH left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM.

@MarkEWaite
MarkEWaite merged commit f59a5d4 into jenkinsci:master Jul 8, 2025
@MarkEWaite
MarkEWaite deleted the reduce-inQueueTaskLookupByAPI-flakiness branch July 8, 2025 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants