Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
  • Loading branch information
gaiksaya committed Aug 28, 2024
1 parent 3049ba2 commit f56aa2b
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 13 deletions.
34 changes: 21 additions & 13 deletions jenkins/release-workflows/release-tag.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,39 @@ pipeline {
description: 'Version of the release.',
trim: true
)
choice(
choices: ['opensearch', 'opensearch-dashboards'],
name: 'PRODUCT',
description: 'Product for tag creation.'
)
}
environment {
DISTRIBUTION_MANIFEST = "$PRODUCT-$VERSION/manifest.yml"
OS_DISTRIBUTION_MANIFEST = "opensearch-$VERSION/manifest.yml"
OSD_DISTRIBUTION_MANIFEST = "opensearch-dashboards-$VERSION/manifest.yml"
}
stages {
stage('Create Release Tag') {
stage('Create Release Tag for OpenSearch components') {
steps {
script {
release_url = "https://artifacts.opensearch.org/releases/bundle/$PRODUCT/$VERSION/$PRODUCT-$VERSION-linux-x64.tar.gz"
sh "curl -SLO $release_url && tar -xf $PRODUCT-$VERSION-linux-x64.tar.gz $PRODUCT-$VERSION/manifest.yml"
echo "The release distribution manifest is downloaded to $DISTRIBUTION_MANIFEST"
os_artifact_url = "https://artifacts.opensearch.org/releases/bundle/opensearch/$VERSION/opensearch-$VERSION-linux-x64.tar.gz"
sh "curl -SLO $os_artifact_url && tar -xf opensearch-$VERSION-linux-x64.tar.gz opensearch-$VERSION/manifest.yml"
echo "The release distribution manifest is downloaded to $OS_DISTRIBUTION_MANIFEST"
createReleaseTag(
distManifest: "$DISTRIBUTION_MANIFEST",
distManifest: "$OS_DISTRIBUTION_MANIFEST",
tagVersion: VERSION
)
}
}
}
stage('Create Release Tag for OpenSearch-Dasboards components') {
steps {
script {
osd_artifact_url = "https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/$VERSION/opensearch-dashboards-$VERSION-linux-x64.tar.gz"
sh "curl -SLO $osd_artifact_url && tar -xf opensearch-dashboards-$VERSION-linux-x64.tar.gz opensearch-dashboards-$VERSION/manifest.yml"
echo "The release distribution manifest is downloaded to $OSD_DISTRIBUTION_MANIFEST"
createReleaseTag(
distManifest: "$OSD_DISTRIBUTION_MANIFEST",
tagVersion: VERSION
)

}
}
}
stage('Update Manifest') {
stage('Lock Manifests to tags') {
steps {
echo 'Triggering manifest lock workflow'
build job: 'release-manifest-commit-lock', wait: true, parameters: [
Expand Down
98 changes: 98 additions & 0 deletions tests/jenkins/TestReleaseTagJob.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright OpenSearch Contributors
* 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.
*/
import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.GitSource.gitSource
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.assertj.core.api.Assertions.assertThat
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.CoreMatchers.hasItems
import org.yaml.snakeyaml.Yaml


class TestReleaseTag extends BuildPipelineTest {

@Override
@Before
void setUp() {
String releaseVersion = '2.16.0'

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('1.0.4')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
.retriever(gitSource('https://github.com/opensearch-project/opensearch-build-libraries.git'))
.build()
)
super.setUp()
addParam('VERSION', releaseVersion)
binding.setVariable('GITHUB_BOT_TOKEN_NAME', 'github_bot_token_name')
binding.setVariable('env', [
'VERSION': releaseVersion,
'OS_DISTRIBUTION_MANIFEST': 'opensearch-2.16.0/manifest.yml',
'OSD_DISTRIBUTION_MANIFEST': 'opensearch-dashboards-2.16.0/manifest.yml'
])
helper.registerAllowedMethod('readYaml', [Map.class], { args ->
if (args.file == 'opensearch-2.16.0/manifest.yml') {
return new Yaml().load(('tests/jenkins/data/opensearch-dist-2.16.0.yml' as File).text)
} else if (args.file == 'opensearch-dashboards-2.16.0/manifest.yml') {
return new Yaml().load(('tests/jenkins/data/opensearch-dashboards-dist-2.16.0.yml' as File).text)
}
})
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/security.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: '30760168263404e628a25fd13a54100d2610810c', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/job-scheduler.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: 'b36f79336db82fd45db5665a5ac2e9368f0a1cdf', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/k-NN.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: 'c8ec49f1e2c9603498ca679727a499dc0b296e26', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/common-utils.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: 'cbc06a5eafe0009edbb2c865d7cd30262d04e502', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/OpenSearch.git 2.16.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: 'f84a26e76807ea67a69822c37b1a1d89e7177d9b', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/dashboards-visualizations.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: '5e86965658791648fad9d0fc573e470c59cce674', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/OpenSearch-Dashboards.git 2.16.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: '4b8826e7ffa6562825ca8aad676a8d89983c2d70', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/opensearch-dashboards-functional-test.git 2.16.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: '7c5e0482b844828cf2aec3b63841bd5d336d5668', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/dashboards-reporting.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: '49057e4f82b0390dc28d0e08009ec5f892d7af1a', exitValue: 0]
}
helper.addShMock("git ls-remote --tags https://github.com/opensearch-project/dashboards-observability.git 2.16.0.0 | awk 'NR==1{print \$1}'") { script ->
return [stdout: '24d368e882ec01ff98e556725b84e332d4ab825e', exitValue: 0]
}
}
@Test
public void checkTagCreation() {
super.testPipeline("jenkins/release-workflows/release-tag.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/release-workflows/release-tag.jenkinsfile")
assertJobStatusSuccess()
}

@Test
public void testManifestLock(){
runScript('jenkins/release-workflows/release-tag.jenkinsfile')
assertCallStack().contains('release-tag.stage(Lock Manifests to tags, groovy.lang.Closure',
'release-tag.string({name=RELEASE_VERSION, value=2.16.0})',
'release-tag.string({name=MANIFEST_LOCK_ACTION, value=UPDATE_TO_TAGS})',
'release-tag.build({job=release-manifest-commit-lock, wait=true, parameters=[null, null]})')
}
}
35 changes: 35 additions & 0 deletions tests/jenkins/data/opensearch-dashboards-dist-2.16.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
schema-version: '1.1'
build:
name: OpenSearch Dashboards
version: 2.16.0
platform: linux
architecture: x64
distribution: tar
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.16.0/7858/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-2.16.0-linux-x64.tar.gz
id: '7858'
components:
- name: OpenSearch-Dashboards
repository: https://github.com/opensearch-project/OpenSearch-Dashboards.git
ref: 4b8826e7ffa6562825ca8aad676a8d89983c2d70
commit_id: 4b8826e7ffa6562825ca8aad676a8d89983c2d70
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.16.0/7858/linux/x64/tar/builds/opensearch-dashboards/dist/opensearch-dashboards-min-2.16.0-linux-x64.tar.gz
- name: functionalTestDashboards
repository: https://github.com/opensearch-project/opensearch-dashboards-functional-test.git
ref: '2.16'
commit_id: 7c5e0482b844828cf2aec3b63841bd5d336d5668
- name: observabilityDashboards
repository: https://github.com/opensearch-project/dashboards-observability.git
ref: 24d368e882ec01ff98e556725b84e332d4ab825e
commit_id: 24d368e882ec01ff98e556725b84e332d4ab825e
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.16.0/7858/linux/x64/tar/builds/opensearch-dashboards/plugins/observabilityDashboards-2.16.0.zip
- name: reportsDashboards
repository: https://github.com/opensearch-project/dashboards-reporting.git
ref: 49057e4f82b0390dc28d0e08009ec5f892d7af1a
commit_id: 49057e4f82b0390dc28d0e08009ec5f892d7af1a
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.16.0/7858/linux/x64/tar/builds/opensearch-dashboards/plugins/reportsDashboards-2.16.0.zip
- name: ganttChartDashboards
repository: https://github.com/opensearch-project/dashboards-visualizations.git
ref: 5e86965658791648fad9d0fc573e470c59cce674
commit_id: 5e86965658791648fad9d0fc573e470c59cce674
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.16.0/7858/linux/x64/tar/builds/opensearch-dashboards/plugins/ganttChartDashboards-2.16.0.zip

Check failure on line 35 in tests/jenkins/data/opensearch-dashboards-dist-2.16.0.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

35:183 [new-line-at-end-of-file] no new line character at the end of file
35 changes: 35 additions & 0 deletions tests/jenkins/data/opensearch-dist-2.16.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
schema-version: '1.1'
build:
name: OpenSearch
version: 2.16.0
platform: linux
architecture: x64
distribution: tar
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.16.0/10154/linux/x64/tar/dist/opensearch/opensearch-2.16.0-linux-x64.tar.gz
id: '10154'
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
ref: f84a26e76807ea67a69822c37b1a1d89e7177d9b
commit_id: f84a26e76807ea67a69822c37b1a1d89e7177d9b
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.16.0/10154/linux/x64/tar/builds/opensearch/dist/opensearch-min-2.16.0-linux-x64.tar.gz
- name: common-utils
repository: https://github.com/opensearch-project/common-utils.git
ref: cbc06a5eafe0009edbb2c865d7cd30262d04e502
commit_id: cbc06a5eafe0009edbb2c865d7cd30262d04e502
- name: job-scheduler
repository: https://github.com/opensearch-project/job-scheduler.git
ref: b36f79336db82fd45db5665a5ac2e9368f0a1cdf
commit_id: b36f79336db82fd45db5665a5ac2e9368f0a1cdf
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.16.0/10154/linux/x64/tar/builds/opensearch/plugins/opensearch-job-scheduler-2.16.0.0.zip
- name: security
repository: https://github.com/opensearch-project/security.git
ref: 30760168263404e628a25fd13a54100d2610810c
commit_id: 30760168263404e628a25fd13a54100d2610810c
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.16.0/10154/linux/x64/tar/builds/opensearch/plugins/opensearch-security-2.16.0.0.zip
- name: k-NN
repository: https://github.com/opensearch-project/k-NN.git
ref: c8ec49f1e2c9603498ca679727a499dc0b296e26
commit_id: c8ec49f1e2c9603498ca679727a499dc0b296e26
location: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.16.0/10154/linux/x64/tar/builds/opensearch/plugins/opensearch-knn-2.16.0.0.zip
Loading

0 comments on commit f56aa2b

Please sign in to comment.