Skip to content

Commit

Permalink
arch type fix
Browse files Browse the repository at this point in the history
Signed-off-by: vamsi-amazon <[email protected]>
  • Loading branch information
vmmusings committed Nov 14, 2022
1 parent 03f30e3 commit aa2ad60
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
23 changes: 23 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ buildscript {
// 2.0.0-rc1-SNAPSHOT -> 2.0.0.0-rc1-SNAPSHOT (opensearch_build)
opensearch_build += "-SNAPSHOT"
}
getPrometheusBinaryLocation = { ->
def os = org.gradle.internal.os.OperatingSystem.current()
println "*** Building on ${os.familyName} / ${os.name} / ${os.version} / ${System.getProperty("os.arch")}."
// Currently only considering linux and macos. Need to evolve this logic once we start supporting other os types.
if (os.isMacOsX()) {
//x64, x86-64, amd64
if (System.getProperty("os.arch").startsWith("x") || System.getProperty("os.arch").startsWith("amd")) {
return "https://github.com/prometheus/prometheus/releases/download/v2.37.2/prometheus-2.37.2.darwin-amd64.tar.gz"
}
else {
return "https://github.com/prometheus/prometheus/releases/download/v2.37.2/prometheus-2.37.2.darwin-arm64.tar.gz"
}
}
else {
//x64, x86-64, amd64
if (System.getProperty("os.arch").startsWith("x") || System.getProperty("os.arch").startsWith("amd")) {
return "https://github.com/prometheus/prometheus/releases/download/v2.37.2/prometheus-2.37.2.linux-amd64.tar.gz"
}
else {
return "https://github.com/prometheus/prometheus/releases/download/v2.37.2/prometheus-2.37.2.linux-arm64.tar.gz"
}
}
}
}

repositories {
Expand Down
15 changes: 10 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,9 @@ task stopPrometheus() {
process.waitFor()
} finally {
pidFile.delete()
println "Deleting prometheus folder"
println file("$projectDir/bin/prometheus").deleteDir()
println file("$projectDir/bin/prometheus.tar.gz").delete()
}
}
}
Expand Down
26 changes: 20 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,37 @@ 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 {
println "Deleting prometheus folder"
println file("$projectDir/bin/prometheus").deleteDir()
println file("$projectDir/bin/prometheus.tar.gz").delete()
}
}

stopPrometheus.mustRunAfter startPrometheus

Expand Down

0 comments on commit aa2ad60

Please sign in to comment.