Skip to content

Commit 6aa24fa

Browse files
Merge branch 'master' into snapshot-lifecycle-management
2 parents 74b4e75 + dfa40e6 commit 6aa24fa

File tree

493 files changed

+7564
-3410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

493 files changed

+7564
-3410
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ class BuildPlugin implements Plugin<Project> {
825825

826826
test.executable = "${ext.get('runtimeJavaHome')}/bin/java"
827827
test.workingDir = project.file("${project.buildDir}/testrun/${test.name}")
828-
test.maxParallelForks = project.rootProject.extensions.getByType(ExtraPropertiesExtension).get('defaultParallel') as Integer
828+
test.maxParallelForks = System.getProperty('tests.jvms', project.rootProject.extensions.extraProperties.get('defaultParallel').toString()) as Integer
829829

830830
test.exclude '**/*$*.class'
831831

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
353353

354354
private void testSetup(Snippet snippet) {
355355
if (lastDocsPath == snippet.path) {
356-
throw new InvalidUserDataException("$snippet: wasn't first")
356+
throw new InvalidUserDataException("$snippet: wasn't first. TESTSETUP can only be used in the first snippet of a document.")
357357
}
358358
setupCurrent(snippet)
359359
current.println('---')

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import java.io.File;
4747
import java.io.IOException;
4848
import java.io.InputStream;
49+
import java.io.LineNumberReader;
50+
4951
import java.io.UncheckedIOException;
5052
import java.net.URI;
5153
import java.nio.charset.StandardCharsets;
@@ -61,6 +63,7 @@
6163
import java.util.HashMap;
6264
import java.util.HashSet;
6365
import java.util.LinkedHashMap;
66+
import java.util.LinkedList;
6467
import java.util.List;
6568
import java.util.Map;
6669
import java.util.Objects;
@@ -82,13 +85,22 @@ public class ElasticsearchNode implements TestClusterConfiguration {
8285
private static final Logger LOGGER = Logging.getLogger(ElasticsearchNode.class);
8386
private static final int ES_DESTROY_TIMEOUT = 20;
8487
private static final TimeUnit ES_DESTROY_TIMEOUT_UNIT = TimeUnit.SECONDS;
88+
8589
private static final int NODE_UP_TIMEOUT = 2;
8690
private static final TimeUnit NODE_UP_TIMEOUT_UNIT = TimeUnit.MINUTES;
8791
private static final int ADDITIONAL_CONFIG_TIMEOUT = 15;
8892
private static final TimeUnit ADDITIONAL_CONFIG_TIMEOUT_UNIT = TimeUnit.SECONDS;
8993
private static final List<String> OVERRIDABLE_SETTINGS = Arrays.asList(
9094
"path.repo",
9195
"discovery.seed_providers"
96+
97+
);
98+
99+
private static final int TAIL_LOG_MESSAGES_COUNT = 40;
100+
private static final List<String> MESSAGES_WE_DONT_CARE_ABOUT = Arrays.asList(
101+
"Option UseConcMarkSweepGC was deprecated",
102+
"is a pre-release version of Elasticsearch",
103+
"max virtual memory areas vm.max_map_count"
92104
);
93105

94106
private final String path;
@@ -693,14 +705,73 @@ private void logProcessInfo(String prefix, ProcessHandle.Info info) {
693705
}
694706

695707
private void logFileContents(String description, Path from) {
696-
LOGGER.error("{} `{}`", description, this);
697-
try (Stream<String> lines = Files.lines(from, StandardCharsets.UTF_8)) {
698-
lines
699-
.map(line -> " " + line)
700-
.forEach(LOGGER::error);
708+
final Map<String, Integer> errorsAndWarnings = new LinkedHashMap<>();
709+
LinkedList<String> ring = new LinkedList<>();
710+
try (LineNumberReader reader = new LineNumberReader(Files.newBufferedReader(from))) {
711+
for (String line = reader.readLine(); line != null ; line = reader.readLine()) {
712+
final String lineToAdd;
713+
if (ring.isEmpty()) {
714+
lineToAdd = line;
715+
} else {
716+
if (line.startsWith("[")) {
717+
lineToAdd = line;
718+
// check to see if the previous message (possibly combined from multiple lines) was an error or
719+
// warning as we want to show all of them
720+
String previousMessage = normalizeLogLine(ring.getLast());
721+
if (MESSAGES_WE_DONT_CARE_ABOUT.stream().noneMatch(previousMessage::contains) &&
722+
(previousMessage.contains("ERROR") || previousMessage.contains("WARN"))) {
723+
errorsAndWarnings.put(
724+
previousMessage,
725+
errorsAndWarnings.getOrDefault(previousMessage, 0) + 1
726+
);
727+
}
728+
} else {
729+
// We combine multi line log messages to make sure we never break exceptions apart
730+
lineToAdd = ring.removeLast() + "\n" + line;
731+
}
732+
}
733+
ring.add(lineToAdd);
734+
if (ring.size() >= TAIL_LOG_MESSAGES_COUNT) {
735+
ring.removeFirst();
736+
}
737+
}
701738
} catch (IOException e) {
702739
throw new UncheckedIOException("Failed to tail log " + this, e);
703740
}
741+
742+
if (errorsAndWarnings.isEmpty() == false || ring.isEmpty() == false) {
743+
LOGGER.error("\n=== {} `{}` ===", description, this);
744+
}
745+
if (errorsAndWarnings.isEmpty() == false) {
746+
LOGGER.lifecycle("\n» ↓ errors and warnings from " + from + " ↓");
747+
errorsAndWarnings.forEach((message, count) -> {
748+
LOGGER.lifecycle("» " + message.replace("\n", "\n» "));
749+
if (count > 1) {
750+
LOGGER.lifecycle("» ↑ repeated " + count + " times ↑");
751+
}
752+
});
753+
}
754+
755+
ring.removeIf(line -> MESSAGES_WE_DONT_CARE_ABOUT.stream().anyMatch(line::contains));
756+
757+
if (ring.isEmpty() == false) {
758+
LOGGER.lifecycle("» ↓ last " + TAIL_LOG_MESSAGES_COUNT + " non error or warning messages from " + from + " ↓");
759+
ring.forEach(message -> {
760+
if (errorsAndWarnings.containsKey(normalizeLogLine(message)) == false) {
761+
LOGGER.lifecycle("» " + message.replace("\n", "\n» "));
762+
}
763+
});
764+
}
765+
}
766+
767+
private String normalizeLogLine(String line) {
768+
if (line.contains("ERROR")) {
769+
return line.substring(line.indexOf("ERROR"));
770+
}
771+
if (line.contains("WARN")) {
772+
return line.substring(line.indexOf("WARN"));
773+
}
774+
return line;
704775
}
705776

706777
private void waitForProcessToExit(ProcessHandle processHandle) {

buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void apply(Project project) {
122122

123123
extension.fixtures
124124
.matching(fixtureProject -> fixtureProject.equals(project) == false)
125-
.all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath()));
125+
.all(fixtureProject -> project.evaluationDependsOn(fixtureProject.getPath()));
126126

127127
conditionTaskByType(tasks, extension, Test.class);
128128
conditionTaskByType(tasks, extension, getTaskClass("org.elasticsearch.gradle.test.RestIntegTestTask"));

buildSrc/src/test/java/org/elasticsearch/gradle/EmptyDirTaskTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.io.File;
2222
import java.io.IOException;
2323

24+
import com.carrotsearch.randomizedtesting.RandomizedTest;
25+
import org.apache.tools.ant.taskdefs.condition.Os;
2426
import org.elasticsearch.gradle.test.GradleUnitTestCase;
2527
import org.gradle.api.Project;
2628
import org.gradle.testfixtures.ProjectBuilder;
@@ -49,6 +51,8 @@ public void testCreateEmptyDir() throws Exception {
4951
}
5052

5153
public void testCreateEmptyDirNoPermissions() throws Exception {
54+
RandomizedTest.assumeFalse("Functionality is Unix specific", Os.isFamily(Os.FAMILY_WINDOWS));
55+
5256
Project project = ProjectBuilder.builder().build();
5357
EmptyDirTask emptyDirTask = project.getTasks().create("emptyDirTask", EmptyDirTask.class);
5458
emptyDirTask.setDirMode(0000);

buildSrc/src/test/java/org/elasticsearch/gradle/testclusters/TestClustersPluginIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public void testUseClusterByTwo() {
6868
public void testUseClusterByUpToDateTask() {
6969
// Run it once, ignoring the result and again to make sure it's considered up to date.
7070
// Gradle randomly considers tasks without inputs and outputs as as up-to-date or success on the first run
71-
getTestClustersRunner(":upToDate1", ":upToDate2").build();
72-
BuildResult result = getTestClustersRunner(":upToDate1", ":upToDate2").build();
73-
assertTaskUpToDate(result, ":upToDate1", ":upToDate2");
71+
getTestClustersRunner(":upToDate1").build();
72+
BuildResult result = getTestClustersRunner(":upToDate1").build();
73+
assertTaskUpToDate(result, ":upToDate1");
7474
assertNotStarted(result);
7575
}
7676

buildSrc/src/testKit/testclusters/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ task printLog {
105105

106106
task upToDate1 {
107107
useCluster testClusters.myTestCluster
108-
}
109-
110-
task upToDate2 {
111-
useCluster testClusters.myTestCluster
108+
outputs.upToDateWhen { true }
109+
doLast {
110+
println "Some task action"
111+
}
112112
}
113113

114114
task skipped1 {

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@
3232
import org.elasticsearch.tasks.Task;
3333
import org.elasticsearch.transport.TransportService;
3434

35-
import java.util.function.Supplier;
36-
3735
public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
3836
private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocWriteRequest.OpType.UPDATE,
3937
new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 1L, DocWriteResponse.Result.CREATED));
4038

4139
@Inject
4240
public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters) {
43-
super(NoopBulkAction.NAME, transportService, actionFilters, (Supplier<BulkRequest>) BulkRequest::new);
41+
super(NoopBulkAction.NAME, transportService, BulkRequest::new, actionFilters);
4442
}
4543

4644
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.dataframe.transforms;
21+
22+
import org.elasticsearch.common.ParseField;
23+
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
24+
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
25+
import org.elasticsearch.common.xcontent.XContentParser;
26+
27+
import java.io.IOException;
28+
import java.util.Collections;
29+
import java.util.Map;
30+
import java.util.Objects;
31+
32+
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
33+
34+
/**
35+
* Holds state of the cursors:
36+
*
37+
* indexer_position: the position of the indexer querying the source
38+
* bucket_position: the position used for identifying changes
39+
*/
40+
public class DataFrameIndexerPosition {
41+
public static final ParseField INDEXER_POSITION = new ParseField("indexer_position");
42+
public static final ParseField BUCKET_POSITION = new ParseField("bucket_position");
43+
44+
private final Map<String, Object> indexerPosition;
45+
private final Map<String, Object> bucketPosition;
46+
47+
@SuppressWarnings("unchecked")
48+
public static final ConstructingObjectParser<DataFrameIndexerPosition, Void> PARSER = new ConstructingObjectParser<>(
49+
"data_frame_indexer_position",
50+
true,
51+
args -> new DataFrameIndexerPosition((Map<String, Object>) args[0],(Map<String, Object>) args[1]));
52+
53+
static {
54+
PARSER.declareField(optionalConstructorArg(), XContentParser::mapOrdered, INDEXER_POSITION, ValueType.OBJECT);
55+
PARSER.declareField(optionalConstructorArg(), XContentParser::mapOrdered, BUCKET_POSITION, ValueType.OBJECT);
56+
}
57+
58+
public DataFrameIndexerPosition(Map<String, Object> indexerPosition, Map<String, Object> bucketPosition) {
59+
this.indexerPosition = indexerPosition == null ? null : Collections.unmodifiableMap(indexerPosition);
60+
this.bucketPosition = bucketPosition == null ? null : Collections.unmodifiableMap(bucketPosition);
61+
}
62+
63+
public Map<String, Object> getIndexerPosition() {
64+
return indexerPosition;
65+
}
66+
67+
public Map<String, Object> getBucketsPosition() {
68+
return bucketPosition;
69+
}
70+
71+
@Override
72+
public boolean equals(Object other) {
73+
if (this == other) {
74+
return true;
75+
}
76+
77+
if (other == null || getClass() != other.getClass()) {
78+
return false;
79+
}
80+
81+
DataFrameIndexerPosition that = (DataFrameIndexerPosition) other;
82+
83+
return Objects.equals(this.indexerPosition, that.indexerPosition) &&
84+
Objects.equals(this.bucketPosition, that.bucketPosition);
85+
}
86+
87+
@Override
88+
public int hashCode() {
89+
return Objects.hash(indexerPosition, bucketPosition);
90+
}
91+
92+
public static DataFrameIndexerPosition fromXContent(XContentParser parser) {
93+
try {
94+
return PARSER.parse(parser, null);
95+
} catch (IOException e) {
96+
throw new RuntimeException(e);
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)