Skip to content

Commit

Permalink
Merge pull request #6819: [BEAM-5837] Add health check prober for com…
Browse files Browse the repository at this point in the history
…munity metrics infrastructure
  • Loading branch information
swegner committed Oct 24, 2018
2 parents c127e15 + aacb734 commit 802887c
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .test-infra/jenkins/job_PostCommit_CommunityMetrics.groovy
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import CommonJobProperties as commonJobProperties

job('beam_Prober_CommunityMetrics') {
description('Health check probes for the Community Metrics infrastructure')
commonJobProperties.setTopLevelMainJobProperties(delegate)

commonJobProperties.enablePhraseTriggeringFromPullRequest(delegate,
'Community Metrics Prober',
'Run Community Metrics Prober')

commonJobProperties.setAutoJob(delegate)

commonJobProperties.enablePhraseTriggeringFromPullRequest(
delegate,
'Community Metrics Prober',
'Run Community Metrics Prober')

// Gradle goals for this job.
steps {
gradle {
rootBuildScriptDir(commonJobProperties.checkoutDir)
tasks(':communityMetricsProber')
commonJobProperties.setGradleSwitches(delegate)
}
}
}
2 changes: 1 addition & 1 deletion .test-infra/jenkins/job_PreCommit_CommunityMetrics.groovy
Expand Up @@ -21,7 +21,7 @@ import PrecommitJobBuilder
PrecommitJobBuilder builder = new PrecommitJobBuilder(
scope: this,
nameBase: 'Community Metrics',
gradleTask: ':communitymetricsPreCommit',
gradleTask: ':communityMetricsPreCommit',
triggerPathPatterns: ['^.test-infra/metrics/.*$']
)
builder.build()
Expand Down
13 changes: 13 additions & 0 deletions .test-infra/metrics/build.gradle
Expand Up @@ -17,10 +17,20 @@
*/

apply plugin: "base"
apply plugin: "groovy"

repositories {
mavenCentral()
}

// https://github.com/avast/gradle-docker-compose-plugin
apply plugin: "com.avast.gradle.docker-compose"

dependencies {
testCompile library.groovy.groovy_all
testCompile library.java.junit
}

task testMetricsStack {
doLast {
// TODO(BEAM-5837): Add some actual validation of the metrics stack
Expand All @@ -33,3 +43,6 @@ task preCommit {
dependsOn testMetricsStack
}

task checkProber {
dependsOn test
}
42 changes: 42 additions & 0 deletions .test-infra/metrics/src/test/groovy/ProberTests.groovy
@@ -0,0 +1,42 @@
#!groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import org.junit.Test
import groovy.json.JsonSlurper
import static groovy.test.GroovyAssert.shouldFail

/**
* Prober tests which performs health checks on deployed infrasture for
* community metrics.
*/
class ProberTests {
// TODO: Make this configurable
def grafanaEndpoint = 'http://104.154.241.245';

@Test
void PingGrafanaHttpApi() {
def allDashboardsJson = "${grafanaEndpoint}/api/search?type=dash-db".toURL().text
def allDashboards = new JsonSlurper().parseText(allDashboardsJson)
def dashboardNames = allDashboards.title
// Validate at least one expected dashboard exists
assert dashboardNames.contains('Post-commit Tests') : 'Expected dashboard does not exist'
assert dashboardNames.size >= 3 : "Number of dashboards is less than expected ${dashboardNames}"
}
}

5 changes: 4 additions & 1 deletion build.gradle
Expand Up @@ -245,10 +245,13 @@ task websitePreCommit() {
}

task communityMetricsPreCommit() {
dependsOn ":rat"
dependsOn ":beam-test-infra-metrics:preCommit"
}

task communityMetricsProber() {
dependsOn ":beam-test-infra-metrics:checkProber"
}

task javaExamplesDataflowPrecommit() {
dependsOn ":beam-runners-google-cloud-dataflow-java-examples:preCommit"
dependsOn ":beam-runners-google-cloud-dataflow-java-examples-streaming:preCommit"
Expand Down
Expand Up @@ -441,6 +441,9 @@ class BeamModulePlugin implements Plugin<Project> {
woodstox_core_asl : "org.codehaus.woodstox:woodstox-core-asl:4.4.1",
quickcheck_core : "com.pholser:junit-quickcheck-core:$quickcheck_version",
],
groovy: [
groovy_all: "org.codehaus.groovy:groovy-all:2.4.13",
],
// For generating pom.xml from archetypes.
maven: [
maven_compiler_plugin: "maven-plugins:maven-compiler-plugin:3.7.0",
Expand Down
2 changes: 1 addition & 1 deletion release/build.gradle
Expand Up @@ -23,7 +23,7 @@ repositories {
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.13'
compile library.groovy.groovy_all
compile 'commons-cli:commons-cli:1.2'
}

Expand Down

0 comments on commit 802887c

Please sign in to comment.