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 flaky tests in PortalRegistryTest.java and ConsulRegistryTest.java #857

Merged
merged 3 commits into from
Dec 10, 2020

Conversation

KellyShao
Copy link
Contributor

@KellyShao KellyShao commented Dec 9, 2020

Fixed flaky test that caused by unregistered and unavailabled registry in class PortalRegistryTest.java and ConsulRegistryTest.java.

  • Issue 1

    • In both classes, if only run subAndUnsubService() method before doRegisterAndAvailable() or discoverService() method, the tests will failed. Take the PortalRegistryTest class for example, the error msgs are:

      • doRegisterAndAvailable() method:
          java.lang.AssertionError
            at com.networknt.portal.registry.PortalRegistryTest.doRegisterAndAvailable(PortalRegistryTest.java:76)
        
      • discoverService() method:
         java.lang.AssertionError
           at com.networknt.portal.registry.PortalRegistryTest.a1discoverService(PortalRegistryTest.java:122)
        
    • Root cause: Since the subAndUnsubService() method is the last one, in the default test order in both PortalRegistryTest.java and ConsulRegistryTest.java. If we simply run the tests, we cannot find out the subAndUnsubService() method has unregistered URLs.

    • Solution: Unregistered URLs in the subAndUnsubService() method

  • Issue 2

    • In both classes, if only run discoverService() method before doRegisterAndAvailable() method, the tests will failed. Take the PortalRegistryTest class for example, the error msg is:
     java.lang.AssertionError
        at com.networknt.portal.registry.PortalRegistryTest.doRegisterAndAvailable(PortalRegistryTest.java:76)
    
    • Root cause: Since the discoverService() method is always after the doRegisterAndAvailable() method, in the default test order in both PortalRegistryTest.java and ConsulRegistryTest.java. If we simply run the tests, we cannot find out the discoverService() method has unavailabled service.

    • Solution: Unavailabled service in the discoverService() method

The flaky tests are found by running iDFlakies, after fixing the issue, there's no flaky tests in PortalRegistryTest.java and ConsulRegistryTest.java.

@stevehu stevehu merged commit e1e8486 into networknt:master Dec 10, 2020
@stevehu
Copy link
Contributor

stevehu commented Dec 10, 2020

@stevehu
Copy link
Contributor

stevehu commented Dec 10, 2020

@KellyShao Thanks a lot for your help.

Copy link
Contributor

@BalloonWen BalloonWen left a comment

Choose a reason for hiding this comment

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

I think this PR fails the build.

// unavailable
registry.doUnavailable(null);
Thread.sleep(sleepTime);
Assert.assertFalse(client.isWorking(serviceid));
Copy link
Contributor

Choose a reason for hiding this comment

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

where is the serviceid defined?

younggwon1 pushed a commit to younggwon1/light-4j that referenced this pull request Feb 10, 2024
networknt#857)

* Add unregistry for subAndUnsubService() method

* Update PortalRegistryTest.java

* Add unregistry & unavailable code
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.

None yet

3 participants