2024-02-14 15:46:15 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
library 'status-jenkins-lib@v1.8.6'
|
|
|
|
|
2023-07-06 13:30:43 +00:00
|
|
|
pipeline {
|
|
|
|
agent {
|
|
|
|
dockerfile {
|
|
|
|
label 'linux'
|
|
|
|
dir 'ci'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(
|
|
|
|
name: 'ITERATIONS',
|
|
|
|
description: 'Number of repeated integration test runs',
|
|
|
|
defaultValue: params.ITERATIONS ?: '1000'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
/* Avoid cache poisoning by other jobs. */
|
|
|
|
GOCACHE = "${env.WORKSPACE_TMP}/go-build"
|
|
|
|
GOPATH = "${env.WORKSPACE_TMP}/go"
|
|
|
|
RUST_BACKTRACE = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '20',
|
|
|
|
daysToKeepStr: '30',
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2023-08-07 15:39:24 +00:00
|
|
|
stage('Integration Tests') {
|
|
|
|
matrix {
|
|
|
|
axes {
|
|
|
|
axis {
|
|
|
|
name 'FEATURE'
|
2023-10-02 08:41:08 +00:00
|
|
|
values 'libp2p'
|
2023-08-07 15:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stages {
|
2023-09-18 14:10:05 +00:00
|
|
|
stage('Tests') {
|
|
|
|
options {
|
|
|
|
lock('sync-integration-${env.GIT_COMMIT}')
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage("BuildAndTest") {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
/* To prevent rebuilding node for each test, tests are defined here */
|
|
|
|
def tests = ['ten_nodes_happy', 'two_nodes_happy', 'ten_nodes_one_down']
|
|
|
|
|
2023-10-27 17:54:56 +00:00
|
|
|
def report = runBuildAndTestsForFeature(FEATURE, tests)
|
|
|
|
writeFile(file: "${WORKSPACE}/report.txt", text: report)
|
2023-09-18 14:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-07 15:39:24 +00:00
|
|
|
}
|
2023-07-06 13:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-17 18:16:05 +00:00
|
|
|
|
2023-07-06 13:30:43 +00:00
|
|
|
post {
|
2024-02-14 15:46:15 +00:00
|
|
|
always { script {
|
|
|
|
def report = readFile("${WORKSPACE}/report.txt").trim()
|
|
|
|
discord.send(
|
|
|
|
header: "Nightly Integration Tests ${currentBuild.currentResult}: ${report}",
|
|
|
|
cred: 'nomos-node-discord-commits-webhook',
|
|
|
|
)
|
|
|
|
} }
|
2023-07-06 13:30:43 +00:00
|
|
|
cleanup { cleanWs() }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 15:39:24 +00:00
|
|
|
def runBuildAndTestsForFeature(feature, tests) {
|
|
|
|
echo "Building node for feature: ${feature}"
|
2023-09-19 09:00:51 +00:00
|
|
|
def build_node = "cargo build --all --no-default-features --features ${feature}"
|
2023-08-07 15:39:24 +00:00
|
|
|
|
2023-09-18 08:25:27 +00:00
|
|
|
if (sh(script: build_node, returnStatus: true) != 0) {
|
2023-10-27 17:54:56 +00:00
|
|
|
return reportError("Build '${feature}' node failed")
|
2023-08-07 15:39:24 +00:00
|
|
|
}
|
2023-09-18 08:25:27 +00:00
|
|
|
|
2023-08-07 15:39:24 +00:00
|
|
|
int iterations = params.ITERATIONS.toInteger()
|
2023-10-27 17:54:56 +00:00
|
|
|
return runTestCases(tests, iterations)
|
2023-08-07 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def runTestCases(test_cases, iterations) {
|
|
|
|
for (int i = 0; i < iterations; i++) {
|
|
|
|
echo "Running iteration ${i + 1} of ${iterations}"
|
|
|
|
|
|
|
|
for (test_case in test_cases) {
|
2023-08-10 11:20:19 +00:00
|
|
|
def test_cmd = "cargo test -p tests --all --no-default-features --features ${feature} ${test_case}"
|
2023-08-07 15:39:24 +00:00
|
|
|
if (sh(script: test_cmd, returnStatus: true) != 0) {
|
2023-10-27 17:54:56 +00:00
|
|
|
return reportError("Test '${test_case}' failed on iteration ${i + 1}")
|
2023-08-07 15:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-27 17:54:56 +00:00
|
|
|
|
|
|
|
return "${iterations}/${iterations} iterations succeeded"
|
2023-08-07 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
2023-10-27 17:54:56 +00:00
|
|
|
def reportError(e) {
|
|
|
|
error(e)
|
|
|
|
return e
|
|
|
|
}
|