Skip to content

Commit

Permalink
[#76] Explicitly creating staging repository in Nexus - WIP
Browse files Browse the repository at this point in the history
Internal implementation in the Exploratory E2E tests to verify it
with Travis.
  • Loading branch information
szpak committed Nov 12, 2018
1 parent 5b69802 commit 281f5c3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package io.codearte.gradle.nexus.functional.e2e

import io.codearte.gradle.nexus.functional.BaseNexusStagingFunctionalSpec
import nebula.test.functional.ExecutionResult
import spock.lang.Ignore
import spock.lang.Stepwise

@Stepwise
@Ignore("Temporary to verify staging repository uplaod from travis in exploratory e2e tests")
class BasicSmokeE2ESpec extends BaseNexusStagingFunctionalSpec implements E2ESpecHelperTrait {

def "should get staging profile"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.codearte.gradle.nexus.functional.BaseNexusStagingFunctionalSpec
import io.codearte.gradle.nexus.infra.SimplifiedHttpJsonRestClient
import io.codearte.gradle.nexus.logic.OperationRetrier
import io.codearte.gradle.nexus.logic.RepositoryCloser
import io.codearte.gradle.nexus.logic.RepositoryCreator
import io.codearte.gradle.nexus.logic.RepositoryDropper
import io.codearte.gradle.nexus.logic.RepositoryFetcher
import io.codearte.gradle.nexus.logic.RepositoryReleaser
Expand Down Expand Up @@ -36,6 +37,7 @@ class ExploratoryE2ESpec extends BaseNexusStagingFunctionalSpec implements E2ESp
@NotYetImplemented
def "remove all staging repositories if exist as clean up"() {}

//TODO: Remove "should" prefix, it's default by convention
def "should get staging profile id from server e2e"() {
given:
StagingProfileFetcher fetcher = new StagingProfileFetcher(client, E2E_SERVER_BASE_PATH)
Expand All @@ -45,25 +47,39 @@ class ExploratoryE2ESpec extends BaseNexusStagingFunctionalSpec implements E2ESp
stagingProfileId == E2E_STAGING_PROFILE_ID
}

def "should upload artifacts to server"() {
def "should create staging repository explicitly e2e"() {
given:
RepositoryCreator creator = new RepositoryCreator(client, E2E_SERVER_BASE_PATH)
when:
String stagingRepositoryId = creator.createStagingRepositoryAndReturnId(E2E_STAGING_PROFILE_ID)
then:
println stagingRepositoryId
stagingRepositoryId.startsWith("iogitlabnexus-at")
and:
propagateStagingRepositoryIdToAnotherTest(stagingRepositoryId)
}

def "should upload artifacts to server e2e"() {
given:
assert resolvedStagingRepositoryId
and:
copyResources("sampleProjects//nexus-at-minimal", "")
when:
ExecutionResult result = runTasksSuccessfully('uploadArchives')
ExecutionResult result = runTasksSuccessfully('uploadArchives',
"-Pe2eRepositoryUrl=${E2E_SERVER_BASE_PATH}staging/deployByRepositoryId/${resolvedStagingRepositoryId}")
then:
result.standardOutput.contains('Uploading: io/gitlab/nexus-at/minimal/nexus-at-minimal/')
}

//TODO: Adjust to (optionally) just get repository ID in getNonTransitioningRepositoryStateById()
def "should get open repository id from server e2e"() {
given:
RepositoryFetcher fetcher = new RepositoryFetcher(client, E2E_SERVER_BASE_PATH)
when:
String stagingRepositoryId = fetcher.getOpenRepositoryIdForStagingProfileId(E2E_STAGING_PROFILE_ID)
then:
println stagingRepositoryId
stagingRepositoryId.startsWith("iogitlabnexus-at")
and:
propagateStagingRepositoryIdToAnotherTest(stagingRepositoryId)
stagingRepositoryId == resolvedStagingRepositoryId
}

def "should get not in transition open repository state by repository id from server e2e"() {
Expand Down
2 changes: 1 addition & 1 deletion src/funcTest/resources/sampleProjects/nexus-at-minimal
Submodule nexus-at-minimal updated from c6abaa to 2ab799
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class SimplifiedHttpJsonRestClient {
return (Map) sendRequestHandlingErrors(uri, null, restClient.&get, RequestType.GET).data
}

void post(String uri, Map content) {
sendRequestHandlingErrors(uri, content, restClient.&post, RequestType.POST)
Map post(String uri, Map content) {
return (Map) sendRequestHandlingErrors(uri, content, restClient.&post, RequestType.POST).data
}

private HttpResponseDecorator sendRequestHandlingErrors(String uri, Map content, Closure<Object> clientMethodHandler, RequestType requestTypeName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.codearte.gradle.nexus.logic

import groovy.transform.InheritConstructors
import groovy.util.logging.Slf4j
import io.codearte.gradle.nexus.infra.SimplifiedHttpJsonRestClient

//@InheritConstructors //TODO: Why broken???
@Slf4j
class RepositoryCreator extends BaseOperationExecutor {

RepositoryCreator(SimplifiedHttpJsonRestClient client, String nexusUrl) {
super(client, nexusUrl)
}

String createStagingRepositoryAndReturnId(String stagingProfileId) {
log.info("Creating staging repository for staging profile '$stagingProfileId'")
Map responseAsMap = client.post(nexusUrl + "/staging/profiles/${stagingProfileId}/start",
[data: [description: "Explicitly created by gradle-nexus-staging-plugin"]])

log.info("Raw response as map: $responseAsMap")
String repositoryId = responseAsMap.data.stagedRepositoryId
log.info("Created staging repository with id: $repositoryId")
return repositoryId
}
}

0 comments on commit 281f5c3

Please sign in to comment.