Skip to content

Commit

Permalink
[2.x manual backport] Stop prometheus in doctest build.gradle now run…
Browse files Browse the repository at this point in the history
…s upon project failure in startOpenSearch (#1763)

* fixed buildgradle merge conflicts

Signed-off-by: Mitchell Gale <[email protected]>

* Fix CI (#1760)

* Fix ML-commons missing dependency.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Fix `mockito` dependency.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Revert changes in `:opensearch` since it is not needed anymore.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Mitchell Gale <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
MitchellGale and Yury-Fridlyand authored Jun 22, 2023
1 parent 34d2b7a commit bcb2af4
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import java.util.concurrent.Callable
import org.opensearch.gradle.testclusters.RunTask

plugins {
Expand Down Expand Up @@ -50,7 +49,7 @@ task startPrometheus(type: SpawnProcessTask) {
}
command "$projectDir/bin/prometheus/prometheus --storage.tsdb.path=$projectDir/bin/prometheus/data --config.file=$projectDir/bin/prometheus/prometheus.yml"
ready 'TSDB started'
pidLockFileName '.prom.pid.lock'
pidLockFileName ".prom.pid.lock"
}


Expand Down Expand Up @@ -78,36 +77,26 @@ task doctest(type: Exec, dependsOn: ['bootstrap']) {

task stopOpenSearch(type: KillProcessTask)

task stopPrometheus() {

task stopPrometheus(type: KillProcessTask) {
pidLockFileName ".prom.pid.lock"
doLast {
def pidFile = new File(path, ".prom.pid.lock")
if(!pidFile.exists()) {
logger.quiet "No Prometheus server running!"
return
}

def pid = pidFile.text
def process = "kill $pid".execute()

try {
process.waitFor()
} finally {
pidFile.delete()
file("$projectDir/bin/prometheus").deleteDir()
file("$projectDir/bin/prometheus.tar.gz").delete()
}
file("$projectDir/bin/prometheus").deleteDir()
file("$projectDir/bin/prometheus.tar.gz").delete()
}
}

// Stop Prom AFTER Start Prom...
if(getOSFamilyType() != "windows") {
stopPrometheus.mustRunAfter startPrometheus
startOpenSearch.dependsOn startPrometheus
stopOpenSearch.finalizedBy stopPrometheus
startOpenSearch.finalizedBy stopPrometheus
}
doctest.dependsOn startOpenSearch
doctest.finalizedBy stopOpenSearch
check.dependsOn doctest
clean.dependsOn(cleanBootstrap)
clean.dependsOn(stopPrometheus)

// 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT
String opensearch_no_snapshot = opensearch_version.replace('-SNAPSHOT', '')
Expand Down

0 comments on commit bcb2af4

Please sign in to comment.