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

Introduce build benchmark tests (test pr 1) #1

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .ci/jobs.t/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
reference-repo: "/var/lib/jenkins/.git-references/elasticsearch.git"
branches:
- "${branch_specifier}"
url: "https://github.com/elastic/elasticsearch.git"
url: "https://github.com/breskeby/elasticsearch.git"
basedir: ""
wipe-workspace: true
triggers: []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- job:
name: "elastic+elasticsearch+pull-request+build-performance"
display-name: "elastic / elasticsearch - pull request build performance"
description: "Testing of Elasticsearch pull requests - build performance"
workspace: "/dev/shm/elastic+elasticsearch+pull-request+build-perf"
scm:
- git:
refspec: "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*"
branches:
- "introduce-build-benchmark-tests"
triggers:
- github-pull-request:
org-list:
- breskeby
allow-whitelist-orgs-as-admins: true
trigger-phrase: '.*run\W+elasticsearch-ci/build-perf.*'
github-hooks: true
status-context: elasticsearch-ci/build-performance
cancel-builds-on-update: false
black-list-target-branches:
- 6.8
excluded-regions:
- ^docs/.*
white-list-labels:
- 'build-performance'
black-list-labels:
- '>test-mute'
builders:
- inject:
properties-file: '.ci/java-versions.properties'
properties-content: |
JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
RUNTIME_JAVA_HOME=$HOME/.java/$ES_RUNTIME_JAVA
JAVA8_HOME=$HOME/.java/java8
JAVA11_HOME=$HOME/.java/java11
- shell: |
#!/usr/local/bin/runbld --redirect-stderr
$WORKSPACE/.ci/scripts/run-gradle.sh bootstrapPerformanceTests
#!/usr/local/bin/runbld --redirect-stderr
$WORKSPACE/.ci/scripts/install-gradle-profiler.sh bootstrapPerformanceTests
7 changes: 7 additions & 0 deletions .ci/scripts/install-gradle-profiler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
PROFILER_VERSION="0.16.0"
wget https://repo.gradle.org/gradle/ext-releases-local/org/gradle/profiler/gradle-profiler/$PROFILER_VERSION/gradle-profiler-$PROFILER_VERSION.zip -O $WORKSPACE/gradle-profiler-$PROFILER_VERSION.zip
unzip $WORKSPACE/gradle-profiler-$PROFILER_VERSION.zip
mv $WORKSPACE/gradle-profiler-$PROFILER_VERSION $WORKSPACE/gradle-profiler
set -e
$GRADLEW -S --max-workers=$MAX_WORKERS $@
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.gradle.internal.conventions.info;

import java.net.URL;
import java.util.List;
import java.util.Map;
import groovy.json.JsonSlurper;
import java.net.MalformedURLException;
import java.util.Objects;
import java.util.stream.Collectors;

public class GradleVersionInfo {

static Version getLatestRelease() throws MalformedURLException{
URL url = new URL("https://services.gradle.org/versions/current");
JsonSlurper slurper = new JsonSlurper();
Map parsedJson = (Map) slurper.parse(url);
return new Version((String) parsedJson.get("version"), "", "", false);
}

static Version getLatestRC() throws MalformedURLException {
URL url = new URL("https://services.gradle.org/versions/release-candidate");
JsonSlurper slurper = new JsonSlurper();
Map parsedJson = (Map)slurper.parse(url);
return new Version((String)parsedJson.get("version"),
(String)parsedJson.get("rcFor"),
(String)parsedJson.get("milestoneFor"),
false
);
}

static Version getLatestReleaseOrRC() throws MalformedURLException{
Version latestRelease = getLatestRelease();
Version latestRC = getLatestRC();
return latestRC.getRcFor().equals(latestRelease.getVersionString()) ? latestRelease : latestRC;
}

static class Version {
private final String versionString;
private final String rcFor;
private final String milestoneFor;
private final boolean snapshot;

Version(String versionString, String rcFor, String milestoneFor, boolean snapshot) {
this.versionString = versionString;
this.rcFor = rcFor;
this.milestoneFor = milestoneFor;
this.snapshot = snapshot;
}

public String getVersionString() {
return versionString;
}

public boolean isFinal() {
return snapshot == false && (rcFor == null || rcFor.isEmpty()) && (milestoneFor == null || milestoneFor.isEmpty());
// return rcFor != null && (rcFor.isEmpty() == false) || (milestoneFor != null && milestoneFor.isEmpty() == false);
}

public String getRcFor() {
return rcFor;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Version version = (Version) o;
return snapshot == version.snapshot && Objects.equals(versionString, version.versionString) && Objects.equals(rcFor, version.rcFor) && Objects.equals(milestoneFor, version.milestoneFor);
}

@Override
public int hashCode() {
return Objects.hash(versionString, rcFor, milestoneFor, snapshot);
}
}

static List<Version> getGradleVersions() throws MalformedURLException {
URL url = new URL("https://services.gradle.org/versions/all");
JsonSlurper slurper = new JsonSlurper();
List<Map> parsedJson = (List<Map>) slurper.parse(url);
return parsedJson.stream().map(m -> new Version((String)m.get("version"),
(String)m.get("rcFor"),
(String)m.get("milestoneFor"),
(boolean)m.get("snapshot")))
.collect(Collectors.toList());
}

static Version getPreviousRelease(Version version) throws MalformedURLException{
List<Version> collect = getGradleVersions().stream()
.filter(v -> v.isFinal())
.sorted((v1, v2) -> v2.versionString.compareTo(v1.versionString))
.collect(Collectors.toList());
return (version.isFinal()) ? collect.get(collect.indexOf(version) + 1) : collect.get(0);
}

}
17 changes: 17 additions & 0 deletions build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* Side Public License, v 1.
*/

import org.apache.tools.ant.filters.ReplaceTokens
import org.elasticsearch.gradle.internal.conventions.info.GitInfo
import org.gradle.util.GradleVersion
import org.elasticsearch.gradle.internal.conventions.info.GradleVersionInfo

plugins {
id 'java-gradle-plugin'
id 'groovy-gradle-plugin'
Expand Down Expand Up @@ -270,6 +275,7 @@ dependencies {
tasks.named('test').configure {
useJUnitPlatform()
}

tasks.register("integTest", Test) {
inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
systemProperty 'test.version_under_test', version
Expand All @@ -279,3 +285,14 @@ tasks.register("integTest", Test) {
}

tasks.named("check").configure { dependsOn("integTest") }

tasks.register("bootstrapPerformanceTests", Copy) {
from('performance')
into('build/performanceTests')
def root = file('..')
filter(ReplaceTokens, tokens: [gradleVersion: gradle.gradleVersion,
oldGradleVersion: GradleVersionInfo.getPreviousRelease(GradleVersionInfo.getLatestReleaseOrRC()),
testGitCommit:GitInfo.gitInfo(root).revision
]
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Can specify scenarios to use when none are specified on the command line
default-scenarios = ["buildConfigurationNew", "buildConfigurationOld"]

buildConfigurationNew {
title = "new"
tasks = ["help"]
# cleanup-tasks = ["clean"]
versions = ["@gradleVersion@"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "@testGitCommit@"
}
}

buildConfigurationOld {
title = "base"
tasks = ["help"]
versions = ["@gradleVersion@"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "master"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Can specify scenarios to use when none are specified on the command line
default-scenarios = ["buildConfigurationNew", "buildConfigurationOld"]

buildConfiguration {
title = "new"
tasks = ["help"]
# cleanup-tasks = ["clean"]
versions = ["@oldGradleVersion@", "@gradleVersion@"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "@testGitCommit@"
}
}
17 changes: 17 additions & 0 deletions build-tools-internal/performance/runBenchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0 and the Server Side Public License, v 1; you may not use this file except
# in compliance with, at your election, the Elastic License 2.0 or the Server
# Side Public License, v 1.
#

cd gradle-profiler
./gradlew installDist
cd ..

echo "Running scenario file: $1";

./gradle-profiler/build/install/gradle-profiler/bin/gradle-profiler --benchmark --scenario-file elasticsearch/build-tools-internal/build/performanceTests/$1.scenarios --project-dir elasticsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import org.elasticsearch.gradle.internal.precommit.JarHellPrecommitPlugin
import org.elasticsearch.gradle.internal.precommit.ThirdPartyAuditPrecommitPlugin

String elasticsearchLibraryCorePath = ":libs:elasticsearch-core"

configure(allprojects - project(elasticsearchLibraryCorePath)) {
project.getPlugins().withType(JarHellPrecommitPlugin) {
project.getDependencies().add("jarHell", project(elasticsearchLibraryCorePath));
}

project.getPlugins().withType(ThirdPartyAuditPrecommitPlugin) {
project.getDependencies().add("jdkJarHell", project.project(elasticsearchLibraryCorePath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ public class JarHellPrecommitPlugin extends PrecommitPlugin {
@Override
public TaskProvider<? extends Task> createTask(Project project) {
project.getPluginManager().apply(JarHellPlugin.class);

if (project.getPath().equals(":libs:elasticsearch-core") == false) {
// ideally we would configure this as a default dependency. But Default dependencies do not work correctly
// with gradle project dependencies as they're resolved to late in the build and don't setup according task
// dependencies properly
project.getDependencies().add("jarHell", project.project(":libs:elasticsearch-core"));
}

return project.getTasks().withType(JarHellTask.class).named("jarHell");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public TaskProvider<? extends Task> createTask(Project project) {
// we are not doing this for this project itself to avoid jar hell with itself
project.getDependencies().add(JDK_JAR_HELL_CONFIG_NAME, project.project(LIBS_ELASTICSEARCH_CORE_PROJECT_PATH));
}

TaskProvider<ExportElasticsearchBuildResourcesTask> resourcesTask = project.getTasks()
.register("thirdPartyAuditResources", ExportElasticsearchBuildResourcesTask.class);
Path resourcesDir = project.getBuildDir().toPath().resolve("third-party-audit-config");
Expand Down
14 changes: 14 additions & 0 deletions testfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
line 1
2
2
2
2
2
2
2
2
2
2
2
2
2