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.
Add yum repo for RPM of OS and OSD in staging (opensearch-project#1960)
* add createrepo for rpm Signed-off-by: Tianle Huang <[email protected]> * move to assemble Signed-off-by: Tianle Huang <[email protected]> * typo Signed-off-by: Tianle Huang <[email protected]> * fix Signed-off-by: Tianle Huang <[email protected]> * add repo file Signed-off-by: Tianle Huang <[email protected]> * add logs Signed-off-by: Tianle Huang <[email protected]> * fix Signed-off-by: Tianle Huang <[email protected]> * add file path Signed-off-by: Tianle Huang <[email protected]> * create new groovy Signed-off-by: Tianle Huang <[email protected]> * fix param Signed-off-by: Tianle Huang <[email protected]> * address comments Signed-off-by: Tianle Huang <[email protected]> * fix name Signed-off-by: Tianle Huang <[email protected]> * temp change for 1.3.0 testing Signed-off-by: Tianle Huang <[email protected]> * update osd 2.0 for testing Signed-off-by: Tianle Huang <[email protected]> * temp stop upload Signed-off-by: Tianle Huang <[email protected]> * update name Signed-off-by: Tianle Huang <[email protected]> * restore temp changes Signed-off-by: Tianle Huang <[email protected]> * add unit tests Signed-off-by: Tianle Huang <[email protected]> * add more unit tests Signed-off-by: Tianle Huang <[email protected]> * more Signed-off-by: Tianle Huang <[email protected]> * fix Signed-off-by: Tianle Huang <[email protected]> * address comment Signed-off-by: Tianle Huang <[email protected]> * Add test txt Signed-off-by: Peter Zhu <[email protected]> Co-authored-by: Peter Zhu <[email protected]>
- Loading branch information
1 parent
826325d
commit 8876571
Showing
13 changed files
with
2,762 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package jenkins.tests | ||
|
||
import org.junit.* | ||
|
||
class TestAssembleManifest extends BuildPipelineTest { | ||
|
||
@Test | ||
void testAssembleManifest_rpm() { | ||
this.registerLibTester(new AssembleManifestLibTester('tests/data/opensearch-build-1.3.0-rpm.yml')) | ||
|
||
this.registerLibTester(new BuildYumRepoTester( | ||
'tests/data/opensearch-build-1.3.0-rpm.yml', | ||
'https://ci.opensearch.org/dbc/vars-build/1.3.0/123/linux/x64' | ||
)) | ||
|
||
super.setUp() | ||
|
||
super.testPipeline('tests/jenkins/jobs/AssembleManifest_rpm_Jenkinsfile') | ||
} | ||
|
||
@Test | ||
void testAssembleManifest_tar() { | ||
this.registerLibTester(new AssembleManifestLibTester('tests/data/opensearch-build-1.3.0.yml')) | ||
super.setUp() | ||
|
||
super.testPipeline('tests/jenkins/jobs/AssembleManifest_tar_Jenkinsfile') | ||
} | ||
} |
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,29 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package jenkins.tests | ||
|
||
import org.junit.* | ||
|
||
class TestBuildYumRepo extends BuildPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
this.registerLibTester(new BuildYumRepoTester( | ||
'tests/data/opensearch-build-1.3.0.yml', | ||
'https://ci.opensearch.org/ci/dbc/test/1.3.0/9/linux/x64' | ||
)) | ||
|
||
super.setUp() | ||
} | ||
|
||
@Test | ||
void testBuildYumRepo() { | ||
super.testPipeline('tests/jenkins/jobs/BuildYumRepo_Jenkinsfile') | ||
} | ||
|
||
} |
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,16 @@ | ||
lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm)) | ||
|
||
pipeline { | ||
agent none | ||
stages { | ||
stage('assembleManifest rpm') { | ||
steps { | ||
script { | ||
assembleManifest( | ||
buildManifest: 'tests/data/opensearch-build-1.3.0-rpm.yml' | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
AssembleManifest_rpm_Jenkinsfile.run() | ||
AssembleManifest_rpm_Jenkinsfile.legacySCM(groovy.lang.Closure) | ||
AssembleManifest_rpm_Jenkinsfile.library({identifier=jenkins@20211123, retriever=null}) | ||
AssembleManifest_rpm_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
AssembleManifest_rpm_Jenkinsfile.echo(Executing on agent [label:none]) | ||
AssembleManifest_rpm_Jenkinsfile.stage(assembleManifest rpm, groovy.lang.Closure) | ||
AssembleManifest_rpm_Jenkinsfile.script(groovy.lang.Closure) | ||
AssembleManifest_rpm_Jenkinsfile.assembleManifest({buildManifest=tests/data/opensearch-build-1.3.0-rpm.yml}) | ||
assembleManifest.legacySCM(groovy.lang.Closure) | ||
assembleManifest.library({identifier=jenkins@20211123, retriever=null}) | ||
assembleManifest.readYaml({file=tests/data/opensearch-build-1.3.0-rpm.yml}) | ||
BuildManifest.asBoolean() | ||
BuildManifest.getArtifactRootUrlWithoutDistribution(https://ci.opensearch.org/dbc, vars-build, 123) | ||
assembleManifest.sh(./assemble.sh "tests/data/opensearch-build-1.3.0-rpm.yml" --base-url https://ci.opensearch.org/dbc/vars-build/1.3.0/123/linux/x64) | ||
assembleManifest.buildYumRepo({baseUrl=https://ci.opensearch.org/dbc/vars-build/1.3.0/123/linux/x64, buildManifest=tests/data/opensearch-build-1.3.0-rpm.yml}) | ||
buildYumRepo.legacySCM(groovy.lang.Closure) | ||
buildYumRepo.library({identifier=jenkins@20211123, retriever=null}) | ||
buildYumRepo.readYaml({file=tests/data/opensearch-build-1.3.0-rpm.yml}) | ||
BuildManifest.asBoolean() | ||
buildYumRepo.echo(Create yum repo metadata and repo file tests/data/opensearch-build-1.3.0-rpm.yml) | ||
buildYumRepo.sh(createrepo "rpm/dist/opensearch") | ||
buildYumRepo.writeFile({file=rpm/dist/opensearch/opensearch-1.3.0.staging.repo, text=[opensearch-1.3.0-123-staging] | ||
name=OpenSearch 1.3.0 123 Staging | ||
baseurl=https://ci.opensearch.org/dbc/vars-build/1.3.0/123/linux/x64/rpm/dist/opensearch/ | ||
enabled=1 | ||
gpgcheck=0 | ||
autorefresh=1 | ||
type=rpm-md}) |
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,16 @@ | ||
lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm)) | ||
|
||
pipeline { | ||
agent none | ||
stages { | ||
stage('assembleManifest tar') { | ||
steps { | ||
script { | ||
assembleManifest( | ||
buildManifest: 'tests/data/opensearch-build-1.3.0.yml' | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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,14 @@ | ||
AssembleManifest_tar_Jenkinsfile.run() | ||
AssembleManifest_tar_Jenkinsfile.legacySCM(groovy.lang.Closure) | ||
AssembleManifest_tar_Jenkinsfile.library({identifier=jenkins@20211123, retriever=null}) | ||
AssembleManifest_tar_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
AssembleManifest_tar_Jenkinsfile.echo(Executing on agent [label:none]) | ||
AssembleManifest_tar_Jenkinsfile.stage(assembleManifest tar, groovy.lang.Closure) | ||
AssembleManifest_tar_Jenkinsfile.script(groovy.lang.Closure) | ||
AssembleManifest_tar_Jenkinsfile.assembleManifest({buildManifest=tests/data/opensearch-build-1.3.0.yml}) | ||
assembleManifest.legacySCM(groovy.lang.Closure) | ||
assembleManifest.library({identifier=jenkins@20211123, retriever=null}) | ||
assembleManifest.readYaml({file=tests/data/opensearch-build-1.3.0.yml}) | ||
BuildManifest.asBoolean() | ||
BuildManifest.getArtifactRootUrlWithoutDistribution(https://ci.opensearch.org/dbc, vars-build, 123) | ||
assembleManifest.sh(./assemble.sh "tests/data/opensearch-build-1.3.0.yml" --base-url https://ci.opensearch.org/dbc/vars-build/1.3.0/123/linux/x64) |
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,17 @@ | ||
lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm)) | ||
|
||
pipeline { | ||
agent none | ||
stages { | ||
stage('buildYumRepo') { | ||
steps { | ||
script { | ||
buildYumRepo( | ||
buildManifest: 'tests/data/opensearch-build-1.3.0.yml', | ||
baseUrl: 'https://ci.opensearch.org/ci/dbc/test/1.3.0/9/linux/x64' | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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,21 @@ | ||
BuildYumRepo_Jenkinsfile.run() | ||
BuildYumRepo_Jenkinsfile.legacySCM(groovy.lang.Closure) | ||
BuildYumRepo_Jenkinsfile.library({identifier=jenkins@20211123, retriever=null}) | ||
BuildYumRepo_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
BuildYumRepo_Jenkinsfile.echo(Executing on agent [label:none]) | ||
BuildYumRepo_Jenkinsfile.stage(buildYumRepo, groovy.lang.Closure) | ||
BuildYumRepo_Jenkinsfile.script(groovy.lang.Closure) | ||
BuildYumRepo_Jenkinsfile.buildYumRepo({buildManifest=tests/data/opensearch-build-1.3.0.yml, baseUrl=https://ci.opensearch.org/ci/dbc/test/1.3.0/9/linux/x64}) | ||
buildYumRepo.legacySCM(groovy.lang.Closure) | ||
buildYumRepo.library({identifier=jenkins@20211123, retriever=null}) | ||
buildYumRepo.readYaml({file=tests/data/opensearch-build-1.3.0.yml}) | ||
BuildManifest.asBoolean() | ||
buildYumRepo.echo(Create yum repo metadata and repo file tests/data/opensearch-build-1.3.0.yml) | ||
buildYumRepo.sh(createrepo "rpm/dist/opensearch") | ||
buildYumRepo.writeFile({file=rpm/dist/opensearch/opensearch-1.3.0.staging.repo, text=[opensearch-1.3.0-123-staging] | ||
name=OpenSearch 1.3.0 123 Staging | ||
baseurl=https://ci.opensearch.org/ci/dbc/test/1.3.0/9/linux/x64/rpm/dist/opensearch/ | ||
enabled=1 | ||
gpgcheck=0 | ||
autorefresh=1 | ||
type=rpm-md}) |
31 changes: 31 additions & 0 deletions
31
tests/jenkins/lib-testers/AssembleManifestLibTester.groovy
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 @@ | ||
import static org.hamcrest.CoreMatchers.notNullValue | ||
import static org.hamcrest.MatcherAssert.assertThat | ||
|
||
class AssembleManifestLibTester extends LibFunctionTester { | ||
|
||
private String buildManifest | ||
|
||
public AssembleManifestLibTester(buildManifest) { | ||
this.buildManifest = buildManifest | ||
} | ||
|
||
void configure(helper, binding) { | ||
|
||
binding.setVariable('PUBLIC_ARTIFACT_URL', 'https://ci.opensearch.org/dbc') | ||
binding.setVariable('JOB_NAME', 'vars-build') | ||
binding.setVariable('BUILD_NUMBER', '123') | ||
} | ||
|
||
void parameterInvariantsAssertions(call) { | ||
assertThat(call.args.buildManifest.first(), notNullValue()) | ||
} | ||
|
||
boolean expectedParametersMatcher(call) { | ||
return call.args.buildManifest.first().toString().equals(this.buildManifest) | ||
} | ||
|
||
String libFunctionName() { | ||
return 'assembleManifest' | ||
} | ||
|
||
} |
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,34 @@ | ||
import static org.hamcrest.CoreMatchers.notNullValue | ||
import static org.hamcrest.MatcherAssert.assertThat | ||
|
||
class BuildYumRepoTester extends LibFunctionTester { | ||
|
||
private String buildManifest | ||
private String baseUrl | ||
|
||
public BuildYumRepoTester(buildManifest, baseUrl) { | ||
this.buildManifest = buildManifest | ||
this.baseUrl = baseUrl | ||
} | ||
|
||
void configure(helper, binding) { | ||
binding.setVariable('BUILD_NUMBER', '123') | ||
|
||
helper.registerAllowedMethod("writeFile", [Map]) | ||
} | ||
|
||
void parameterInvariantsAssertions(call) { | ||
assertThat(call.args.buildManifest.first(), notNullValue()) | ||
assertThat(call.args.baseUrl.first(), notNullValue()) | ||
} | ||
|
||
boolean expectedParametersMatcher(call) { | ||
return call.args.buildManifest.first().toString().equals(this.buildManifest) && | ||
call.args.baseUrl.first().toString().equals(this.baseUrl) | ||
} | ||
|
||
String libFunctionName() { | ||
return 'buildYumRepo' | ||
} | ||
|
||
} |
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,28 @@ | ||
void call(Map args = [:]) { | ||
lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm)) | ||
|
||
def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifest)) | ||
echo "Create yum repo metadata and repo file ${args.buildManifest}" | ||
|
||
def filename = buildManifest.build.getFilename() | ||
def name = buildManifest.build.name | ||
def version = buildManifest.build.version | ||
def repoFilePath = "rpm/dist/${filename}" | ||
|
||
sh([ | ||
'createrepo', | ||
"\"${repoFilePath}\"", | ||
].join(' ')) | ||
|
||
def repoFileContent = [ | ||
"[${filename}-${version}-${BUILD_NUMBER}-staging]", | ||
"name=${name} ${version} ${BUILD_NUMBER} Staging", | ||
"baseurl=${args.baseUrl}/${repoFilePath}/", | ||
"enabled=1", | ||
"gpgcheck=0", | ||
"autorefresh=1", | ||
"type=rpm-md" | ||
].join('\n') | ||
|
||
writeFile file: "${repoFilePath}/${filename}-${version}.staging.repo", text: repoFileContent | ||
} |