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

[Synthetics] [Meta] Port API tests from stateful to serverless #179100

Closed
justinkambic opened this issue Mar 20, 2024 · 8 comments
Closed

[Synthetics] [Meta] Port API tests from stateful to serverless #179100

justinkambic opened this issue Mar 20, 2024 · 8 comments
Labels
Synthetics Team:obs-ux-management Observability Management User Experience Team technical debt Improvement of the software architecture and operational architecture

Comments

@justinkambic
Copy link
Contributor

justinkambic commented Mar 20, 2024

Some additional work that came out of #178897, we need to have some assurance that Synthetics will not catastrophically fail on Serverless when dependencies change. This is a visible risk that is illustrated in the linked issue for that PR.

As such, we should port at least a subset of the Synthetics API tests to the Serverless section of x-pack testing. This will give us at least assurance that our Kibana server is functioning nominally as more changes go in.

I've converted this task to a meta ticket with sub-issues stubbed out. I'll update each issue with links to the code in question, and add a guide to the meta for adapting tests that rely on features like roles and the ES security API that aren't available in Serverless. I'll also include links to the testing docs for Kibana's Serverless test suite.

Prior art

You can see the initial implementation as part of #179861.

Key differences

When interacting via API endpoints, many of the Stateful tests utilize supertestWithAuth and make requests via users/roles they create using the security service:

          const username = 'admin';
          const roleName = `synthetics_admin-${privilege}`;
          const password = `${username}-password`;
          try {
            await security.role.create(roleName, {
              kibana: [
                {
                  feature: {
                    uptime: ['all'],
                  },
                  spaces: ['*'],
                },
              ],
              elasticsearch: {
                cluster: [privilege],
                indices: getServiceApiKeyPrivileges(false).indices,
              },
            });

In Serverless, there's a SAML simulator you can use to provide the necessary auth via supertestWithoutAuth:

note: at this time it's recommended to avoid using system_indices_superuser because this does not exist in MKI and will cause the test to fail and be skipped.

// `role` can be 'system_indices_superuser', 'admin', 'editor', 'viewer'
supertestWithoutAuth
  .put(SYNTHETICS_API_URLS.SYNTHETICS_ENABLEMENT)
  // internal request header is different from the typical kbn-xsrf header
  // implementation details are available in the PR linked above
  .set(internalRequestHeader)
  .set(await svlUserManager.getApiCredentialsForRole(role))
  .expect(expectedStatus);

Smells to look for are declarations like:

// custom user creation
const username = 'admin';
const roleName = `synthetics_admin-${privilege}`;

// calls to create custom roles
await security.role.create(roleName, ...)

The Serverless alternative is to choose the appropriate SAML role to utilize to replicate the spirit of the original test you're porting.

Guidance

You can learn more about writing and manipulating serverless tests in general and API tests specifically by reviewing the README for the test_serverless section of the Kibana repo.

@botelastic botelastic bot added the needs-team Issues missing a team label label Mar 20, 2024
@mbondyra mbondyra added apm:synthtrace APM Synthtrace Topics Team:Observability Team label for Observability Team (for things that are handled across all of observability) labels Mar 20, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/unified-observability (Team:Observability)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Mar 20, 2024
@justinkambic justinkambic self-assigned this Mar 27, 2024
@justinkambic justinkambic changed the title [Synthetics] Port API tests from stateful to serverless [Synthetics] [Meta] Port API tests from stateful to serverless Apr 3, 2024
justinkambic added a commit that referenced this issue Apr 4, 2024
## Summary

Related to #179100.

Sets up Synthetics API Integrations suite in Serverless Tests and adds
tests for the enablement endpoint.

Additional API test ports will be posted following up on this in the
coming days.

---------

Co-authored-by: kibanamachine <[email protected]>
@justinkambic justinkambic added Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team and removed apm:synthtrace APM Synthtrace Topics labels Apr 4, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@justinkambic justinkambic added the technical debt Improvement of the software architecture and operational architecture label Apr 4, 2024
@paulb-elastic
Copy link
Contributor

Removing from the Synthetics on serverless project board, as being tracked as part of Infra&Services work

@paulb-elastic
Copy link
Contributor

Note that the Management UX team have been trying out having a unified set of API tests that are suitable for both stateful and serverless - see #183113.

This would be a more efficient implementation, rather than having duplicated API tests for each.

@paulb-elastic
Copy link
Contributor

We should be hearing by the end of next week, the mechanism to allow stateful API tests to be run in a serverless configuration

@smith smith added the Team:obs-ux-management Observability Management User Experience Team label Jul 10, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@smith smith added Synthetics and removed Team:Observability Team label for Observability Team (for things that are handled across all of observability) Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team labels Jul 10, 2024
@maryam-saeidi
Copy link
Member

@justinkambic @dominiqueclarke Will this ticket be covered in #196229?

@paulb-elastic
Copy link
Contributor

@dominiqueclarke confirmed that these will be done as part of #196229, so closing this one

@paulb-elastic paulb-elastic closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Synthetics Team:obs-ux-management Observability Management User Experience Team technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

No branches or pull requests

6 participants