-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Adds usage data for ILM #33377
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
Merged
Merged
Adds usage data for ILM #33377
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
96935f9
Adds usage data for ILM
colings86 7d76b42
Adds tests for IndexLifecycleFeatureSetUsage and friends
colings86 0137385
Adds tests for IndexLifecycleFeatureSet
colings86 2d093d8
Fixes merge errors
colings86 368c0b4
Add number of indices managed to usage stats
colings86 25e66ed
Addresses Review comments
colings86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
.../java/org/elasticsearch/xpack/core/indexlifecycle/IndexLifecycleFeatureSetUsageTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.core.indexlifecycle; | ||
|
|
||
| import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
| import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleFeatureSetUsage.PolicyStats; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class IndexLifecycleFeatureSetUsageTests extends AbstractWireSerializingTestCase<IndexLifecycleFeatureSetUsage> { | ||
|
|
||
| @Override | ||
| protected IndexLifecycleFeatureSetUsage createTestInstance() { | ||
| boolean enabled = randomBoolean(); | ||
| boolean available = randomBoolean(); | ||
| List<PolicyStats> policyStats = null; | ||
| if (enabled) { | ||
| int size = randomIntBetween(0, 10); | ||
| policyStats = new ArrayList<>(size); | ||
| for (int i = 0; i < size; i++) { | ||
| policyStats.add(PolicyStatsTests.createRandomInstance()); | ||
| } | ||
| } | ||
| return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats); | ||
| } | ||
|
|
||
| @Override | ||
| protected IndexLifecycleFeatureSetUsage mutateInstance(IndexLifecycleFeatureSetUsage instance) throws IOException { | ||
| boolean available = instance.available(); | ||
| boolean enabled = instance.enabled(); | ||
| List<PolicyStats> policyStats = instance.getPolicyStats(); | ||
| switch (between(0, 2)) { | ||
| case 0: | ||
| available = available == false; | ||
| break; | ||
| case 1: | ||
| enabled = enabled == false; | ||
| break; | ||
| case 2: | ||
| if (policyStats == null) { | ||
| policyStats = new ArrayList<>(); | ||
| policyStats.add(PolicyStatsTests.createRandomInstance()); | ||
| } else if (randomBoolean()) { | ||
| policyStats = null; | ||
| } else { | ||
| policyStats = new ArrayList<>(policyStats); | ||
| policyStats.add(PolicyStatsTests.createRandomInstance()); | ||
| } | ||
| break; | ||
| default: | ||
| throw new AssertionError("Illegal randomisation branch"); | ||
| } | ||
| return new IndexLifecycleFeatureSetUsage(available, enabled, policyStats); | ||
| } | ||
|
|
||
| @Override | ||
| protected Reader<IndexLifecycleFeatureSetUsage> instanceReader() { | ||
| return IndexLifecycleFeatureSetUsage::new; | ||
| } | ||
|
|
||
| } |
53 changes: 53 additions & 0 deletions
53
...lugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/PhaseStatsTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.core.indexlifecycle; | ||
|
|
||
| import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
| import org.elasticsearch.common.unit.TimeValue; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
| import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleFeatureSetUsage.PhaseStats; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
|
|
||
| public class PhaseStatsTests extends AbstractWireSerializingTestCase<PhaseStats> { | ||
|
|
||
| @Override | ||
| protected PhaseStats createTestInstance() { | ||
| return createRandomInstance(); | ||
| } | ||
|
|
||
| public static PhaseStats createRandomInstance() { | ||
| TimeValue after = TimeValue.parseTimeValue(randomTimeValue(), "phase_stats_tests"); | ||
| String[] actionNames = randomArray(0, 20, size -> new String[size], () -> randomAlphaOfLengthBetween(1, 20)); | ||
| return new PhaseStats(after, actionNames); | ||
| } | ||
|
|
||
| @Override | ||
| protected PhaseStats mutateInstance(PhaseStats instance) throws IOException { | ||
| TimeValue after = instance.getAfter(); | ||
| String[] actionNames = instance.getActionNames(); | ||
| switch (between(0, 1)) { | ||
| case 0: | ||
| after = randomValueOtherThan(after, () -> TimeValue.parseTimeValue(randomPositiveTimeValue(), "rollover_action_test")); | ||
| break; | ||
| case 1: | ||
| actionNames = randomValueOtherThanMany(a -> Arrays.equals(a, instance.getActionNames()), | ||
| () -> randomArray(0, 20, size -> new String[size], () -> randomAlphaOfLengthBetween(1, 20))); | ||
| break; | ||
| default: | ||
| throw new AssertionError("Illegal randomisation branch"); | ||
| } | ||
| return new PhaseStats(after, actionNames); | ||
| } | ||
|
|
||
| @Override | ||
| protected Reader<PhaseStats> instanceReader() { | ||
| return PhaseStats::new; | ||
| } | ||
|
|
||
| } |
57 changes: 57 additions & 0 deletions
57
...ugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/PolicyStatsTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.core.indexlifecycle; | ||
|
|
||
| import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
| import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleFeatureSetUsage.PhaseStats; | ||
| import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleFeatureSetUsage.PolicyStats; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class PolicyStatsTests extends AbstractWireSerializingTestCase<PolicyStats> { | ||
|
|
||
| @Override | ||
| protected PolicyStats createTestInstance() { | ||
| return createRandomInstance(); | ||
| } | ||
|
|
||
| public static PolicyStats createRandomInstance() { | ||
| int size = randomIntBetween(0, 10); | ||
| Map<String, PhaseStats> phaseStats = new HashMap<>(size); | ||
| for (int i = 0; i < size; i++) { | ||
| phaseStats.put(randomAlphaOfLengthBetween(1, 20), PhaseStatsTests.createRandomInstance()); | ||
| } | ||
| return new PolicyStats(phaseStats, randomIntBetween(0, 100)); | ||
| } | ||
|
|
||
| @Override | ||
| protected PolicyStats mutateInstance(PolicyStats instance) throws IOException { | ||
| Map<String, PhaseStats> phaseStats = instance.getPhaseStats(); | ||
| int indicesManaged = instance.getIndicesManaged(); | ||
| switch (between(0, 1)) { | ||
| case 0: | ||
| phaseStats = new HashMap<>(instance.getPhaseStats()); | ||
| phaseStats.put(randomAlphaOfLengthBetween(1, 20), PhaseStatsTests.createRandomInstance()); | ||
| break; | ||
| case 1: | ||
| indicesManaged = randomIntBetween(1, 50); | ||
| break; | ||
| default: | ||
| throw new AssertionError("Illegal randomisation branch"); | ||
| } | ||
| return new PolicyStats(phaseStats, indicesManaged); | ||
| } | ||
|
|
||
| @Override | ||
| protected Reader<PolicyStats> instanceReader() { | ||
| return PolicyStats::new; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at first I thought this format would make it difficult to know how many policies didn't use a certain field, but after a few test queries, it looks like this is sufficient