Skip to content

Commit f3ff00f

Browse files
Fix TestArtifactoryClientCert flakiness on windows.. Adding some retries on Windows when this error happens. (#3366)
Instead of the certificate error we might have "wsarecv: An established connection was aborted" which fails the test Co-authored-by: github-actions[bot] <[email protected]>
1 parent 4438471 commit f3ff00f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

artifactory_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,12 +1663,29 @@ func TestArtifactoryClientCert(t *testing.T) {
16631663

16641664
// The server is requiring client certificates
16651665
// Without loading a valid client certificate, we expect all actions to fail due to error: "tls: bad certificate"
1666+
// On Windows, the error can be "wsarecv: An established connection was aborted" (flaky).
16661667
searchCmd := generic.NewSearchCommand()
16671668
searchCmd.SetServerDetails(serverDetails).SetSpec(fileSpec)
1669+
16681670
reader, err := searchCmd.Search()
16691671
if reader != nil {
16701672
readerCloseAndAssert(t, reader)
16711673
}
1674+
require.Error(t, err, "Expected a connection failure, since client did not provide a client certificate. Connection however is successful")
1675+
1676+
if runtime.GOOS == "windows" && strings.Contains(err.Error(), "wsarecv") {
1677+
for attempt := 1; attempt < 3; attempt++ {
1678+
reader, err = searchCmd.Search()
1679+
if reader != nil {
1680+
readerCloseAndAssert(t, reader)
1681+
}
1682+
require.Error(t, err, "Expected a connection failure, since client did not provide a client certificate. Connection however is successful")
1683+
if !strings.Contains(err.Error(), "wsarecv") {
1684+
break
1685+
}
1686+
time.Sleep(200 * time.Millisecond)
1687+
}
1688+
}
16721689
assert.ErrorContains(t, err, "certificate", "Expected a connection failure, since client did not provide a client certificate. Connection however is successful")
16731690

16741691
// Inject client certificates, we expect the search to succeed

0 commit comments

Comments
 (0)