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

[Spaces] Moved tests to agnostic setup #200606

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

elena-shostak
Copy link
Contributor

@elena-shostak elena-shostak commented Nov 18, 2024

Summary

Moved space tests to deployment agnostic setup.

Checklist

Closes: #194584

@elena-shostak
Copy link
Contributor Author

/ci

9 similar comments
@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak elena-shostak changed the title Moved tests to agnostic setup [Spaces] Moved tests to agnostic setup Nov 19, 2024
@elena-shostak elena-shostak added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Security/Spaces Platform Security - Spaces feature FTR release_note:skip Skip the PR/issue when compiling release notes labels Nov 19, 2024
@elena-shostak elena-shostak force-pushed the space-deployment-agnostic branch from 8fedf64 to f6def7f Compare November 19, 2024 14:11
@elena-shostak
Copy link
Contributor Author

/ci

@azasypkin azasypkin self-requested a review November 19, 2024 16:02
@elena-shostak elena-shostak force-pushed the space-deployment-agnostic branch 2 times, most recently from 2df08a0 to 1464f66 Compare December 27, 2024 12:55
@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#7634

[❌] x-pack/test/spaces_api_integration/deployment_agnostic/stateful.config_trial.ts: 0/10 tests passed.

see run history

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#7635

[❌] x-pack/test/spaces_api_integration/deployment_agnostic/stateful.config_trial.ts: 0/1 tests passed.
[❌] x-pack/test/spaces_api_integration/deployment_agnostic/stateful.copy_to_space.config_basic.ts: 0/1 tests passed.
[❌] x-pack/test/spaces_api_integration/deployment_agnostic/stateful.copy_to_space.config_trial.ts: 0/1 tests passed.
[❌] x-pack/test/spaces_api_integration/deployment_agnostic/spaces_only/config.ts: 0/1 tests passed.
[❌] x-pack/test/spaces_api_integration/security_and_spaces/config_basic.ts: 0/1 tests passed.
[❌] x-pack/test/spaces_api_integration/security_and_spaces/config_trial.ts: 0/1 tests passed.

see run history

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

/сi

@elena-shostak elena-shostak force-pushed the space-deployment-agnostic branch from efed4f7 to 585fcec Compare December 30, 2024 13:25
) {
const license = config.get('esTestCluster.license');

if (!user || license !== 'trial') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Important

We have a shared test suite for basic/trial licenses, which includes tests for both authorized and unauthorized users. Decoupling these tests is a complex and time-consuming task that requires careful consideration to avoid ending up with a significant amount of duplicated test code for different licenses.

Our custom service for RoleScopedSupertest takes it into account license and user passed/not passed to adjust needed supertest accordingly.

@@ -139,7 +139,7 @@
"id": "conflict_2_default",
"originId": "conflict_2",
"references": [],
"type": "sharedtype",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note

sharedtype changed to event-annotation-group SO
isolatedtype changed to url SO

I failed to change sharedtype to index-pattern SO type since I was getting a lot of missing references errors, probably it was due to the fact that index-pattern was migrated to the multiple namespace from 8.0.0

@@ -34,5 +34,11 @@ module.exports = {
'@typescript-eslint/no-floating-promises': 'error',
},
},
{
files: ['*spaces_api_integration/common/services/basic_auth_supertest.ts'],
Copy link
Contributor Author

@elena-shostak elena-shostak Jan 3, 2025

Choose a reason for hiding this comment

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

agent.auth(this.user.username!, this.user.password!);

Needed to suppress the eslint error for this line in our custom test service, the promise is awaited in the tests itself and adding a catch block breaks some of the test cases

eslint-disable line gets removed because this rule runs dynamically

.join(', ')}`
);

// _update_objects_spaces route is internal in serverless and public in stateful
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note

Decided to not add complexity to the custom roleScopedSupertest to accommodate this use case, so made it in place.

includeAuthorizedPurposes: {
statusCode: 403,
response: expectRbacForbidden,
if (!isServerless) {
Copy link
Contributor Author

@elena-shostak elena-shostak Jan 7, 2025

Choose a reason for hiding this comment

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

Note

There are no machine_learning_admin, machine_learning_user and monitoring_user roles in serverless.
We could rather move it to it's own test only for stateful or define custom roles, would like to have suggestions on this one 🙂

@elena-shostak elena-shostak added the backport:skip This commit does not require backporting label Jan 7, 2025
@elena-shostak elena-shostak marked this pull request as ready for review January 7, 2025 14:00
@elena-shostak elena-shostak requested review from a team as code owners January 7, 2025 14:00
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

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

.buildkite and src/dev/eslint/types.eslint.config.template.cjs LGTM

@jeramysoucy jeramysoucy requested a review from dmlemeshko January 9, 2025 17:04
@@ -128,3 +128,65 @@ system_indices_superuser:
privileges: ['*']
resources: ['*']
run_as: ['*']

machine_learning_admin:
Copy link
Member

Choose a reason for hiding this comment

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

roles.yml is expected to list only default Cloud roles, we keep consistency with Cloud (both MKI and ESS) because we can't provision roles from this file to Cloud deployment. In order to make things work, we introduced custom roles support in FTR:

// First set privileges for custom role
await samlAuth.setCustomRole({
        elasticsearch: {
          indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }],
        },
        kibana: [
          {
            feature: {
              discover: ['read'],
            },
            spaces: ['*'],
          },
        ],
      });
    });

// Then you can login in browser as a user with newly defined privileges
await pageObjects.svlCommonPage.loginWithCustomRole()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, but in stateful they are built in already, isn't it? (screenshots are from cloud deployment)
Am I missing smth?

Screenshot 2025-01-10 at 11 01 58 Screenshot 2025-01-10 at 11 01 49

Copy link
Contributor

@jeramysoucy jeramysoucy Jan 14, 2025

Choose a reason for hiding this comment

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

These roles are built-in to stateful, but not serverless. The predefined serverless roles can be found in the roles.yml files in packages/kbn-es/src/serverless_resources/project_roles, nested under solution-specific folders.

Any tests that need a role other than these built-in serveless roles, will require a custom role, and will not be able to run on MKI from the FTR (at least for the time being, as it is not yet supported).

The stateful roles file is meant to mirror the serverless roles to keep the testing methodology the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will move it to custom role

Copy link
Contributor Author

Choose a reason for hiding this comment

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

UPD: we cannot use our api for custom roles or at least I don't see how. All those 3 roles rely on reserved built in privileges: ml_admin, ml_user, reserved_monitoring . I cannot pass those in, since we accept only read, all, none. Going one layer down to use es api to create those roles and adding other if/else statements seems not feasible.

I've moved those 3 tests to only stateful for now.

@@ -104,3 +104,8 @@ enabled:
- x-pack/test/cloud_security_posture_functional/data_views/config.ts
- x-pack/test/automatic_import_api_integration/apis/config_basic.ts
- x-pack/test/automatic_import_api_integration/apis/config_graphs.ts
- x-pack/test/spaces_api_integration/deployment_agnostic/spaces_only/config.ts
- x-pack/test/spaces_api_integration/deployment_agnostic/security_and_spaces/stateful.config_basic.ts
Copy link
Member

Choose a reason for hiding this comment

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

I think we discussed it with @azasypkin and @jeramysoucy , that while basic license is stateful-only, these tests cannot be considered deployment-agnostic. wdyt?

Copy link
Contributor Author

@elena-shostak elena-shostak Jan 10, 2025

Choose a reason for hiding this comment

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

I can move them out of the deployment_agnostic folder to eliminate confusion, but all those tests still use the same test suite the serverless/trial config does

Copy link
Member

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

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

Great progress! I left few questions

@jeramysoucy jeramysoucy self-requested a review January 10, 2025 17:17
@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/test-suites-xpack 737 721 -16

Total ESLint disabled count

id before after diff
@kbn/test-suites-xpack 762 746 -16

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Security/Spaces Platform Security - Spaces feature FTR release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leverage deployment agnostic SamlAuthProvider for Spaces API tests
8 participants