forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
175 lines (152 loc) · 7.67 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* 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
/**
* End-to-end test docker network
*/
def AGGREGATE_PIPELINE_YAML = 'aggregate-e2e-pipeline.yml'
def DATA_PREPPER_CONFIG_LOCAL_NODE = 'data_prepper_local_node.yml'
def DATA_PREPPER_CONFIG_STATIC = 'data_prepper_static.yml'
/**
* Represents the configurations needed for peer-forwarder end-to-end tests.
*/
class PeerForwarderTestConfiguration {
PeerForwarderTestConfiguration(
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<PeerForwarderTestConfiguration> peerForwarderTestConfigurations = [
new PeerForwarderTestConfiguration(
'localAggregateEndToEndTest',
'Runs the local log aggregation end-to-end test.',
'org.opensearch.dataprepper.integration.peerforwarder.EndToEndPeerForwarderTest.testAggregatePipelineWithSingleNodeEndToEnd*',
'data-prepper',
AGGREGATE_PIPELINE_YAML,
DATA_PREPPER_CONFIG_LOCAL_NODE
),
new PeerForwarderTestConfiguration(
'staticAggregateEndToEndTest',
'Runs the local log aggregation end-to-end test.',
'org.opensearch.dataprepper.integration.peerforwarder.EndToEndPeerForwarderTest.testAggregatePipelineWithMultipleNodesEndToEnd*',
'node.data-prepper.example.com',
AGGREGATE_PIPELINE_YAML,
DATA_PREPPER_CONFIG_STATIC
),
new PeerForwarderTestConfiguration(
'staticLogMetricsEndToEndTest',
'Runs the local log aggregation end-to-end test.',
'org.opensearch.dataprepper.integration.peerforwarder.EndToEndLogMetricsTest.testLogMetricsPipelineWithMultipleNodesEndToEnd*',
'node.data-prepper.example.com',
'log-metrics-pipeline.yml',
DATA_PREPPER_CONFIG_STATIC
)
]
/**
* Creates a container name from a base name. If the name looks like a DNS entry
* it adds the index after the first part. Otherwise, it appends the index to the end.
*
* @param name The base container name
* @param index The index of the container to create
* @return The container name to use.
*/
static def createContainerName(String name, int index) {
def nameParts = name.split('\\.', 2)
return "${nameParts[0]}${index}${nameParts.length==2 ? '.' + nameParts[1] : ''}"
}
peerForwarderTestConfigurations.each { testConfiguration ->
tasks.register("start${testConfiguration.testName}All")
tasks.register("remove${testConfiguration.testName}All")
(0..1).each { containerIndex ->
tasks.register("create${testConfiguration.testName}${containerIndex}", DockerCreateContainer) {
dependsOn dataPrepperDockerImage
dependsOn createDataPrepperNetwork
containerName = createContainerName(testConfiguration.containerName, containerIndex)
exposePorts('tcp', [2021])
hostConfig.portBindings = ["${2021+containerIndex}:2021"]
hostConfig.binds = [
(project.file("src/integrationTest/resources/${testConfiguration.pipelineConfiguration}").toString()) : '/usr/share/data-prepper/pipelines/test-pipeline.yaml',
(project.file("src/integrationTest/resources/${testConfiguration.dataPrepperConfiguration}").toString()): '/usr/share/data-prepper/config/data-prepper-config.yaml',
(project.file('src/integrationTest/resources/default_certificate.pem').toString()) : '/usr/share/data-prepper/config/default_certificate.pem',
(project.file('src/integrationTest/resources/default_private_key.pem').toString()): '/usr/share/data-prepper/config/default_private_key.pem'
]
hostConfig.network = createDataPrepperNetwork.getNetworkName()
targetImageId dataPrepperDockerImage.imageId
}
tasks.register("start${testConfiguration.testName}${containerIndex}", DockerStartContainer) {
dependsOn "create${testConfiguration.testName}${containerIndex}"
dependsOn 'startOpenSearchDockerContainer'
mustRunAfter 'startOpenSearchDockerContainer'
targetContainerId tasks.getByName("create${testConfiguration.testName}${containerIndex}").getContainerId()
}
tasks.named("start${testConfiguration.testName}All").configure {
dependsOn "start${testConfiguration.testName}${containerIndex}"
}
tasks.register("stop${testConfiguration.testName}${containerIndex}", DockerStopContainer) {
dependsOn "${testConfiguration.testName}"
targetContainerId tasks.getByName("create${testConfiguration.testName}${containerIndex}").getContainerId()
}
tasks.register("remove${testConfiguration.testName}${containerIndex}", DockerRemoveContainer) {
dependsOn "stop${testConfiguration.testName}${containerIndex}"
targetContainerId tasks.getByName("stop${testConfiguration.testName}${containerIndex}").getContainerId()
}
tasks.named("remove${testConfiguration.testName}All").configure {
dependsOn "remove${testConfiguration.testName}${containerIndex}"
}
}
tasks.register(testConfiguration.testName, Test) {
dependsOn build
dependsOn startOpenSearchDockerContainer
dependsOn "start${testConfiguration.testName}All"
// 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}All"
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 project(':data-prepper-plugins:otel-trace-group-processor')
integrationTestImplementation 'org.awaitility:awaitility:4.2.0'
integrationTestImplementation libs.opentelemetry.proto
integrationTestImplementation libs.protobuf.util
integrationTestImplementation libs.armeria.core
integrationTestImplementation libs.armeria.grpc
integrationTestImplementation libs.opensearch.rhlc
integrationTestImplementation 'com.fasterxml.jackson.core:jackson-databind'
}