Skip to content

Commit

Permalink
Integ tests fix for arm64.[Failure in starting up prometheus server] (#…
Browse files Browse the repository at this point in the history
…1069)

Signed-off-by: vamsi-amazon <reddyvam@amazon.com>
  • Loading branch information
vmmusings authored Nov 14, 2022
1 parent 03f30e3 commit 662a938
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,40 @@ buildscript {
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
prometheus_binary_version = "2.37.2"
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
if (isSnapshot) {
// 2.0.0-rc1-SNAPSHOT -> 2.0.0.0-rc1-SNAPSHOT (opensearch_build)
opensearch_build += "-SNAPSHOT"
}
getArchType = {
if (System.getProperty("os.arch").startsWith("x") || System.getProperty("os.arch").startsWith("amd")) {
return "amd64"
}
else {
return "arm64"
}
}
getOSFamilyType = {
def os = org.gradle.internal.os.OperatingSystem.current();
if (os.isMacOsX()) {
return "darwin"
}
else if(os.isLinux()){
return "linux"
}
else if(os.isWindows()) {
return "windows"
}
else {
return os.getFamilyName().toString()
}
}
getPrometheusBinaryLocation = { ->
return "https://github.com/prometheus/prometheus/releases/download/v${prometheus_binary_version}/prometheus-${prometheus_binary_version}."+ getOSFamilyType() + "-" + getArchType() + ".tar.gz"
}
}

repositories {
Expand Down
14 changes: 9 additions & 5 deletions doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@ task bootstrap(type: Exec) {
task startPrometheus(type: SpawnProcessTask) {
doFirst {
download.run {
src 'https://github.com/prometheus/prometheus/releases/download/v2.39.1/prometheus-2.39.1.linux-amd64.tar.gz'
src getPrometheusBinaryLocation()
dest new File("$projectDir/bin", 'prometheus.tar.gz')
}
copy {
from tarTree("$projectDir/bin/prometheus.tar.gz")
into "$projectDir/bin"
}
copy {
from "$projectDir/bin/prometheus.yml"
into "$projectDir/bin/prometheus-2.39.1.linux-amd64/prometheus"
file("$projectDir/bin").eachDir {
if (it.name.startsWith("prometheus-")) {
println "Renaming folder : " + it.name.toString()
println it.renameTo("$projectDir/bin/prometheus")
}
}
}
command "$projectDir/bin/prometheus-2.39.1.linux-amd64/prometheus --storage.tsdb.path=$projectDir/bin/prometheus-2.39.1.linux-amd64/data --config.file=$projectDir/bin/prometheus-2.39.1.linux-amd64/prometheus.yml"
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'
}
Expand Down Expand Up @@ -80,6 +82,8 @@ task stopPrometheus() {
process.waitFor()
} finally {
pidFile.delete()
file("$projectDir/bin/prometheus").deleteDir()
file("$projectDir/bin/prometheus.tar.gz").delete()
}
}
}
Expand Down
25 changes: 19 additions & 6 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.opensearch.gradle.test.RestIntegTestTask
import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask

import java.util.concurrent.Callable
import org.gradle.internal.os.OperatingSystem

plugins {
id "de.undercouch.download" version "5.3.0"
Expand All @@ -38,6 +39,9 @@ apply plugin: 'java'
apply plugin: 'io.freefair.lombok'
apply plugin: 'com.wiredforcode.spawn'




repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
Expand Down Expand Up @@ -113,27 +117,36 @@ testClusters.integTest {
plugin ":opensearch-sql-plugin"
keystore 'plugins.query.federation.datasources.config', new File("$projectDir/src/test/resources/catalog/", 'catalog.json')
}

task startPrometheus(type: SpawnProcessTask) {
mustRunAfter ':doctest:doctest'

doFirst {
download.run {
src 'https://github.com/prometheus/prometheus/releases/download/v2.39.1/prometheus-2.39.1.linux-amd64.tar.gz'
src getPrometheusBinaryLocation()
dest new File("$projectDir/bin", 'prometheus.tar.gz')
}
copy {
from tarTree("$projectDir/bin/prometheus.tar.gz")
into "$projectDir/bin"
}
copy {
from "$projectDir/bin/prometheus.yml"
into "$projectDir/bin/prometheus-2.39.1.linux-amd64/prometheus"
file("$projectDir/bin").eachDir {
if (it.name.startsWith("prometheus-")) {
println "Renaming folder : " + it.name.toString()
println it.renameTo("$projectDir/bin/prometheus")
}
}
}
command "$projectDir/bin/prometheus-2.39.1.linux-amd64/prometheus --storage.tsdb.path=$projectDir/bin/prometheus-2.39.1.linux-amd64/data --config.file=$projectDir/bin/prometheus-2.39.1.linux-amd64/prometheus.yml"
command "$projectDir/bin/prometheus/prometheus --storage.tsdb.path=$projectDir/bin/prometheus/data --config.file=$projectDir/bin/prometheus/prometheus.yml"
ready 'TSDB started'
}

task stopPrometheus(type: KillProcessTask)
task stopPrometheus(type: KillProcessTask) {
doLast {
file("$projectDir/bin/prometheus").deleteDir()
file("$projectDir/bin/prometheus.tar.gz").delete()
}
}

stopPrometheus.mustRunAfter startPrometheus

Expand Down

0 comments on commit 662a938

Please sign in to comment.