-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
158 changed files
with
19,058 additions
and
1,637 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChange.kt
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package org.octopusden.octopus.vcsfacade.client.common.dto | ||
|
||
data class FileChange(val type: FileChangeType, val path: String, val link: String) | ||
data class FileChange(val type: FileChangeType, val path: String, val link: String) : Comparable<FileChange> { | ||
override fun compareTo(other: FileChange) = path compareTo other.path | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
vcs-facade: | ||
job: | ||
fast-work-timout-secs: 0 | ||
fast-work-timout-secs: 0 #check retry mechanism | ||
retry-interval-secs: 1 |
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
102 changes: 78 additions & 24 deletions
102
ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitea.kt
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 |
---|---|---|
@@ -1,36 +1,90 @@ | ||
package org.octopusden.octopus.vcsfacade | ||
|
||
import java.util.stream.Stream | ||
import java.net.HttpURLConnection | ||
import java.net.URI | ||
import java.util.Base64 | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.octopusden.octopus.infrastructure.common.test.dto.NewChangeSet | ||
import org.octopusden.octopus.infrastructure.gitea.test.GiteaTestClient | ||
|
||
private const val VCS_HOST = "gitea:3000" | ||
import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest | ||
|
||
@EnabledIfSystemProperty(named = "test.profile", matches = "gitea") | ||
class VcsFacadeFunctionalTestGitea : BaseVcsFacadeFunctionalTest( | ||
GiteaTestClient("http://localhost:3000", GITEA_USER, GITEA_PASSWORD, VCS_HOST), | ||
"ssh://git@$VCS_HOST:%s/%s.git" | ||
TestService.Gitea(GITEA_HOST, GITEA_EXTERNAL_HOST, true), | ||
GiteaTestClient("http://$GITEA_HOST", GITEA_USER, GITEA_PASSWORD, GITEA_EXTERNAL_HOST) | ||
) { | ||
//TODO: test using opensearch | ||
override fun issueCommits(): Stream<Arguments> = Stream.of( | ||
Arguments.of("ABSENT-1", emptyList<String>()), | ||
) | ||
@BeforeAll | ||
fun beforeAllVcsFacadeFunctionalTestGitea() { | ||
val url = URI("http://$GITEA_HOST/api/v1/repos/$GROUP/$REPOSITORY_2/hooks").toURL() | ||
with(url.openConnection() as HttpURLConnection) { | ||
setRequestMethod("POST") | ||
setRequestProperty( | ||
"Authorization", | ||
"Basic " + Base64.getEncoder().encodeToString("$GITEA_USER:$GITEA_PASSWORD".toByteArray()) | ||
) | ||
setRequestProperty("Content-Type", "application/json") | ||
setRequestProperty("Accept", "application/json") | ||
setDoOutput(true) | ||
outputStream.use { | ||
it.write(WEBHOOK_CREATION_REQUEST.toByteArray()) | ||
} | ||
if (getResponseCode() / 100 != 2) { | ||
throw RuntimeException("Unable to create webhook for '$GROUP:$REPOSITORY_2'") | ||
} | ||
} | ||
(testService as TestService.Gitea).scan(GROUP, REPOSITORY_2) | ||
} | ||
|
||
override val exceptionsMessageInfo: Map<String, String> by lazy { | ||
mapOf( | ||
"absent-repo" to "The target couldn't be found.", | ||
"commitById" to DEFAULT_ID, | ||
"commitsException_1" to "object does not exist [id: $DEFAULT_ID, rel_path: ]", | ||
"commitsException_2" to "'hashOrRef' and 'date' can not be used together", | ||
"commitsException_3" to "Cannot find commit '${MESSAGE_3.commitId(REPOSITORY)}' in commit graph for commit '${ | ||
MESSAGE_1.commitId( | ||
REPOSITORY | ||
) | ||
}' in '$PROJECT:$REPOSITORY'", | ||
"pr_1" to "GetUserByName", | ||
"pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'", | ||
"pr_3" to "Target branch 'absent' not found in '$PROJECT:$REPOSITORY'" | ||
@Test | ||
fun webhooksTest() { | ||
var success = false | ||
testClient.commit( | ||
NewChangeSet("Commit (ISSUE-10)", testService.sshUrl(GROUP, REPOSITORY_2), "ISSUE-10"), | ||
"master" | ||
) | ||
for (i in 1..5) { | ||
Thread.sleep(1000L * i) | ||
success = with(findByIssueKey("ISSUE-10")) { | ||
branches.size == 1 && commits.size == 1 && pullRequests.size == 0 | ||
} | ||
if (success) break | ||
} | ||
if (!success) throw RuntimeException("Commit and branch for ISSUE-10 have not been registered") | ||
createPullRequest( | ||
testService.sshUrl(GROUP, REPOSITORY_2), | ||
CreatePullRequest("ISSUE-10", "master", "Webhook test PR", "Description ISSUE-10") | ||
) | ||
for (i in 1..5) { | ||
Thread.sleep(1000L * i) | ||
success = with(findByIssueKey("ISSUE-10")) { | ||
branches.size == 1 && commits.size == 1 && pullRequests.size == 1 | ||
} | ||
if (success) break | ||
} | ||
if (!success) throw RuntimeException("Pull request for ISSUE-10 has not been registered") | ||
} | ||
|
||
companion object { | ||
//<editor-fold defaultstate="collapsed" desc="webhook creation request"> | ||
const val WEBHOOK_CREATION_REQUEST = """{ | ||
"type": "gitea", | ||
"branch_filter": "*", | ||
"config": { | ||
"content_type": "json", | ||
"url": "http://vcs-facade:8080/rest/api/1/indexer/gitea/webhook", | ||
"secret": "b59dd966-2445-4c84-b631-49502427477e" | ||
}, | ||
"events": [ | ||
"create", | ||
"delete", | ||
"push", | ||
"pull_request" | ||
], | ||
"authorization_header": "", | ||
"active": true | ||
}""" | ||
//</editor-fold> | ||
} | ||
} |
27 changes: 3 additions & 24 deletions
27
ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitlab.kt
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 |
---|---|---|
@@ -1,31 +1,10 @@ | ||
package org.octopusden.octopus.vcsfacade | ||
|
||
import java.util.stream.Stream | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.octopusden.octopus.infrastructure.gitlab.test.GitlabTestClient | ||
|
||
private const val VCS_HOST = "gitlab:8990" | ||
|
||
@EnabledIfSystemProperty(named = "test.profile", matches = "gitlab") | ||
class VcsFacadeFunctionalTestGitlab : BaseVcsFacadeFunctionalTest( | ||
GitlabTestClient("http://localhost:8990", GITLAB_USER, GITLAB_PASSWORD, VCS_HOST), | ||
"ssh://git@$VCS_HOST:%s/%s.git" | ||
) { | ||
override fun issueCommits(): Stream<Arguments> = Stream.of( | ||
Arguments.of("ABSENT-1", emptyList<String>()), | ||
) | ||
|
||
override val exceptionsMessageInfo: Map<String, String> by lazy { | ||
mapOf( | ||
"absent-repo" to "Repository '$PROJECT:absent' does not exist.", | ||
"commitById" to "Commit '$DEFAULT_ID' does not exist in repository '$PROJECT:$REPOSITORY'.", | ||
"commitsException_1" to "Commit '$DEFAULT_ID' does not exist in repository '$PROJECT:$REPOSITORY'.", | ||
"commitsException_2" to "'hashOrRef' and 'date' can not be used together", | ||
"commitsException_3" to "Can't find commit '${MESSAGE_3.commitId(REPOSITORY)}' in graph but it exists in the '$PROJECT:$REPOSITORY'", | ||
"pr_1" to "Group 'absent' does not exist.", | ||
"pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'", | ||
"pr_3" to "Target branch 'absent' not found in '$PROJECT:$REPOSITORY'" | ||
) | ||
} | ||
} | ||
TestService.Gitlab(GITLAB_HOST, GITLAB_EXTERNAL_HOST), | ||
GitlabTestClient("http://$GITLAB_HOST", GITLAB_USER, GITLAB_PASSWORD, GITLAB_EXTERNAL_HOST) | ||
) |
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
Oops, something went wrong.