forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestPromoteContainer.groovy
137 lines (117 loc) · 5.82 KB
/
TestPromoteContainer.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* 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
class TestPromoteContainer extends BuildPipelineTest {
String PROMOTE_PRODUCT = 'opensearch:2.0.1.2901, opensearch-dashboards:2.0.1-2345, data-prepper:2.0.1.123'
String RELEASE_VERSION = '2.0.1'
@Override
@Before
void setUp() {
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()
)
binding.setVariable('SOURCE_IMAGES', PROMOTE_PRODUCT)
binding.setVariable('RELEASE_VERSION', RELEASE_VERSION)
binding.setVariable('DOCKER_USERNAME', 'dummy_docker_username')
binding.setVariable('DOCKER_PASSWORD', 'dummy_docker_password')
binding.setVariable('ARTIFACT_PROMOTION_ROLE_NAME', 'dummy-agent-AssumeRole')
binding.setVariable('AWS_ACCOUNT_ARTIFACT', '1234567890')
binding.setVariable('DATA_PREPPER_STAGING_CONTAINER_REPOSITORY', 'dummy_dataprepper_ecr_url')
helper.registerAllowedMethod('withAWS', [Map, Closure], null)
super.setUp()
}
@Test
public void testPromoteContainerToDocker() {
String dockerPromote = true
String ecrPromote = false
String latestBoolean = false
String majorVersionBoolean = false
binding.setVariable('DOCKER_HUB_PROMOTE', dockerPromote)
binding.setVariable('ECR_PROMOTE', ecrPromote)
binding.setVariable('TAG_LATEST', latestBoolean)
binding.setVariable('TAG_MAJOR_VERSION', majorVersionBoolean)
super.testPipeline("jenkins/promotion/promote-docker-ecr.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/promotion/promote-container/promote-container-testPromoteContainerToDocker.jenkinsfile")
}
@Test
public void testPromoteContainerToDockerLatest() {
String dockerPromote = true
String ecrPromote = false
String latestBoolean = true
String majorVersionBoolean = false
binding.setVariable('DOCKER_HUB_PROMOTE', dockerPromote)
binding.setVariable('ECR_PROMOTE', ecrPromote)
binding.setVariable('TAG_LATEST', latestBoolean)
binding.setVariable('TAG_MAJOR_VERSION', majorVersionBoolean)
super.testPipeline("jenkins/promotion/promote-docker-ecr.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/promotion/promote-container/promote-container-testPromoteContainerToDockerLatest.jenkinsfile")
}
@Test
public void testPromoteContainerToDockerMajor() {
String dockerPromote = true
String ecrPromote = false
String latestBoolean = false
String majorVersionBoolean = true
binding.setVariable('DOCKER_HUB_PROMOTE', dockerPromote)
binding.setVariable('ECR_PROMOTE', ecrPromote)
binding.setVariable('TAG_LATEST', latestBoolean)
binding.setVariable('TAG_MAJOR_VERSION', majorVersionBoolean)
super.testPipeline("jenkins/promotion/promote-docker-ecr.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/promotion/promote-container/promote-container-testPromoteContainerToDockerMajor.jenkinsfile")
}
@Test
public void testPromoteContainerToDockerLatestMajor() {
String dockerPromote = true
String ecrPromote = false
String latestBoolean = true
String majorVersionBoolean = true
binding.setVariable('DOCKER_HUB_PROMOTE', dockerPromote)
binding.setVariable('ECR_PROMOTE', ecrPromote)
binding.setVariable('TAG_LATEST', latestBoolean)
binding.setVariable('TAG_MAJOR_VERSION', majorVersionBoolean)
super.testPipeline("jenkins/promotion/promote-docker-ecr.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/promotion/promote-container/promote-container-testPromoteContainerToDockerLatestMajor.jenkinsfile")
}
@Test
public void testPromoteContainerToECRLatestMajor() {
String dockerPromote = false
String ecrPromote = true
String latestBoolean = true
String majorVersionBoolean = true
binding.setVariable('DOCKER_HUB_PROMOTE', dockerPromote)
binding.setVariable('ECR_PROMOTE', ecrPromote)
binding.setVariable('TAG_LATEST', latestBoolean)
binding.setVariable('TAG_MAJOR_VERSION', majorVersionBoolean)
super.testPipeline("jenkins/promotion/promote-docker-ecr.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/promotion/promote-container/promote-container-testPromoteContainerToECRLatestMajor.jenkinsfile")
}
@Test
public void testPromoteContainerToDockerECRLatestMajor() {
String dockerPromote = true
String ecrPromote = true
String latestBoolean = true
String majorVersionBoolean = true
binding.setVariable('DOCKER_HUB_PROMOTE', dockerPromote)
binding.setVariable('ECR_PROMOTE', ecrPromote)
binding.setVariable('TAG_LATEST', latestBoolean)
binding.setVariable('TAG_MAJOR_VERSION', majorVersionBoolean)
super.testPipeline("jenkins/promotion/promote-docker-ecr.jenkinsfile",
"tests/jenkins/jenkinsjob-regression-files/promotion/promote-container/promote-container-testPromoteContainerToDockerECRLatestMajor.jenkinsfile")
}
}