Skip to content

Commit

Permalink
Show -Dlicense.key value in test repro info
Browse files Browse the repository at this point in the history
- When a -Dlicense.key sys property is passed to the build we want to consider
this in the test reproduction info message
- absolute Paths tried to be converted to relative paths relative to workspace
root to allow simply copy & paste
- Also fixes a inconsistency for checking license existence in x-pack plugin core build
  • Loading branch information
breskeby committed Dec 10, 2020
1 parent 5fe7b7f commit f727431
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.bootstrap.JavaVersion;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
Expand All @@ -33,6 +34,7 @@
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;

import java.nio.file.Path;
import java.util.Locale;
import java.util.TimeZone;

Expand Down Expand Up @@ -102,7 +104,6 @@ public void testFailure(Failure failure) throws Exception {
}
}
b.append("\"");

GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b);
gradleMessageBuilder.appendAllOpts(failure.getDescription());

Expand Down Expand Up @@ -181,10 +182,32 @@ private ReproduceErrorMessageBuilder appendESProperties() {
appendOpt("tests.timezone", TimeZone.getDefault().getID());
appendOpt("tests.distribution", System.getProperty("tests.distribution"));
appendOpt("runtime.java", Integer.toString(JavaVersion.current().getVersion().get(0)));
appendOpt("runtime.java", Integer.toString(JavaVersion.current().getVersion().get(0)));
appendOpt("license.key", relativePath(System.getProperty("licence.key")));
appendOpt(ESTestCase.FIPS_SYSPROP, System.getProperty(ESTestCase.FIPS_SYSPROP));
return this;
}

private String relativePath(String pathProperty) {
if(pathProperty == null) {
return null;
}
Path path = PathUtils.get(pathProperty);
if(path.isAbsolute()) {
// try to resolve workspace root from Jenksin WORKSPACE env variable
String workspace = System.getenv("WORKSPACE");
if(workspace == null) {
// fallback to resolve workspace root from teamcity checkout dir
workspace = System.getProperty("teamcity.build.workingDir");
}
if(workspace != null) {
// resolve path relative to workspace root
return PathUtils.get(workspace).relativize(path).toString();
}
}
return pathProperty;
}

public ReproduceErrorMessageBuilder appendClientYamlSuiteProperties() {
return appendProperties(REST_TESTS_SUITE, REST_TESTS_BLACKLIST);
}
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugin/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ tasks.named("processResources").configure {
} else {
throw new IllegalArgumentException('Property license.key must be set for release build')
}
if (Files.exists(Paths.get(licenseKey)) == false) {
File licenseKeyFile = rootProject.file(licenseKey)
if (licenseKeyFile.exists() == false) {
throw new IllegalArgumentException('license.key at specified path [' + licenseKey + '] does not exist')
}
from(licenseKey) {
from(licenseKeyFile) {
rename { String filename -> 'public.key' }
}
}
Expand Down

0 comments on commit f727431

Please sign in to comment.