diff --git a/.test-infra/jenkins/job_PostCommit_CommunityMetrics.groovy b/.test-infra/jenkins/job_PostCommit_CommunityMetrics.groovy new file mode 100644 index 0000000000000..3334c501b90cd --- /dev/null +++ b/.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) + } + } +} diff --git a/.test-infra/jenkins/job_PreCommit_CommunityMetrics.groovy b/.test-infra/jenkins/job_PreCommit_CommunityMetrics.groovy index 005204ed607cf..598bad152f97f 100644 --- a/.test-infra/jenkins/job_PreCommit_CommunityMetrics.groovy +++ b/.test-infra/jenkins/job_PreCommit_CommunityMetrics.groovy @@ -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() diff --git a/.test-infra/metrics/build.gradle b/.test-infra/metrics/build.gradle index 983a44c192fe4..b91f3023571df 100644 --- a/.test-infra/metrics/build.gradle +++ b/.test-infra/metrics/build.gradle @@ -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 @@ -33,3 +43,6 @@ task preCommit { dependsOn testMetricsStack } +task checkProber { + dependsOn test +} diff --git a/.test-infra/metrics/src/test/groovy/ProberTests.groovy b/.test-infra/metrics/src/test/groovy/ProberTests.groovy new file mode 100644 index 0000000000000..f365327c49a49 --- /dev/null +++ b/.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}" + } +} + diff --git a/build.gradle b/build.gradle index da88f4d0f471b..f36328ad448d5 100644 --- a/build.gradle +++ b/build.gradle @@ -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" diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index d88f2aa7a34c6..30d5926d9b836 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -441,6 +441,9 @@ class BeamModulePlugin implements Plugin { 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", diff --git a/release/build.gradle b/release/build.gradle index 20bca0540fb58..f658d276568ad 100644 --- a/release/build.gradle +++ b/release/build.gradle @@ -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' }