Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix flickering and improve speed in EventsTest #589

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

Pldi23
Copy link
Contributor

@Pldi23 Pldi23 commented Jul 13, 2022

Description

EventsTest was flickering because on high load system wait was finishing before event comes.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify

@@ -55,7 +58,7 @@ public class EventsTest {

@BeforeClass
public static void setupDelay() {
GitHubSCMSource.setEventDelaySeconds(1);
GitHubSCMSource.setEventDelaySeconds(0); // fire immediately without delay
Copy link
Contributor Author

@Pldi23 Pldi23 Jul 13, 2022

Choose a reason for hiding this comment

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

IMO do not make much sense to add 1 second per each test for a delay. With that change single test runs 20-30 ms instead of 1200 ms.

SCMEvents.awaitOne(watermark, received ? 20 : 200, TimeUnit.MILLISECONDS);

if (received) {
TestSCMEventListener.awaitUntilReceived();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

usually event comes immediately, but if system struggling from not enough resources it could be longer, so let's add a waiter for event to be received for tests which are expecting received = true

@@ -188,7 +191,11 @@ private GHSubscriberEvent createEvent(String eventPayloadFile) throws IOExceptio
private void waitAndAssertReceived(boolean received) throws InterruptedException {
long watermark = SCMEvents.getWatermark();
// event will be fired by subscriber at some point
SCMEvents.awaitOne(watermark, 1200, TimeUnit.MILLISECONDS);
SCMEvents.awaitOne(watermark, received ? 20 : 200, TimeUnit.MILLISECONDS);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before changes await was 1200 because of delay before test was 1 second, for now we leave 200 millis for cases when expected received = false

@Pldi23
Copy link
Contributor Author

Pldi23 commented Jul 15, 2022

Could someone from maintainers please review?

@jtnord jtnord enabled auto-merge July 15, 2022 10:03
@jtnord jtnord merged commit 0c05abd into jenkinsci:master Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants