forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
137 lines (113 loc) · 4.96 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.DockerStartContainer
import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerPullImage
import com.bmuschko.gradle.docker.tasks.network.DockerCreateNetwork
import com.bmuschko.gradle.docker.tasks.network.DockerRemoveNetwork
import org.opensearch.dataprepper.gradle.end_to_end.DockerProviderTask
plugins {
id 'com.bmuschko.docker-remote-api' version '9.4.0'
}
subprojects {
apply plugin: 'com.bmuschko.docker-remote-api'
ext {
dataPrepperJarImageFilepath = 'bin/data-prepper/'
targetJavaVersion = project.hasProperty('endToEndJavaVersion') ? project.getProperty('endToEndJavaVersion') : 'docker'
targetOpenTelemetryVersion = project.hasProperty('openTelemetryVersion') ? project.getProperty('openTelemetryVersion') : "${libs.versions.opentelemetry.get()}"
dataPrepperBaseImage = "eclipse-temurin:${targetJavaVersion}-jre"
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
}
tasks.named('processIntegrationTestResources') {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntime
}
tasks.register('copyDataPrepperArchive', Copy) {
dependsOn ':release:archives:linux:linuxx64DistTar'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from project(':release:archives:linux').tasks.getByName('linuxx64DistTar').archiveFile.get().asFile
into("${project.buildDir}/docker/")
}
tasks.register('createDataPrepperDockerFile', Dockerfile) {
dependsOn copyDataPrepperArchive
dependsOn ':release:archives:linux:linuxx64DistTar'
destFile = project.file('build/docker/Dockerfile')
from(dataPrepperBaseImage)
runCommand('mkdir -p /var/log/data-prepper')
addFile(project(':release:archives:linux').tasks.getByName('linuxx64DistTar').archiveFileName.get(), '/usr/share')
runCommand("mv /usr/share/${project(':release:archives:linux').tasks.getByName('linuxx64DistTar').archiveFileName.get().replace('.tar.gz', '')} /usr/share/data-prepper")
workingDir('/usr/share/data-prepper')
defaultCommand('bin/data-prepper')
}
tasks.register('buildDataPrepperDockerImage', DockerBuildImage) {
dependsOn createDataPrepperDockerFile
dockerFile = file('build/docker/Dockerfile')
images.add('e2e-test-data-prepper')
}
tasks.register('dataPrepperDockerImage', DockerProviderTask) {
if(targetJavaVersion == 'docker') {
dependsOn ':release:docker:docker'
imageId = "${project.rootProject.name}:${project.version}"
}
else {
dependsOn 'createDataPrepperDockerFile'
imageId = buildDataPrepperDockerImage.getImageId()
}
}
tasks.register('createDataPrepperNetwork', DockerCreateNetwork) {
networkName = 'data_prepper_network'
}
tasks.register('removeDataPrepperNetwork', DockerRemoveNetwork) {
dependsOn createDataPrepperNetwork
networkId = createDataPrepperNetwork.getNetworkId()
}
/**
* OpenSearch Docker tasks
*/
tasks.register('pullOpenSearchDockerImage', DockerPullImage) {
image = "opensearchproject/opensearch:${libs.versions.opensearch.get()}"
}
tasks.register('createOpenSearchDockerContainer', DockerCreateContainer) {
dependsOn createDataPrepperNetwork
dependsOn pullOpenSearchDockerImage
targetImageId pullOpenSearchDockerImage.image
containerName = 'node-0.example.com'
hostConfig.portBindings = ['9200:9200', '9600:9600']
hostConfig.autoRemove = true
hostConfig.network = createDataPrepperNetwork.getNetworkName()
envVars = ['discovery.type': 'single-node']
}
tasks.register('startOpenSearchDockerContainer', DockerStartContainer) {
dependsOn createOpenSearchDockerContainer
targetContainerId createOpenSearchDockerContainer.getContainerId()
doLast {
sleep(90 * 1000)
}
}
tasks.register('stopOpenSearchDockerContainer', DockerStopContainer) {
targetContainerId createOpenSearchDockerContainer.getContainerId()
doLast {
sleep(5 * 1000)
}
}
dependencies {
testImplementation testLibs.junit.vintage
}
}