From bcb2af4331c1b59da30b8e9a31c1bcf5ca2ba06d Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Thu, 22 Jun 2023 16:59:09 -0700 Subject: [PATCH] [2.x manual backport] Stop prometheus in doctest build.gradle now runs upon project failure in startOpenSearch (#1763) * fixed buildgradle merge conflicts Signed-off-by: Mitchell Gale * Fix CI (#1760) * Fix ML-commons missing dependency. Signed-off-by: Yury-Fridlyand * Fix `mockito` dependency. Signed-off-by: Yury-Fridlyand * Revert changes in `:opensearch` since it is not needed anymore. Signed-off-by: Yury-Fridlyand --------- Signed-off-by: Yury-Fridlyand --------- Signed-off-by: Mitchell Gale Signed-off-by: Yury-Fridlyand Co-authored-by: Yury-Fridlyand --- doctest/build.gradle | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/doctest/build.gradle b/doctest/build.gradle index 6e87cca9fc..b7ed46c075 100644 --- a/doctest/build.gradle +++ b/doctest/build.gradle @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import java.util.concurrent.Callable import org.opensearch.gradle.testclusters.RunTask plugins { @@ -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" } @@ -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', '')