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

[Feature/multi_tenancy] Tenant-aware integration tests for Connector, Model, Agent, Model Groups #2818

Open
wants to merge 33 commits into
base: feature/multi_tenancy
Choose a base branch
from

Conversation

dbwiddis
Copy link
Member

@dbwiddis dbwiddis commented Aug 9, 2024

Description

Tests the entire Create-Get-Update-Search-Delete cycle with multi-tenancy (both enabled and not).

Validates expected results when tenant aware and when not (current status quo).

Looking for review on the approach before replicating to models and agents and other tenant-aware updates, although I won't wait before starting that work. If you want a simpler review, get started now. :)

To execute just these tests:

./gradlew ':opensearch-ml-plugin:integTest' -Dtests.rest.tenantaware=true

or

./gradlew ':opensearch-ml-plugin:integTest' -Dtests.rest.tenantaware=false

Because the classes end in IT, the "false" version executes with normal integ tests as well, a separate test needs to be done for the true case.

Check List

  • New functionality includes testing.
  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dbwiddis dbwiddis marked this pull request as draft August 9, 2024 15:29
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
@@ -184,10 +187,23 @@ integTest {
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")

// Only tenant aware test if set
if (System.getProperty("tests.rest.tenantaware") != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to check true too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, you're looking at this PR! :)

Yes, we do. Most of the build.gradle right now is a work in progress; we need to figure out a way to test on all the different remote stores but they also require a lot more setup (docker, ddb, etc.). Still need to do some cleanup at the end of all the tests as well (since the "wipe all indices" doesn't work remotely).

@@ -19,18 +19,14 @@

import static org.opensearch.sdk.SdkClientUtils.unwrapAndConvertToException;

public class SdkClient implements SettingsChangeListener {
public class SdkClient {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to change this?

I understand if we make the settings static, there's no need for the listener. But even if we keep the settings static this piece of code shouldn't break the functionality.

IMO, it's even a two way door, like if we want to make the settings dynamic, corresponding listener solution is already in place. On top of that we haven't finalized the nature of this settings yet.

@@ -677,4 +674,26 @@ public void testSearchDataObject_NullTenantId() throws IOException {
assertEquals(OpenSearchStatusException.class, cause.getClass());
assertEquals("Tenant ID is required when multitenancy is enabled.", cause.getMessage());
}

public void testSearchDataObject_NullTenantNoMultitenancy() throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add @Test

public static final Setting<Boolean> ML_COMMONS_MULTI_TENANCY_ENABLED = Setting
.boolSetting("plugins.ml_commons.multi_tenancy_enabled", false, Setting.Property.NodeScope, Setting.Property.Dynamic);
.boolSetting("plugins.ml_commons.multi_tenancy_enabled", false, Setting.Property.NodeScope);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we need to make this settings static, do we need to do this now?
Usually dynamic was helpful for manual testing :D


public class RestMLConnectorTenantAwareIT extends MLCommonsTenantAwareRestTestCase {

public void testConnectorCRUD() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add @Test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants