Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integ tests fix for arm64.[Failure in starting up prometheus server] #1069

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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