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 QueryGroup schema #13669

Merged
merged 31 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d417d17
rebase with opensearch/main
kaushalmahi12 Apr 10, 2024
be38bae
add resourceLimitGroupId propagation logic from coordinator to data n…
kaushalmahi12 Apr 12, 2024
8651420
add sandbox schema
kaushalmahi12 Apr 15, 2024
07db8cc
add resourceLimitGroupTests
kaushalmahi12 Apr 16, 2024
f531c53
add resourceLimitGroupMetadata tests
kaushalmahi12 Apr 18, 2024
bfdfb88
run spotlessApply
kaushalmahi12 Apr 18, 2024
7631713
add mode field in ResourceLimitGroup schema
kaushalmahi12 Apr 18, 2024
49b63fa
fix breaking testcases
kaushalmahi12 Apr 19, 2024
0270812
add task cancellation skeleton
kaushalmahi12 Apr 22, 2024
942e142
add multitenant labels in searchSource builder
kaushalmahi12 May 8, 2024
0ca624c
write custom xcontent parser for ResourceLimitGroup
kaushalmahi12 May 14, 2024
163031f
remove unrelated changes
kaushalmahi12 May 14, 2024
c07e5f8
remove non-existing import fro cluster settings
kaushalmahi12 May 14, 2024
098e4df
remove non releated changes
kaushalmahi12 May 14, 2024
fba1dac
add _id as the resourceLimitGroup key
kaushalmahi12 May 15, 2024
7498237
add change to register resource limit group metadata
kaushalmahi12 May 20, 2024
34d22a9
add updatedAt in resource limit group
kaushalmahi12 Jun 3, 2024
a918d35
rename resourceLimitGroup to queryGroup
kaushalmahi12 Jun 13, 2024
a494037
address the comments on PR
kaushalmahi12 Jun 19, 2024
fb58576
rename the mode member var to resiliency mode
kaushalmahi12 Jun 19, 2024
3a1a3ef
address comments
kaushalmahi12 Jun 20, 2024
0da3b68
add change in CHANGELOG
kaushalmahi12 Jun 21, 2024
4508c9d
add tests for custom namedWritable QueryGroupMetadata
kaushalmahi12 Jun 21, 2024
1e45475
structure resourceLimits into an object
kaushalmahi12 Jun 25, 2024
769a46f
add QueryGroup.toXContent test case
kaushalmahi12 Jun 26, 2024
15076eb
Merge branch 'main' into feature/sandbox-schemaPR
kaushalmahi12 Jul 2, 2024
5a7f405
fix precommit errors
kaushalmahi12 Jul 2, 2024
5153a74
fix precommit errors
kaushalmahi12 Jul 2, 2024
c5a70e9
fix assemble errors
kaushalmahi12 Jul 2, 2024
42d3494
fix checkstyle errors
kaushalmahi12 Jul 2, 2024
8a45648
address comments
kaushalmahi12 Jul 3, 2024
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
Prev Previous commit
Next Next commit
add resourceLimitGroupTests
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
  • Loading branch information
kaushalmahi12 committed Jun 25, 2024
commit 07db8cc54dc90aed1cfe4270dfdd6992b38c3396
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
@ExperimentalApi
public class ResourceLimitGroup extends AbstractDiffable<ResourceLimitGroup> implements ToXContentObject {
kaushalmahi12 marked this conversation as resolved.
Show resolved Hide resolved

public static final int MAX_CHARS_ALLOWED_IN_NAME = 50;
private final String name;
private final List<ResourceLimit> resourceLimits;

Expand All @@ -59,7 +60,18 @@ public class ResourceLimitGroup extends AbstractDiffable<ResourceLimitGroup> imp
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), (p, c) -> ResourceLimit.fromXContent(p), RESOURCE_LIMITS_FIELD);
}

public ResourceLimitGroup(String name, List<ResourceLimit> resourceLimits) {
public ResourceLimitGroup(final String name, final List<ResourceLimit> resourceLimits) {
Objects.requireNonNull(name, "ResourceLimitGroup.name can't be null");
Objects.requireNonNull(resourceLimits, "ResourceLimitGroup.resourceLimits can't be null");

if (name.length() > MAX_CHARS_ALLOWED_IN_NAME) {
throw new IllegalArgumentException("ResourceLimitGroup.name shouldn't be more than 50 chars long");
kaushalmahi12 marked this conversation as resolved.
Show resolved Hide resolved
}

if (resourceLimits.isEmpty()) {
throw new IllegalArgumentException("ResourceLimitGroup.resourceLimits should at least have 1 resource limit");
}

this.name = name;
this.resourceLimits = resourceLimits;
}
Expand Down Expand Up @@ -208,4 +220,8 @@ public int hashCode() {
public String getName() {
return name;
}

public List<ResourceLimit> getResourceLimits() {
return resourceLimits;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
import org.opensearch.search.backpressure.settings.SearchShardTaskSettings;
import org.opensearch.search.backpressure.settings.SearchTaskSettings;
import org.opensearch.search.fetch.subphase.highlight.FastVectorHighlighter;
<<<<<<< HEAD
=======
import org.opensearch.search.resource_limit_group.ResourceLimitGroupServiceSettings;
>>>>>>> ba237c14d3f (add resourceLimitGroupTests)
import org.opensearch.snapshots.InternalSnapshotsInfoService;
import org.opensearch.snapshots.SnapshotsService;
import org.opensearch.tasks.TaskCancellationMonitoringSettings;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.cluster.metadata;

import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.test.AbstractSerializingTestCase;

import java.io.IOException;
import java.util.List;

public class ResourceLimitGroupTests extends AbstractSerializingTestCase<ResourceLimitGroup> {


private ResourceLimitGroup createRandomResourceLimitGroup() {
String name = randomAlphaOfLength(10);
ResourceLimitGroup.ResourceLimit resourceLimit = new ResourceLimitGroup.ResourceLimit("jvm",
randomDoubleBetween(0.0, 0.80, false));
return new ResourceLimitGroup(name, List.of(resourceLimit));
}

/**
* Parses to a new instance using the provided {@link XContentParser}
*
* @param parser
*/
@Override
protected ResourceLimitGroup doParseInstance(XContentParser parser) throws IOException {
return ResourceLimitGroup.fromXContent(parser);
}

/**
* Returns a {@link Writeable.Reader} that can be used to de-serialize the instance
*/
@Override
protected Writeable.Reader<ResourceLimitGroup> instanceReader() {
return ResourceLimitGroup::new;
}

/**
* Creates a random test instance to use in the tests. This method will be
* called multiple times during test execution and should return a different
* random instance each time it is called.
*/
@Override
protected ResourceLimitGroup createTestInstance() {
return createRandomResourceLimitGroup();
}

public void testNullName() {
assertThrows(NullPointerException.class,
() -> new ResourceLimitGroup(null, List.of()));
}

public void testNullResourceLimits() {
assertThrows(NullPointerException.class,
() -> new ResourceLimitGroup("analytics", null));
}

public void testEmptyResourceLimits() {
assertThrows(IllegalArgumentException.class,
() -> new ResourceLimitGroup("analytics", List.of()));
}

public void testInvalidResourceLimitWhenInvalidSystemResourceNameIsGiven() {
assertThrows(IllegalArgumentException.class, () -> new ResourceLimitGroup(
"analytics",
List.of(
new ResourceLimitGroup.ResourceLimit("RequestRate", randomDoubleBetween(0.01, 0.8, false))
)
));
}

public void testInvalidResourceLimitWhenInvalidSystemResourceValueIsGiven() {
assertThrows(IllegalArgumentException.class, () -> new ResourceLimitGroup(
"analytics",
List.of(
new ResourceLimitGroup.ResourceLimit("RequestRate", randomDoubleBetween(1.1, 1.8, false))
)
));
}

public void testValidResourceLimitGroup() {
ResourceLimitGroup resourceLimitGroup = new ResourceLimitGroup(
"analytics",
List.of(
new ResourceLimitGroup.ResourceLimit("jvm", randomDoubleBetween(0.01, 0.8, false))
)
);

assertNotNull(resourceLimitGroup.getName());
assertEquals("analytics", resourceLimitGroup.getName());
assertNotNull(resourceLimitGroup.getResourceLimits());
assertFalse(resourceLimitGroup.getResourceLimits().isEmpty());
assertEquals(1, resourceLimitGroup.getResourceLimits().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.search.resource_limit_group.ResourceLimitGroupServiceSettings;
import org.opensearch.test.OpenSearchTestCase;

import static org.opensearch.search.sandbox.ResourceLimitGroupServiceSettings.NODE_CANCELLATION_THRESHOLD_SETTING_NAME;
import static org.opensearch.search.sandbox.ResourceLimitGroupServiceSettings.NODE_REJECTION_THRESHOLD_SETTING_NAME;
import static org.opensearch.search.sandbox.ResourceLimitGroupServiceSettings.RESOURCE_LIMIT_GROUP_COUNT_SETTING_NAME;
import static org.opensearch.search.resource_limit_group.ResourceLimitGroupServiceSettings.NODE_CANCELLATION_THRESHOLD_SETTING_NAME;
import static org.opensearch.search.resource_limit_group.ResourceLimitGroupServiceSettings.NODE_REJECTION_THRESHOLD_SETTING_NAME;
import static org.opensearch.search.resource_limit_group.ResourceLimitGroupServiceSettings.RESOURCE_LIMIT_GROUP_COUNT_SETTING_NAME;

public class ResourceLimitGroupServiceSettingsTests extends OpenSearchTestCase {

Expand Down