Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/id in test cycle results #638

Merged
merged 6 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fixed the Document History of the IVP & IVR is not being generated ([#627](https://github.com/opendevstack/ods-jenkins-shared-library/pull/627))
- Fixed Test name/summary in DTP/DTR documents ([#625](https://github.com/opendevstack/ods-jenkins-shared-library/pull/625)).
- Fix A "null" string is added in the Section 3.1 of the CFTR when the Description of the Zephyr Unit Test doesn't has a Description ([#634](https://github.com/opendevstack/ods-jenkins-shared-library/pull/634))
- Change association with the current release in the test cycles of previewed execution ([#638](https://github.com/opendevstack/ods-jenkins-shared-library/pull/638))

## [3.0] - 2020-08-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.ods.util.IPipelineSteps
import org.ods.orchestration.util.MROPipelineUtil
import org.ods.orchestration.util.Project

@SuppressWarnings(['IfStatementBraces', 'LineLength', 'AbcMetric', 'Instanceof'])
@SuppressWarnings(['IfStatementBraces', 'LineLength', 'AbcMetric', 'Instanceof', 'CyclomaticComplexity'])
class JiraUseCaseZephyrSupport extends AbstractJiraUseCaseSupport {

private JiraZephyrService zephyr
Expand All @@ -26,15 +26,16 @@ class JiraUseCaseZephyrSupport extends AbstractJiraUseCaseSupport {
if (!testIssues?.isEmpty()) {
def buildParams = this.project.buildParams

def versionId = this.project.version?.id ?: '-1'
def versionId = this.project.version?.id ?: project.loadVersionDataFromJira(buildParams.changeId)?.id
def testCycles = this.zephyr.getTestCycles(this.project.id, versionId)

// Zephyr test cycle properties
def name = buildParams.targetEnvironmentToken + ': Build ' + this.steps.env.BUILD_ID
def name = (buildParams.version == 'WIP'? "Preview: Build ": "${buildParams.targetEnvironmentToken}: Build ") + this.steps.env.BUILD_ID
def build = this.steps.env.BUILD_URL
def environment = buildParams.targetEnvironment

testCycleId = testCycles.find { it.value instanceof Map && it.value.name == name && it.value.build == build && it.value.environment == environment }?.key

if (!testCycleId) {
testCycleId = this.zephyr.createTestCycle(this.project.id, versionId, name, build, environment).id
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/ods/orchestration/util/Project.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ class Project {
loadVersionDataFromJira(this.buildParams.version)
}

protected Map loadVersionDataFromJira(String versionName) {
Map loadVersionDataFromJira(String versionName) {
if (!this.jiraUseCase) return [:]
if (!this.jiraUseCase.jira) return [:]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,18 @@ class JiraUseCaseZephyrSupportSpec extends SpecHelper {
_ * zephyr.createTestExecutionForIssue(*_) >> ["1": []]
1 * support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)
}

def "generate test cycle for developer previews"() {
given:
def testIssues = createJiraTestIssues()
def testResults = createTestResults()
project.buildParams.version = 'WIP'

when:
support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)

then:
1 * zephyr.createTestCycle(project.id, "11100", "Preview: Build " + steps.env.BUILD_ID, steps.env.BUILD_URL, project.buildParams.targetEnvironment) >> [id: "111"]
_ * zephyr.createTestExecutionForIssue(*_) >> ["1": []]
}
}