forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
137 lines (121 loc) · 5.56 KB
/
build.gradle
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
*/
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import com.bmuschko.gradle.docker.tasks.container.DockerRemoveContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
/**
* Represents the configurations needed for any end-to-end log test.
*/
class LogTestConfiguration {
LogTestConfiguration(
String testName,
String description,
String testFilters,
String containerName,
String pipelineConfiguration,
String dataPrepperConfiguration) {
this.testName = testName
this.description = description
this.testFilters = testFilters
this.containerName = containerName
this.pipelineConfiguration = pipelineConfiguration
this.dataPrepperConfiguration = dataPrepperConfiguration
}
String testName
String description
String testFilters
String containerName
String pipelineConfiguration
String dataPrepperConfiguration
}
List<LogTestConfiguration> logTestConfigurations = [
new LogTestConfiguration(
'basicLogEndToEndTest',
'Runs the basic grok end-to-end test.',
'org.opensearch.dataprepper.integration.log.EndToEndBasicLogTest.testPipelineEndToEnd*',
'data-prepper-basic-log',
'basic-grok-e2e-pipeline.yml',
'data_prepper.yml'
),
new LogTestConfiguration(
'basicLogWithAwsSecretsEndToEndTest',
'Runs the basic grok with AWS secrets end-to-end test.',
'org.opensearch.dataprepper.integration.log.EndToEndBasicLogTest.testPipelineEndToEnd*',
'data-prepper-basic-log-with-aws-secrets',
'basic-grok-e2e-pipeline-with-aws-secrets.yml',
'data_prepper.yml'
),
new LogTestConfiguration(
'parallelGrokStringSubstituteTest',
'Runs the parallel grok and string substitute end-to-end test.',
'org.opensearch.dataprepper.integration.log.ParallelGrokStringSubstituteLogTest.testPipelineEndToEnd*',
'data-prepper-parallel-log',
'parallel-grok-substitute-e2e-pipeline.yml',
'data_prepper.yml'
)
]
logTestConfigurations.each { testConfiguration ->
tasks.register("create${testConfiguration.testName}", DockerCreateContainer) {
dependsOn dataPrepperDockerImage
dependsOn createDataPrepperNetwork
containerName = testConfiguration.containerName
exposePorts('tcp', [2021, 4900])
hostConfig.portBindings = ['2021:2021', '4900:4900']
hostConfig.binds = [
"${System.getProperty('user.home')}/.aws" : '/root/.aws',
(project.file("src/integrationTest/resources/${testConfiguration.pipelineConfiguration}").toString()) : '/usr/share/data-prepper/pipelines/log-pipeline.yaml',
(project.file("src/integrationTest/resources/${testConfiguration.dataPrepperConfiguration}").toString()): '/usr/share/data-prepper/config/data-prepper-config.yaml'
]
envVars = [
'AWS_PROFILE' : System.getenv('AWS_PROFILE') ?: ''
]
hostConfig.network = createDataPrepperNetwork.getNetworkName()
targetImageId dataPrepperDockerImage.imageId
}
tasks.register("start${testConfiguration.testName}", DockerStartContainer) {
dependsOn "create${testConfiguration.testName}"
dependsOn 'startOpenSearchDockerContainer'
mustRunAfter 'startOpenSearchDockerContainer'
targetContainerId tasks.getByName("create${testConfiguration.testName}").getContainerId()
}
tasks.register("stop${testConfiguration.testName}", DockerStopContainer) {
dependsOn "${testConfiguration.testName}"
targetContainerId tasks.getByName("create${testConfiguration.testName}").getContainerId()
}
tasks.register("remove${testConfiguration.testName}", DockerRemoveContainer) {
dependsOn "stop${testConfiguration.testName}"
targetContainerId tasks.getByName("stop${testConfiguration.testName}").getContainerId()
}
tasks.register(testConfiguration.testName, Test) {
dependsOn build
dependsOn startOpenSearchDockerContainer
dependsOn "start${testConfiguration.testName}"
// Wait for Data Prepper image to be ready
doFirst {
sleep(15 * 1000)
}
description = testConfiguration.description
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
filter {
includeTestsMatching testConfiguration.testFilters
}
finalizedBy stopOpenSearchDockerContainer
finalizedBy "remove${testConfiguration.testName}"
finalizedBy removeDataPrepperNetwork
}
}
dependencies {
integrationTestImplementation project(':data-prepper-api')
integrationTestImplementation project(':data-prepper-plugins:common')
integrationTestImplementation project(':data-prepper-plugins:log-generator-source')
integrationTestImplementation project(':data-prepper-plugins:opensearch')
integrationTestImplementation project(':data-prepper-plugins:aws-plugin-api')
integrationTestImplementation libs.armeria.core
integrationTestImplementation testLibs.awaitility
integrationTestImplementation libs.opensearch.rhlc
}