[ 
https://issues.apache.org/jira/browse/YUNIKORN-3337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated YUNIKORN-3337:
-------------------------------------
    Labels: pull-request-available  (was: )

> Fix connection refused error in webservice unit tests 
> ------------------------------------------------------
>
>                 Key: YUNIKORN-3337
>                 URL: https://issues.apache.org/jira/browse/YUNIKORN-3337
>             Project: Apache YuniKorn
>          Issue Type: Bug
>          Components: test - unit
>            Reporter: weichen lai
>            Assignee: weichen lai
>            Priority: Minor
>              Labels: pull-request-available
>
> When running unit tests in `pkg/webservice` locally (e.g., under WSL via 
> `make test`), tests can fail with `connection refused` errors:             
> {code:java}
> 2026-07-26T10:09:29.610+0800    INFO    core.rest       
> webservice/streaming_limit.go:54        Reloading streaming limit settings
> 2026-07-26T10:09:29.611+0800    INFO    core.rest       
> webservice/webservice.go:74     web-app started {"port": 9080}
> --- FAIL: Test_RedirectDebugHandler (0.00s)
>     --- FAIL: Test_RedirectDebugHandler/statedump (0.00s)
>         webservice_test.go:67: assertion failed: error is not nil: Get 
> "http://localhost:9080/ws/v1/fullstatedump": dial tcp 127.0.0.1:9080: 
> connect: connection refused: unexpected error returned
>     --- FAIL: Test_RedirectDebugHandler/stacks (0.00s)
>         webservice_test.go:67: assertion failed: error is not nil: Get 
> "http://localhost:9080/ws/v1/stack": dial tcp 127.0.0.1:9080: connect: 
> connection refused: unexpected error returned
> 2026-07-26T10:09:29.612+0800    INFO    core.rest       
> webservice/webservice.go:74     web-app started {"port": 9080}
> --- FAIL: Test_RouterHandling (0.00s)
>     webservice_test.go:86: assertion failed: error is not nil: Post 
> "http://localhost:9080/ws/v1/clusters": dial tcp 127.0.0.1:9080: connect: 
> connection refused: unexpected error returned
> 2026-07-26T10:09:29.613+0800    INFO    core.rest       
> webservice/webservice.go:74     web-app started {"port": 9080}
> --- FAIL: Test_HeaderChecks (0.00s)
> {code}
>                                                                               
>                                                                    
> This happens because WebService.StartWebApp() launches 
> httpServer.ListenAndServe() asynchronously in a goroutine and returns 
> immediately. Under local environments like WSL with slight CPU scheduling or 
> socket binding delays, test cases issue HTTP requests in less than 1 ms 
> (0.00s), attempting to connect before the OS finishes binding port 9080.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to