-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make staging repository operations retry on failure
- Loading branch information
1 parent
26f4f9c
commit 491991e
Showing
4 changed files
with
99 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
publish/test/src/coursier/publish/sonatype/SonatypeTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package src.coursier.publish.sonatype | ||
|
||
import coursier.publish.sonatype.SonatypeApi | ||
import sttp.client3.testing.SttpBackendStub | ||
|
||
import utest._ | ||
|
||
object SonatypeTests extends TestSuite { | ||
val tests = Tests { | ||
test("Retry sonatype repository actions") { | ||
var count = 0 | ||
val mockBackend = SttpBackendStub.synchronous | ||
.whenRequestMatches { _ => count += 1; count < 6 } | ||
.thenRespondServerError() | ||
.whenRequestMatches(_ => count >= 6) | ||
.thenRespondOk() | ||
|
||
{ | ||
val sonatypeApi20 = SonatypeApi( | ||
mockBackend, | ||
base = "https://oss.sonatype.org", | ||
authentication = None, | ||
verbosity = 0, | ||
retryOnTimeout = 1, | ||
stagingRepoRetries = 20 | ||
) | ||
|
||
sonatypeApi20.sendPromoteStagingRepositoryRequest( | ||
SonatypeApi.Profile("id", "name", "uri"), | ||
"repo", | ||
"description" | ||
) | ||
|
||
assert(count == 6) | ||
} | ||
|
||
count = 0 | ||
|
||
{ | ||
val sonatypeApi3 = SonatypeApi( | ||
mockBackend, | ||
base = "https://oss.sonatype.org", | ||
authentication = None, | ||
verbosity = 0, | ||
retryOnTimeout = 1 | ||
) | ||
|
||
try sonatypeApi3.sendPromoteStagingRepositoryRequest( | ||
SonatypeApi.Profile("id", "name", "uri"), | ||
"repo", | ||
"description" | ||
) | ||
catch { | ||
case e: Exception | ||
if e.getMessage == "Failed to get uri/promote (http status: 500, response: Internal server error)" => | ||
case _: Throwable => assert(false) | ||
} | ||
|
||
assert(count == 3) | ||
} | ||
} | ||
} | ||
} |