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

[SavedObjects] Create serverless utils for jest integration tests #164157

Merged
merged 25 commits into from
Aug 24, 2023

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Aug 17, 2023

Summary

Introduce basic utils for instantiating serverless servers ;). Also adds a simple smoke test (that is currently skipped) demonstrating usage.

How to test

Run docker locally, check this branch out locally, unskip the smoke test and run:

yarn test:jest_integration ./src/core/server/integration_tests/saved_objects/serverless/migrations

Note: the test cannot be unskipped as we are blocking on #162673 but we would like to prepare our tests so long --- they can be locally executed.

Follow up

  • Create Jest integration tests using these helpers for all migration actions (see packages/core/saved-objects/core-saved-objects-migration-server-internal/src/zdt/actions and packages/core/saved-objects/core-saved-objects-migration-server-internal/src/actions).
  • Migrate our existing ZDT tests to run against serverless Elasticsearch

Related

#162673

jloleysens and others added 21 commits August 17, 2023 12:25
* main: (150 commits)
  Fixes unnecessary autocompletes on HTTP methods (elastic#163233)
  [Defend Workflows] Convert filterQuery to kql  (elastic#161806)
  [Fleet] copy `inactivity_timeout` when duplicating agent policy (elastic#164544)
  Fix 7.17 forward compatibility with 8.2+ (elastic#164274)
  [ML] Fixes dark mode in flyouts and modals (elastic#164399)
  [Defend Workflows]Changes to policy settings are not persistent until a refresh (elastic#164403)
  [Security Solution][Endpoint] Fixes kibana crash when going back to policy details page (elastic#164329)
  Prepare the Security domain HTTP APIs for Serverless (elastic#162087)
  skip failing test suite (elastic#160986)
  [Security Solution] Fix flaky Event Filters test (elastic#164473)
  [EDR workflows] Osquery serverless tests (elastic#163795)
  [Fleet] Only show agent dashboard links if there is more than one non-server agent and if the dashboards exist (elastic#164469)
  [Chrome UI] Fix background color in serverless (elastic#164419)
  [DOCS] Saved objects - resolve import errors API (elastic#162825)
  Remove 'Create Rule' button from Rule Group page (elastic#164167)
  [Security Solution] expandable flyout - fix infinite loop in correlations (elastic#163450)
  [Remote Clusters] Update copy about port help text (elastic#164442)
  [api-docs] 2023-08-23 Daily api_docs build (elastic#164524)
  [data views] Disable scripted fields in serverless environment (elastic#163228)
  [Reporting] Fix - show diagnostic only when image reporting is enabled (elastic#164336)
  ...
@jloleysens jloleysens changed the title [SavedObjects] ZDT test harness [SavedObjects] Create serverless roots for jest integration tests Aug 23, 2023
startKibana: (abortSignal?: AbortSignal) => Promise<TestServerlessKibanaUtils>;
}

export function createTestServerlessInstances({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed easiest to just create a separate function rather than adding a flag to the existing createTestServers logic.

However, we mirror the existing API as closely as possible so that these helpers can be easily substituted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why didn't you name it createTestServerlessServers :trollface:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you said the quiet part out loud 🤫

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but in all seriousness: if you have a better idea for a name I'll gladly accept 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Na, naming is hard, it's fine. We can rename later if we really want so.

/**
* Until we merge https://github.com/elastic/kibana/pull/162673 this test should remain skipped.
*/
describe.skip('smoke', () => {
Copy link
Contributor Author

@jloleysens jloleysens Aug 23, 2023

Choose a reason for hiding this comment

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

I tried to get this working on CI, but it is currently timing out. It seems as though the instance might be too small to start 3 ES containers. We should also wait for QA to figure this out for FTRs.

@jloleysens jloleysens marked this pull request as ready for review August 23, 2023 15:20
@jloleysens jloleysens requested a review from a team as a code owner August 23, 2023 15:20
@pgayvallet pgayvallet added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:skip Skip the PR/issue when compiling release notes labels Aug 24, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +91 to +93
function createServerlessKibana(settings = {}, cliArgs: Partial<CliArgs> = {}) {
return createRoot(defaultsDeep(settings, defaults), { ...cliArgs, serverless: true });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is serverless: true here sufficient to load the serverless config file(s)?

Copy link
Contributor Author

@jloleysens jloleysens Aug 24, 2023

Choose a reason for hiding this comment

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

No, great point, this still needs to be figured out a bit.

I added some basic config that we'll need in serverless in the meantime:

{
  server: {
    restrictInternalApis: true,
    versioned: {
      versionResolution: 'newest',
      strictClientVersionCheck: false,
    },
  },
  migrations: {
    algorithm: 'zdt',
  },
  elasticsearch: {
    serviceAccountToken: 'BEEF',
  },
}

startKibana: (abortSignal?: AbortSignal) => Promise<TestServerlessKibanaUtils>;
}

export function createTestServerlessInstances({
Copy link
Contributor

Choose a reason for hiding this comment

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

Na, naming is hard, it's fine. We can rename later if we really want so.

@jloleysens jloleysens enabled auto-merge (squash) August 24, 2023 09:52
@jloleysens jloleysens changed the title [SavedObjects] Create serverless roots for jest integration tests [SavedObjects] Create serverless utils for jest integration tests Aug 24, 2023
Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

🥳

@jloleysens jloleysens self-assigned this Aug 24, 2023
@jloleysens jloleysens merged commit 178e201 into elastic:main Aug 24, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-test-helpers-kbn-server 49 54 +5

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/core-test-helpers-kbn-server 0 1 +1
Unknown metric groups

API count

id before after diff
@kbn/core-test-helpers-kbn-server 55 61 +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jloleysens

@kibanamachine kibanamachine added v8.11.0 backport:skip This commit does not require backporting labels Aug 24, 2023
@jloleysens jloleysens deleted the zdt-test-harness branch August 24, 2023 11:30
jloleysens added a commit that referenced this pull request Aug 24, 2023
* main: (3152 commits)
  [Security Solution][Detection Engine] fixes 410 error on index legacy template call (#164682)
  [SavedObjects] Create serverless roots for jest integration tests (#164157)
  Create upselling package and implement EntityAnalytics serverless upselling (#164136)
  [Fleet] Change 'Out-of-date' to 'Outdated policy' in agent list table (#164673)
  [IndexManagement] Use internal base path for API (#164665)
  [Profiling] removing ~ symbol (#164595)
  [Telemetry] Fetch snapshot: allow specifying the version via querystring (#164670)
  [Cases] Show warning when all cases table reaches 10k cases message (#164323)
  [ML] Removing token list from text expansion model testing (#164560)
  [Fleet] Add secrets package API integration test (#164583)
  [Fleet] Fix security solution tag id (#164582)
  [Security Solution] Modal says "duplicating 0 rules" when you duplicate an individual rule (#163908)
  [api-docs] 2023-08-24 Daily api_docs build (#164658)
  [APM] Cleanup alerting api tests (#164438)
  Upgrade EUI to 87.2.0 (#164385)
  [ML] Fix query bar autocompletion for ML and AIOps embeddables (#164485)
  [Fleet] Fix flaky unit test for the details page (#164641)
  [Security Solution] update codeowner for serverless security subdir (#164640)
  [Security Solution] Fixes Assistant Connector and Actions RBAC Flow (#164382)
  [Discover] Removing large string truncation from doc viewer (#164236)
  ...
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:Functional Testing release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants