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

Adding shard count to node stats api #75395

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6ffe99c
Adding shard count to node stats api
masseyke Jul 14, 2021
ffa52b9
Adding tests, test fixes, and documentation
masseyke Jul 15, 2021
462c3d6
Update ILM message for out of order phases error (#75099)
Esduard Jul 13, 2021
0a7372c
[DOCS] Anomaly detection: Visualize delayed data (#75098)
lcawl Jul 14, 2021
fed7cbe
Refactor SimpleFeatureFactory so it has no external dependencies (#75…
iverase Jul 14, 2021
1f26077
Use contains relation for geo_point intersection over geo_point field…
iverase Jul 14, 2021
f5745ab
[Rest Api Compatibility] Enable tests after types and cat api fixed (…
pgomulka Jul 14, 2021
6a4754f
[TEST] Add logging when LDAP server starts/stops (#75322)
tvernum Jul 14, 2021
d184843
Mute FeatureFactoryTests testPoint methods (#75326)
iverase Jul 14, 2021
924d84b
Add logging of shard failures (#75275)
przemekwitek Jul 14, 2021
1db1340
[Transform] improve performance by using point in time API for search…
Jul 14, 2021
f7cedcb
Track Lucene field usage (#74227)
ywelsch Jul 14, 2021
a9544ae
Adapt BWC after backport (#74227)
ywelsch Jul 14, 2021
f9db73e
Geometry formatters should be applied to the full array (#75177)
iverase Jul 14, 2021
0c2f728
Reenable test after backport of #75099 to 7.x (#75344)
danhermann Jul 14, 2021
10ed0cb
Loosen checks in REST test for PIT slicing (#75261)
jtibshirani Jul 14, 2021
44eccac
Implement system index access level that includes everything except n…
gwbrown Jul 14, 2021
60c3bd4
Make GeoIpDownloaderIT.testInvalidTimestamp more robust (#75330)
probakowski Jul 14, 2021
e7feb47
Mute SimpleFeatureFactoryTests test points (#75359)
iverase Jul 15, 2021
2275cd8
Move some constants from SearchableSnapshotsConstants to server (#75308)
tlrx Jul 15, 2021
a9f50d1
[Rest Api Compatibility] Allow transforming warnings per test (#75187)
pgomulka Jul 15, 2021
e2c9cc4
Update "ssl-config" to support X-Pack features (#74887)
tvernum Jul 15, 2021
e585eb5
Introduce searchable snapshots index setting for cascade deletion of …
tlrx Jul 15, 2021
c67fce7
[ML] Rename JobNodeLoadDetectorTests to match tested class (#75370)
dimitris-athanasiou Jul 15, 2021
c7f6ce8
Resolve date math expressions before looking up index metadata (#75314)
danhermann Jul 15, 2021
2d97c7a
Add a tool for creating enrollment tokens (#74890)
jkakavas Jul 15, 2021
84b6b40
[DOCS] Clarify usage of the enroll Kibana API (#75348)
Jul 15, 2021
19ed187
Remove SET aliases from disk usage and field usage YML tests (#75381)
stevejgordon Jul 15, 2021
5db102d
Add null check for shard stats to data tier telemetry (#75185)
dakrone Jul 15, 2021
0337dec
[DOCS] Fix broken doc url values in JSON API spec (#75385)
jrodewig Jul 15, 2021
6d18e14
[DOCS] Update doc URLs for trained model deployment APIs (#75388)
lcawl Jul 15, 2021
1c9765a
Increase client timeout on CCS tests (#75346)
bpintea Jul 15, 2021
952ea84
Increment Iron Bank base image to 8.4
pugnascotia Jul 15, 2021
41b3e18
Incorporating code review feedback
masseyke Jul 16, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ public void removeWarning(String... warnings) {
transformations.add(new RemoveWarnings(Set.copyOf(Arrays.asList(warnings))));
}

/**
* Removes one or more warnings
* @param warnings the warning(s) to remove
* @param testName the test name to remove the warning
*/
public void removeWarningForTest(String warnings, String testName) {
transformations.add(new RemoveWarnings(Set.copyOf(Arrays.asList(warnings)), testName));
}

/**
* Adds one or more allowed warnings
* @param allowedWarnings the warning(s) to add
Expand All @@ -298,6 +307,15 @@ public void addAllowedWarningRegex(String... allowedWarningsRegex) {
transformations.add(new InjectAllowedWarnings(true, Arrays.asList(allowedWarningsRegex)));
}

/**
* Adds one or more allowed regular expression warnings
* @param allowedWarningsRegex the regex warning(s) to add
* @testName the test name to add a allowedWarningRegex
*/
public void addAllowedWarningRegexForTest(String allowedWarningsRegex, String testName) {
transformations.add(new InjectAllowedWarnings(true, Arrays.asList(allowedWarningsRegex), testName));
}

@OutputDirectory
public DirectoryProperty getOutputDirectory() {
return outputDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

import org.elasticsearch.gradle.internal.test.rest.transform.RestTestContext;
import org.elasticsearch.gradle.internal.test.rest.transform.RestTestTransformByParentObject;
import org.elasticsearch.gradle.internal.test.rest.transform.feature.FeatureInjector;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;

import java.util.List;

Expand All @@ -26,6 +29,7 @@ public class InjectAllowedWarnings extends FeatureInjector implements RestTestTr
private static JsonNodeFactory jsonNodeFactory = JsonNodeFactory.withExactBigDecimals(false);

private final List<String> allowedWarnings;
private String testName;
private final boolean isRegex;

/**
Expand All @@ -40,8 +44,18 @@ public InjectAllowedWarnings(List<String> allowedWarnings) {
* @param allowedWarnings The allowed warnings to inject
*/
public InjectAllowedWarnings(boolean isRegex, List<String> allowedWarnings) {
this(isRegex, allowedWarnings, null);
}

/**
* @param isRegex true if should inject the regex variant of allowed warnings
* @param allowedWarnings The allowed warnings to inject
* @param testName The testName to inject
*/
public InjectAllowedWarnings(boolean isRegex, List<String> allowedWarnings, String testName) {
this.isRegex = isRegex;
this.allowedWarnings = allowedWarnings;
this.testName = testName;
}

@Override
Expand All @@ -52,7 +66,7 @@ public void transformTest(ObjectNode doNodeParent) {
arrayWarnings = new ArrayNode(jsonNodeFactory);
doNodeValue.set(getSkipFeatureName(), arrayWarnings);
}
allowedWarnings.forEach(arrayWarnings::add);
this.allowedWarnings.forEach(arrayWarnings::add);
}

@Override
Expand All @@ -71,4 +85,15 @@ public String getSkipFeatureName() {
public List<String> getAllowedWarnings() {
return allowedWarnings;
}

@Override
public boolean shouldApply(RestTestContext testContext) {
return testName == null || testContext.getTestName().equals(testName);
}

@Input
@Optional
public String getTestName() {
return testName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import org.elasticsearch.gradle.internal.test.rest.transform.RestTestContext;
import org.elasticsearch.gradle.internal.test.rest.transform.RestTestTransformByParentObject;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,13 +31,22 @@
public class RemoveWarnings implements RestTestTransformByParentObject {

private final Set<String> warnings;
private String testName;

/**
* @param warnings The allowed warnings to inject
*/
public RemoveWarnings(Set<String> warnings) {
this.warnings = warnings;
}
/**
* @param warnings The allowed warnings to inject
* @param testName The testName to inject
*/
public RemoveWarnings(Set<String> warnings, String testName) {
this.warnings = warnings;
this.testName = testName;
}

@Override
public void transformTest(ObjectNode doNodeParent) {
Expand Down Expand Up @@ -66,4 +78,15 @@ public String getKeyToFind() {
public Set<String> getWarnings() {
return warnings;
}

@Override
public boolean shouldApply(RestTestContext testContext) {
return testName == null || testContext.getTestName().equals(testName);
}

@Input
@Optional
public String getTestName() {
return testName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLParser;

import org.elasticsearch.gradle.internal.test.GradleUnitTestCase;
import org.elasticsearch.gradle.internal.test.rest.transform.headers.InjectHeaders;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsCollectionContaining;
import org.junit.Before;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.LongAdder;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public abstract class TransformTests extends GradleUnitTestCase {
Expand Down Expand Up @@ -181,11 +182,11 @@ protected ObjectNode getSkipNode(ArrayNode setupNodeValue) {
return null;
}

protected void validateBodyHasWarnings(String featureName, List<ObjectNode> tests, Set<String> expectedWarnings) {
protected void validateBodyHasWarnings(String featureName, List<ObjectNode> tests, Collection<String> expectedWarnings) {
validateBodyHasWarnings(featureName, null, tests, expectedWarnings);
}

protected void validateBodyHasWarnings(String featureName, String testName, List<ObjectNode> tests, Set<String> expectedWarnings) {
protected void validateBodyHasWarnings(String featureName, String testName, List<ObjectNode> tests, Collection<String> expectedWarnings) {
AtomicBoolean actuallyDidSomething = new AtomicBoolean(false);
tests.forEach(test -> {
Iterator<Map.Entry<String, JsonNode>> testsIterator = test.fields();
Expand All @@ -201,13 +202,10 @@ protected void validateBodyHasWarnings(String featureName, String testName, List
ObjectNode doSection = (ObjectNode) testSection.get("do");
assertThat(doSection.get(featureName), CoreMatchers.notNullValue());
ArrayNode warningsNode = (ArrayNode) doSection.get(featureName);
LongAdder assertions = new LongAdder();
warningsNode.forEach(warning -> {
if (expectedWarnings.contains(warning.asText())) {
assertions.increment();
}
});
assertThat(assertions.intValue(), CoreMatchers.equalTo(expectedWarnings.size()));
List<String> actual = new ArrayList<>();
warningsNode.forEach(node -> actual.add(node.asText()));
String[] expected = expectedWarnings.toArray(new String[]{});
assertThat(actual, Matchers.containsInAnyOrder(expected));
actuallyDidSomething.set(true);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public void testInjectAllowedWarningsWithPreExisting() throws Exception {
List<ObjectNode> transformedTests = transformTests(tests);
printTest(testName, transformedTests);
validateSetupAndTearDown(transformedTests);
validateBodyHasWarnings(ALLOWED_WARNINGS_REGEX, tests, Set.of("c", "d"));
validateBodyHasWarnings(ALLOWED_WARNINGS_REGEX, tests, addWarnings);
validateBodyHasWarnings(ALLOWED_WARNINGS_REGEX, tests, Set.of("c", "d", "added warning"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,24 @@ public void testInjectAllowedWarningsWithPreExisting() throws Exception {
List<ObjectNode> transformedTests = transformTests(tests);
printTest(testName, transformedTests);
validateSetupAndTearDown(transformedTests);
validateBodyHasWarnings(ALLOWED_WARNINGS, transformedTests, List.of("a", "b", "added warning"));
}

@Test
public void testInjectAllowedWarningsWithPreExistingForSingleTest() throws Exception {
String testName = "/rest/transform/warnings/with_existing_allowed_warnings.yml";
List<ObjectNode> tests = getTests(testName);
validateSetupExist(tests);
validateBodyHasWarnings(ALLOWED_WARNINGS, tests, Set.of("a", "b"));
validateBodyHasWarnings(ALLOWED_WARNINGS, tests, addWarnings);
List<ObjectNode> transformedTests = transformTests(tests, getTransformationsForTest("Test with existing allowed warnings"));
printTest(testName, transformedTests);
validateSetupAndTearDown(transformedTests);
validateBodyHasWarnings(ALLOWED_WARNINGS, "Test with existing allowed warnings", transformedTests, Set.of("a", "b", "added warning"));
validateBodyHasWarnings(ALLOWED_WARNINGS, "Test with existing allowed warnings not to change", transformedTests, Set.of("a", "b"));
}

private List<RestTestTransform<?>> getTransformationsForTest(String testName) {
return Collections.singletonList(new InjectAllowedWarnings(false, new ArrayList<>(addWarnings), testName));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void testInjectWarningsWithPreExisting() throws Exception {
List<ObjectNode> transformedTests = transformTests(tests);
printTest(testName, transformedTests);
validateSetupAndTearDown(transformedTests);
validateBodyHasWarnings(WARNINGS_REGEX, tests, Set.of("c", "d"));
validateBodyHasWarnings(WARNINGS_REGEX, "Test warnings", tests, addWarnings);
validateBodyHasWarnings(WARNINGS_REGEX, "Not the test to change", tests, Set.of("c", "d"));
validateBodyHasWarnings(WARNINGS_REGEX, "Test warnings", tests, Set.of("c", "d", "added warning"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void testInjectWarningsWithPreExisting() throws Exception {
List<ObjectNode> transformedTests = transformTests(tests);
printTest(testName, transformedTests);
validateSetupAndTearDown(transformedTests);
validateBodyHasWarnings(WARNINGS, tests, Set.of("a", "b"));
validateBodyHasWarnings(WARNINGS, "Test warnings", tests, addWarnings);
validateBodyHasWarnings(WARNINGS, "Not the test to change", tests, Set.of("a", "b"));
validateBodyHasWarnings(WARNINGS, "Test warnings", tests, Set.of("a", "b", "added warning"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ public void testRemoveWarningWithPreExisting() throws Exception {
validateBodyHasWarnings(WARNINGS, tests, Set.of("b"));
}

@Test
public void testRemoveWarningWithPreExistingFromSingleTest() throws Exception {
String testName = "/rest/transform/warnings/with_existing_warnings.yml";
List<ObjectNode> tests = getTests(testName);
validateSetupExist(tests);
validateBodyHasWarnings(WARNINGS, tests, Set.of("a", "b"));
List<ObjectNode> transformedTests = transformTests(tests, getTransformationsForTest("Test warnings"));
printTest(testName, transformedTests);
validateSetupAndTearDown(transformedTests);
validateBodyHasWarnings(WARNINGS, "Test warnings", tests, Set.of("b"));
validateBodyHasWarnings(WARNINGS, "Not the test to change", tests, Set.of("a", "b"));
}

private List<RestTestTransform<?>> getTransformationsForTest(String testName) {
return Collections.singletonList(new RemoveWarnings(Set.of("a"), testName));
}

/**
* test file has preexisting single warning
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ setup:
id: "something"
- match: { acknowledged: true }

---
"Test with existing allowed warnings not to change":
- do:
allowed_warnings:
- "a"
- "b"
allowed_warnings_regex:
- "c"
- "d"
something:
id: "something_else"
- match: { acknowledged: true }
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags:
# Build args passed to Dockerfile ARGs
args:
BASE_IMAGE: "redhat/ubi/ubi8"
BASE_TAG: "8.3"
BASE_TAG: "8.4"

# Docker image labels
labels:
Expand Down
12 changes: 12 additions & 0 deletions docs/reference/cluster/nodes-stats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,18 @@ Time by which recovery operations were delayed due to throttling.
Time in milliseconds
recovery operations were delayed due to throttling.
=======

`shards`::
(object)
Contains statistics about all shards assigned to the node.
+
.Properties of `shards`
[%collapsible%open]
=======
`total_count`::
(integer)
The total number of shards assigned to the node.
======
======

[[cluster-nodes-stats-api-response-body-os]]
Expand Down
59 changes: 59 additions & 0 deletions docs/reference/commands/create-enrollment-token.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[roles="xpack"]
[[create-enrollment-token]]

== elasticsearch-create-enrollment-token

The `elasticsearch-create-enrollment-token` command creates enrollment tokens for
{es} nodes and {kib} instances.

[discrete]
=== Synopsis

[source,shell]
----
bin/elasticsearch-create-enrollment-token
[-f, --force] [-h, --help] [-E <KeyValuePair>] [-s, --scope]
----

[discrete]
=== Description

Use this command to create enrollment tokens, which you can use to enroll new
{es} nodes to an existing cluster or configure {kib} instances to communicate
with an existing {es} cluster that has security features enabled.
The command generates (and subsequently removes) a temporary user in the
<<file-realm,file realm>> to run the request that creates enrollment tokens.
IMPORTANT: You cannot use this tool if the file realm is disabled in your
`elasticsearch.yml` file.

This command uses an HTTP connection to connect to the cluster and run the user
management requests. The command automatically attempts to establish the connection
over HTTPS by using the `xpack.security.http.ssl` settings in
the `elasticsearch.yml` file. If you do not use the default configuration directory,
ensure that the `ES_PATH_CONF` environment variable returns the
correct path before you run the `elasticsearch-create-enrollment-token` command. You can
override settings in your `elasticsearch.yml` file by using the `-E` command
option. For more information about debugging connection failures, see
<<trb-security-setup>>.

[discrete]
[[create-enrollment-token-parameters]]
=== Parameters

`-E <KeyValuePair>`:: Configures a standard {es} or {xpack} setting.

`-f, --force`:: Forces the command to run against an unhealthy cluster.

`-h, --help`:: Returns all of the command parameters.

`-s, --scope`:: Specifies the scope of the generated token. Supported values are `node` and `kibana`.

[discrete]
=== Examples

The following command creates an enrollment token for enrolling an {es} node into a cluster:

[source,shell]
----
bin/elasticsearch-create-enrollment-token -s node
----
Loading