forked from opensearch-project/opensearch-build
-
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.
Data Prepper Unit Test & Test Refactoring (opensearch-project#1451)
* Added a unit test for the Data Prepper build. Signed-off-by: David Venable <[email protected]>
- Loading branch information
1 parent
4194dfd
commit 77e4bea
Showing
5 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package jenkins.tests | ||
|
||
import jenkins.tests.CommonPipelineTest | ||
import org.junit.Before | ||
|
||
/** | ||
* Base class for testing jobs which do not need the implementation | ||
* details of the Jenkins library exposed. | ||
*/ | ||
abstract class BaseJobPipelineTest extends CommonPipelineTest { | ||
@Override | ||
@Before | ||
void setUp() { | ||
super.setUp() | ||
|
||
binding.setVariable('scm', {}) | ||
helper.registerAllowedMethod('legacySCM', [Closure.class], null) | ||
helper.registerAllowedMethod("library", [Map.class], {}) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package jenkins.tests | ||
|
||
import com.lesfurets.jenkins.unit.RegressionTestHelper | ||
import com.lesfurets.jenkins.unit.declarative.DeclarativePipelineTest | ||
import org.junit.Before | ||
|
||
|
||
/** | ||
* This base test class holds common functions, but does not perform | ||
* any additional setup. Test authors can extend from this class if | ||
* they don't need common setup. Otherwise, please see the sub-classes. | ||
*/ | ||
abstract class CommonPipelineTest extends DeclarativePipelineTest { | ||
@Override | ||
@Before | ||
void setUp() { | ||
super.setUp() | ||
} | ||
|
||
void testPipeline(String jenkinsScript, String regressionFilename = null) { | ||
runScript(jenkinsScript) | ||
RegressionTestHelper.testNonRegression(helper, regressionFilename ?: jenkinsScript) | ||
assertJobStatusSuccess() | ||
printCallStack() | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import jenkins.tests.BaseJobPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class TestDataPrepperDistributionArtifacts extends BaseJobPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
super.setUp() | ||
|
||
binding.setVariable('VERSION', '0.22.1') | ||
binding.setVariable('BRANCH', 'refs/tags/0.22.1') | ||
|
||
binding.setVariable('JOB_BASE_NAME', 'data-prepper-distribution-artifacts') | ||
binding.setVariable('BUILD_NUMBER', '7654321') | ||
binding.setVariable('WORKSPACE', '/tmp/workspace') | ||
|
||
binding.setVariable('ARTIFACT_BUCKET_NAME', 'job-s3-bucket-name') | ||
|
||
helper.registerAllowedMethod('checkout', [Map], {}) | ||
helper.registerAllowedMethod('signArtifacts', [Map], {}) | ||
helper.registerAllowedMethod('uploadToS3', [Map], {}) | ||
helper.registerAllowedMethod('printArtifactDownloadUrlsForStaging', [Map], {}) | ||
helper.registerAllowedMethod('postCleanup', [], {}) | ||
} | ||
|
||
@Test | ||
void dataPrepperDistributionArtifacts_builds_consistently() { | ||
testPipeline('jenkins/data-prepper/distribution-artifacts.jenkinsfile', | ||
'tests/jenkins/jobs/data-prepper/distribution-artifacts.jenkinsfile') | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/jenkins/jobs/data-prepper/distribution-artifacts.jenkinsfile.txt
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
distribution-artifacts.run() | ||
distribution-artifacts.legacySCM(groovy.lang.Closure) | ||
distribution-artifacts.library({identifier=jenkins@20211123, retriever=null}) | ||
distribution-artifacts.pipeline(groovy.lang.Closure) | ||
distribution-artifacts.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ci-runner-centos7-v1, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) | ||
distribution-artifacts.stage(Build Data Prepper, groovy.lang.Closure) | ||
distribution-artifacts.script(groovy.lang.Closure) | ||
distribution-artifacts.checkout({changelog=false, poll=false, scm={$class=GitSCM, branches=[{name=refs/tags/0.22.1}], userRemoteConfigs=[{url=https://github.com/opensearch-project/data-prepper.git}]}}) | ||
distribution-artifacts.sh(./gradlew clean :release:archives:linux:linuxTar -Prelease) | ||
distribution-artifacts.sh({script=find /tmp/workspace/release/archives/linux/build/distributions | sed -n "s|^/tmp/workspace/release/archives/linux/build/distributions/||p", returnStdout=true}) | ||
distribution-artifacts.stage(Sign Artifacts, groovy.lang.Closure) | ||
distribution-artifacts.script(groovy.lang.Closure) | ||
distribution-artifacts.signArtifacts({artifactPath=/tmp/workspace/release/archives/linux/build/distributions, signatureType=.sig, distributionPlatform=linux}) | ||
distribution-artifacts.stage(Upload Artifacts to Staging Distribution Bucket, groovy.lang.Closure) | ||
distribution-artifacts.script(groovy.lang.Closure) | ||
distribution-artifacts.uploadToS3({sourcePath=/tmp/workspace/release/archives/linux/build/distributions, bucket=job-s3-bucket-name, path=data-prepper-distribution-artifacts/0.22.1/7654321/builds/signed}) | ||
distribution-artifacts.printArtifactDownloadUrlsForStaging({artifactFileNames=[bbb, bbb.sig, ccc, ccc.sig], uploadPath=data-prepper-distribution-artifacts/0.22.1/7654321/builds/signed}) | ||
distribution-artifacts.script(groovy.lang.Closure) | ||
distribution-artifacts.postCleanup() |