From ee0fc34affda236b1301b4b3757d9c1511035b47 Mon Sep 17 00:00:00 2001 From: Marcin Zajaczkowski Date: Mon, 20 Mar 2017 22:09:28 +0100 Subject: [PATCH] [#44] Workaround issue with bypassed retry mechanism Introduced with sharing stagingRepositoryId. Will be fixed by #21. --- .../gradle/nexus/PromoteRepositoryTask.groovy | 2 +- .../functional/MockedFunctionalSpec.groovy | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/io/codearte/gradle/nexus/PromoteRepositoryTask.groovy b/src/main/groovy/io/codearte/gradle/nexus/PromoteRepositoryTask.groovy index e4d3f81..6456bc6 100644 --- a/src/main/groovy/io/codearte/gradle/nexus/PromoteRepositoryTask.groovy +++ b/src/main/groovy/io/codearte/gradle/nexus/PromoteRepositoryTask.groovy @@ -42,7 +42,7 @@ class PromoteRepositoryTask extends BaseStagingTask { private String getRepositoryIdFromCloseTaskOrFromServer(String stagingProfileId, RepositoryFetcher repositoryFetcher) { //TODO: Add debug statement OperationRetrier retrier = createOperationRetrier() - String repositoryId = getCloseRepositoryTask().stagingRepositoryId ?: + String repositoryId = /*getCloseRepositoryTask().stagingRepositoryId ?:*/ //Temporary disabled due to https://github.com/Codearte/gradle-nexus-staging-plugin/issues/44 retrier.doWithRetry { repositoryFetcher.getClosedRepositoryIdForStagingProfileId(stagingProfileId) } return repositoryId } diff --git a/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy b/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy index 0d0701c..075e059 100644 --- a/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy +++ b/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy @@ -7,6 +7,8 @@ import io.codearte.gradle.nexus.logic.FetcherResponseTrait import nebula.test.functional.ExecutionResult import org.gradle.api.logging.LogLevel import org.junit.Rule +import spock.lang.Ignore +import spock.lang.Issue import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.containing @@ -84,6 +86,32 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet "promoteRepository" | "closed" } + //TODO: Remove when 'stagingProfileId AND stagingRepositoryId' case is fixed + def "should reuse stagingProfileId from closeRepository in promoteRepository when called together"() { + given: + stubGetStagingProfilesWithJson(this.getClass().getResource("/io/codearte/gradle/nexus/logic/2stagingProfilesShrunkResponse.json").text) + and: + stubGetOneOpenRepositoryInFirstCallAndOneClosedInTheNext(stagingProfileId) + and: + stubSuccessfulCloseRepositoryWithProfileId(stagingProfileId) + and: + stubSuccessfulPromoteRepositoryWithProfileId(stagingProfileId) + and: + buildFile << """ + ${getApplyPluginBlock()} + ${getDefaultConfigurationClosure()} + """.stripIndent() + when: + ExecutionResult result = runTasksSuccessfully("closeRepository", "promoteRepository") + then: + result.wasExecuted("closeRepository") + result.wasExecuted("promoteRepository") + and: + verify(2, getRequestedFor(urlEqualTo("/staging/profile_repositories/$stagingProfileId"))) + verify(1, getRequestedFor(urlEqualTo("/staging/profiles"))) + } + + @Ignore("Due to https://github.com/Codearte/gradle-nexus-staging-plugin/issues/44") def "should reuse stagingProfileId AND stagingRepositoryId from closeRepository in promoteRepository when called together"() { given: stubGetStagingProfilesWithJson(this.getClass().getResource("/io/codearte/gradle/nexus/logic/2stagingProfilesShrunkResponse.json").text) @@ -166,7 +194,8 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet def "should call close and promote in closeAndPromoteRepository task"() { given: - stubGetOneOpenRepositoryAndOneClosedInFirstCallAndTwoClosedInTheNext(stagingProfileId) +// stubGetOneOpenRepositoryAndOneClosedInFirstCallAndTwoClosedInTheNext(stagingProfileId) //TODO: Temporary disabled due to #44 + stubGetOneOpenRepositoryInFirstCallAndOneClosedInTheNext(stagingProfileId) and: stubSuccessfulCloseRepositoryWithProfileId(stagingProfileId) and: