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 intermittent build failures #8312

Merged

Conversation

vishesh92
Copy link
Member

@vishesh92 vishesh92 commented Dec 6, 2023

Description

This PR fixes intermittent build failures which happen due to parallel test runs. As of now port 9399 is being used in NetworkerClientTest & VeeamClientTest. This PR updates the port in NetworkerClientTest from 9399 to 9400.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@rohityadavcloud
Copy link
Member

Could we somehow use random/available ports, there has to be a way to do that @vishesh92 ?

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

lgtm

@DaanHoogland
Copy link
Contributor

I don t think we should assign random ports, but make it deterministic. random is a sure way to get intermitted results in the end.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a15b706) 22.25% compared to head (1b4c9be) 27.92%.
Report is 9 commits behind head on main.

❗ Current head 1b4c9be differs from pull request most recent head 1449aa3. Consider uploading reports for the commit 1449aa3 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8312      +/-   ##
============================================
+ Coverage     22.25%   27.92%   +5.67%     
- Complexity    22439    29729    +7290     
============================================
  Files          5117     5251     +134     
  Lines        346819   368797   +21978     
  Branches      49790    53765    +3975     
============================================
+ Hits          77190   102993   +25803     
+ Misses       258466   251569    -6897     
- Partials      11163    14235    +3072     
Flag Coverage Δ
simulator-marvin-tests 23.48% <ø> (-0.36%) ⬇️
uitests 4.44% <ø> (ø)
unit-tests 14.89% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vishesh92
Copy link
Member Author

Could we somehow use random/available ports, there has to be a way to do that @vishesh92 ?

I tried using wiremock's dynamicPort, but for some reason it's not working.

@kishankavala
Copy link
Contributor

Can you create a common util similar to the following to find a free port:

try (ServerSocket socket = new ServerSocket(0)) {
            socket.setReuseAddress(true);
            return socket.getLocalPort();
        }

@DaanHoogland
Copy link
Contributor

Could we somehow use random/available ports, there has to be a way to do that @vishesh92 ?

I tried using wiremock's dynamicPort, but for some reason it's not working.

If dynamic ports are using a global registry it might work but predictability always suffers. Let's stick to this.

@weizhouapache
Copy link
Member

Can you create a common util similar to the following to find a free port:

try (ServerSocket socket = new ServerSocket(0)) {
            socket.setReuseAddress(true);
            return socket.getLocalPort();
        }

+1

btw, can we specify a port range ?

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

LGTM

@shwstppr
Copy link
Contributor

shwstppr commented Dec 6, 2023

@vishesh92 will you be adding suggested changes in this PR or can it be done as a separate PR?

@shwstppr shwstppr added this to the 4.19.0.0 milestone Dec 6, 2023
@vishesh92
Copy link
Member Author

@shwstppr Let me make the change in this PR itself.

@vishesh92 vishesh92 force-pushed the fix-intermittent-build-failures branch from 4b46737 to 1b4c9be Compare December 6, 2023 11:28
@vishesh92
Copy link
Member Author

@kishankavala @shwstppr @DaanHoogland I have made the changes to randomly select a port.

@@ -60,6 +63,15 @@ public void setUp() throws Exception {
client = new NetworkerClient(url, adminUsername, adminPassword, false, 60);
}

private int getRandomPort() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be in a util class, so that other tests can also use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM otherwise

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree. But let's do that in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should not do this. let's keep it deterministic.

@kishankavala
Copy link
Contributor

Can you create a common util similar to the following to find a free port:

try (ServerSocket socket = new ServerSocket(0)) {
            socket.setReuseAddress(true);
            return socket.getLocalPort();
        }

+1

btw, can we specify a port range ?

There are options to specify a range, but didn't look efficient to me.
org.springframework.util.SocketUtils#findAvailableTcpPort(int, int)
Its deprecated as well.

@@ -87,7 +99,7 @@ public void testListPolicies() {
" \"comment\": \"-CSBKP-\",\n" +
" \"links\": [\n" +
" {\n" +
" \"href\": \"http://localhost:9399/nwrestapi/v3/global/protectionpolicies/CSBRONZE\",\n" +
" \"href\": \"http://localhost:9400/nwrestapi/v3/global/protectionpolicies/CSBRONZE\",\n" +
Copy link
Member

Choose a reason for hiding this comment

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

need to use url instead, the port might be different as 9400

private final String url =  "http://localhost:" + port + "/nwrestapi/v3";

@@ -60,6 +63,15 @@ public void setUp() throws Exception {
client = new NetworkerClient(url, adminUsername, adminPassword, false, 60);
}

private int getRandomPort() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should not do this. let's keep it deterministic.

@vishesh92 vishesh92 force-pushed the fix-intermittent-build-failures branch from 1b4c9be to 1449aa3 Compare December 7, 2023 12:02
@vishesh92
Copy link
Member Author

vishesh92 commented Dec 7, 2023

Let's fix the intermittent build failures for now. If random port is required, let's do that in a separate PR. Reverting the change for the random port for now and moving ahead with the fixed port.

@shwstppr
Copy link
Contributor

shwstppr commented Dec 7, 2023

@vishesh92 cc @DaanHoogland @kishankavala @weizhouapache I propose we move forward with this for now to address build failure and maybe create an issue or PR with more holistic changes to make a common util class to fetch an available port for different tests (in some range). Does that work?

@weizhouapache
Copy link
Member

@vishesh92 cc @DaanHoogland @kishankavala @weizhouapache I propose we move forward with this for now to address build failure and maybe create an issue or PR with more holistic changes to make a common util class to fetch an available port for different tests (in some range). Does that work?

fine with me . let's use port 9400 for now.
if the port is used in a day in the future, we can use another port, it is not an issue.

@weizhouapache weizhouapache merged commit 4e9c4a5 into apache:main Dec 7, 2023
48 of 49 checks passed
@DaanHoogland DaanHoogland deleted the fix-intermittent-build-failures branch December 8, 2023 13:37
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants