Skip to content

Commit

Permalink
jobs/bodhi-trigger: add reporting to ResultsDB
Browse files Browse the repository at this point in the history
Call out to the new `resultsdb-report` script in cosa to report test
results back to ResultsDB. Report when first running and then again with
final test results.

Just this alone seems sufficient for the results to show up in Bodhi's
"Automated Tests" tab.

With this, we'll then be able to work on adding policies in Greenwave.
  • Loading branch information
jlebon committed Nov 16, 2023
1 parent 999c3d3 commit 5e59cff
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
16 changes: 16 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ oc annotate secret/github-coreosbot-token-username-password \
jenkins.io/credentials-description="GitHub coreosbot token as username/password"
```

### Create ResultsDB authentication secret

Create the ResultsDB authentication secret (available in BitWarden).

```
RDB_USERNAME=username
RDB_PASSWORD=password
oc create secret generic resultsdb-auth \
--from-literal=username=${RDB_USERNAME} \
--from-literal=password=${RDB_PASSWORD}
oc label secret/resultsdb-auth \
jenkins.io/credentials-type=usernamePassword
oc annotate secret/resultsdb-auth \
jenkins.io/credentials-description="ResultsDB authentication"
```

### Create pipeline configmap

Run:
Expand Down
37 changes: 35 additions & 2 deletions jobs/bodhi-trigger.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ if (test_mode) {
cosaPod(cpu: "0.1", kvm: false) {
def test = null

stage("Report Running") {
withCredentials([usernamePassword(credentialsId: 'resultsdb-auth',
usernameVariable: 'RDB_USERNAME',
passwordVariable: 'RDB_PASSWORD')]) {
shwrap("""/usr/lib/coreos-assembler/resultsdb-report \
--testcase cosa.build-and-test \
--testcase-url ${JENKINS_URL}/job/test-override \
--testrun-url ${JENKINS_URL}/job/test-override \
--outcome RUNNING --advisory ${msg.update.updateid} \
--stream ${stream}
""")
}
}

stage("Test") {
test = build(job: 'test-override', propagate: false, wait: true,
parameters: [
Expand All @@ -214,8 +228,27 @@ cosaPod(cpu: "0.1", kvm: false) {
])
}

stage("Report") {
// XXX: report result to resultsdb
stage("Report Completion") {
def outcome
if (test.result == 'SUCCESS') {
outcome = 'PASSED'
} else if (test.result == 'UNSTABLE') {
outcome = 'NEEDS_INSPECTION'
} else {
outcome = 'FAILED'
}
def blueocean_url = "${JENKINS_URL}/blue/organizations/jenkins/test-override/detail/test-override/${test.number}"
withCredentials([usernamePassword(credentialsId: 'resultsdb-auth',
usernameVariable: 'RDB_USERNAME',
passwordVariable: 'RDB_PASSWORD')]) {
shwrap("""/usr/lib/coreos-assembler/resultsdb-report \
--testcase cosa.build-and-test \
--testcase-url ${JENKINS_URL}/job/test-override \
--testrun-url ${blueocean_url} \
--outcome ${outcome} --advisory ${msg.update.updateid} \
--stream ${stream}
""")
}
}
}

Expand Down

0 comments on commit 5e59cff

Please sign in to comment.