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

[Data Usage] setup integration tests #197112

Merged

Conversation

neptunian
Copy link
Contributor

@neptunian neptunian commented Oct 21, 2024

Summary

Adds serverless api integration tests and basic functional smoke test for data usage plugin

Both are skipped in mki until xpack.dataUsage.enabled is enabled by default in serverless

GET /internal/api/data_usage/data_streams

POST /internal/api/data_usage/metrics

  • skipped in MKI because we'll need to make sure real credentials are being used via the xpack.dataUsage.autoops*
  • we start a mock server at localhost:9000 and set that the config (xpack.dataUsage.autoops.api.url=http://localhost:9000') along with fake credentials for the other xpack.dataUsage.autoops* values. If we're not in MKI these values will be used and the mock server will respond to the request at http://localhost:9000. If we are in MKI, the real values and credentials should be set, otherwise it will fail as these kibana config values in the tests are not passed into the MKI environment.

@@ -134,8 +135,10 @@ export class AutoOpsAPIService {
}
);

const validatedResponse = UsageMetricsAutoOpsResponseSchema.body().validate(response.data);
Copy link
Contributor Author

@neptunian neptunian Oct 21, 2024

Choose a reason for hiding this comment

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

I think we should validate the autoops response at runtime. The error will be caught further up.

@elastic elastic deleted a comment from elasticmachine Oct 22, 2024
@@ -21,5 +22,22 @@ export default createTestConfig({
kbnServerArgs: [
// useful for testing (also enabled in MKI QA)
'--coreApp.allowDynamicConfigOverrides=true',
'--xpack.dataUsage.enabled=true',
Copy link
Contributor Author

@neptunian neptunian Oct 23, 2024

Choose a reason for hiding this comment

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

we need to enable this to run the tests in MKI. once we enable this in serverless only, we can remove this.

@neptunian neptunian force-pushed the data-usage-serverless-api-integration-tests branch 2 times, most recently from 55c96a7 to c786ac9 Compare October 23, 2024 19:13
@neptunian neptunian added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes labels Oct 23, 2024
>;
>['metrics'][MetricTypes][number];

export type UsageMetricsAutoOpsResponseSchemaBody = Omit<
Copy link
Contributor Author

@neptunian neptunian Oct 23, 2024

Choose a reason for hiding this comment

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

I changed this type because I was getting a type error when only sending a subset of metrics (using the type in mock server response), so this allows the subset instead of all. @ashokaditya Hope thats ok.

@neptunian neptunian marked this pull request as ready for review October 23, 2024 19:21
@neptunian neptunian requested review from a team as code owners October 23, 2024 19:21
@neptunian neptunian requested review from a team as code owners October 23, 2024 20:01
@neptunian neptunian force-pushed the data-usage-serverless-api-integration-tests branch from 41e2585 to dff67dc Compare October 23, 2024 20:05
@neptunian neptunian removed request for a team October 23, 2024 20:06
@@ -25,5 +26,11 @@ export default createTestConfig({
'--coreApp.allowDynamicConfigOverrides=true',
`--xpack.securitySolutionServerless.cloudSecurityUsageReportingTaskInterval=5s`,
`--xpack.securitySolutionServerless.usageApi.url=http://localhost:8081`,
'--xpack.dataUsage.enabled=true',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'--xpack.dataUsage.enabled=true',
'--xpack.dataUsage.autoops.enabled=true',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added --xpack.dataUsage.autoops.enabled=true, though left --xpack.dataUsage.enabled=true in place so as not to enable the plugin.

@@ -21,5 +22,11 @@ export default createTestConfig({
kbnServerArgs: [
// useful for testing (also enabled in MKI QA)
'--coreApp.allowDynamicConfigOverrides=true',
'--xpack.dataUsage.enabled=true',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'--xpack.dataUsage.enabled=true',
'--xpack.dataUsage.autoops.enabled=true',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added --xpack.dataUsage.autoops.enabled=true, though left --xpack.dataUsage.enabled=true in place so as not to enable the plugin.

import { DataStreamsResponseBodySchemaBody } from '@kbn/data-usage-plugin/common/rest_types';
import { FtrProviderContext } from '../../../../ftr_provider_context';

const API_PATH = '/internal/api/data_usage/data_streams';
Copy link
Member

Choose a reason for hiding this comment

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

You can import and use DATA_USAGE_METRICS_API_ROUTE instead.

import { DATA_USAGE_METRICS_API_ROUTE } from '@kbn/data-usage-plugin/common';

@neptunian neptunian requested a review from a team as a code owner November 4, 2024 19:29
@neptunian neptunian requested a review from a team as a code owner November 5, 2024 20:09
Copy link
Contributor

@awahab07 awahab07 left a comment

Choose a reason for hiding this comment

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

obs-ux-logs changes LGTM.

Thought need to look at why it triggered the codeowners review for obs-ux-logs-team.

Copy link
Contributor

@YulNaumenko YulNaumenko left a comment

Choose a reason for hiding this comment

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

LGTM!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

@neptunian neptunian merged commit 4f9ab47 into elastic:main Nov 6, 2024
22 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11709558601

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 197112

Questions ?

Please refer to the Backport tool documentation

neptunian added a commit to neptunian/kibana that referenced this pull request Nov 6, 2024
Adds serverless api integration tests and basic functional smoke test
for data usage plugin

Both are skipped in mki until `xpack.dataUsage.enabled` is enabled by
default in serverless

- skipped in MKI because we'll need to make sure real credentials are
being used via the `xpack.dataUsage.autoops*`
- we start a mock server at localhost:9000 and set that the config
(`xpack.dataUsage.autoops.api.url=http://localhost:9000'`) along with
fake credentials for the other `xpack.dataUsage.autoops*` values. If
we're not in MKI these values will be used and the mock server will
respond to the request at `http://localhost:9000`. If we are in MKI, the
real values and credentials should be set, otherwise it will fail as
these kibana config values in the tests are not passed into the MKI
environment.

---------

Co-authored-by: kibanamachine <[email protected]>
mgadewoll pushed a commit to mgadewoll/kibana that referenced this pull request Nov 7, 2024
## Summary

Adds serverless api integration tests and basic functional smoke test
for data usage plugin

Both are skipped in mki until `xpack.dataUsage.enabled` is enabled by
default in serverless

### `GET /internal/api/data_usage/data_streams`

### `POST /internal/api/data_usage/metrics`
- skipped in MKI because we'll need to make sure real credentials are
being used via the `xpack.dataUsage.autoops*`
- we start a mock server at localhost:9000 and set that the config
(`xpack.dataUsage.autoops.api.url=http://localhost:9000'`) along with
fake credentials for the other `xpack.dataUsage.autoops*` values. If
we're not in MKI these values will be used and the mock server will
respond to the request at `http://localhost:9000`. If we are in MKI, the
real values and credentials should be set, otherwise it will fail as
these kibana config values in the tests are not passed into the MKI
environment.

---------

Co-authored-by: kibanamachine <[email protected]>
@ashokaditya ashokaditya added backport:version Backport to applied version labels v8.17.0 and removed backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Nov 7, 2024
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11722902893

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 197112

Questions ?

Please refer to the Backport tool documentation

ashokaditya pushed a commit to ashokaditya/kibana that referenced this pull request Nov 7, 2024
## Summary

Adds serverless api integration tests and basic functional smoke test
for data usage plugin

Both are skipped in mki until `xpack.dataUsage.enabled` is enabled by
default in serverless

### `GET /internal/api/data_usage/data_streams`

### `POST /internal/api/data_usage/metrics`
- skipped in MKI because we'll need to make sure real credentials are
being used via the `xpack.dataUsage.autoops*`
- we start a mock server at localhost:9000 and set that the config
(`xpack.dataUsage.autoops.api.url=http://localhost:9000'`) along with
fake credentials for the other `xpack.dataUsage.autoops*` values. If
we're not in MKI these values will be used and the mock server will
respond to the request at `http://localhost:9000`. If we are in MKI, the
real values and credentials should be set, otherwise it will fail as
these kibana config values in the tests are not passed into the MKI
environment.

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 4f9ab47)

# Conflicts:
#	x-pack/test_serverless/api_integration/test_suites/security/config.ts
#	x-pack/test_serverless/functional/test_suites/search/config.ts
#	x-pack/test_serverless/tsconfig.json
@ashokaditya
Copy link
Member

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

ashokaditya added a commit that referenced this pull request Nov 7, 2024
> [!Warning]
> The following files were updated as a result of merge conflicts that
should be reviewed
> -
`/x-pack/test_serverless/api_integration/test_suites/security/config.ts`
> - `/x-pack/test_serverless/functional/test_suites/search/config.ts`
> - `/x-pack/test_serverless/tsconfig.json`

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Data Usage] setup integration tests
(#197112)](#197112)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sandra
G","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-06T18:20:49Z","message":"[Data
Usage] setup integration tests (#197112)\n\n## Summary\r\n\r\nAdds
serverless api integration tests and basic functional smoke test\r\nfor
data usage plugin\r\n\r\nBoth are skipped in mki until
`xpack.dataUsage.enabled` is enabled by\r\ndefault in
serverless\r\n\r\n### `GET
/internal/api/data_usage/data_streams`\r\n\r\n### `POST
/internal/api/data_usage/metrics`\r\n- skipped in MKI because we'll need
to make sure real credentials are\r\nbeing used via the
`xpack.dataUsage.autoops*`\r\n- we start a mock server at localhost:9000
and set that the
config\r\n(`xpack.dataUsage.autoops.api.url=http://localhost:9000'`)
along with\r\nfake credentials for the other `xpack.dataUsage.autoops*`
values. If\r\nwe're not in MKI these values will be used and the mock
server will\r\nrespond to the request at `http://localhost:9000`. If we
are in MKI, the\r\nreal values and credentials should be set, otherwise
it will fail as\r\nthese kibana config values in the tests are not
passed into the
MKI\r\nenvironment.\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"4f9ab47291362185a113755eefe2583df5f9827b","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:version","v8.17.0"],"number":197112,"url":"https://github.com/elastic/kibana/pull/197112","mergeCommit":{"message":"[Data
Usage] setup integration tests (#197112)\n\n## Summary\r\n\r\nAdds
serverless api integration tests and basic functional smoke test\r\nfor
data usage plugin\r\n\r\nBoth are skipped in mki until
`xpack.dataUsage.enabled` is enabled by\r\ndefault in
serverless\r\n\r\n### `GET
/internal/api/data_usage/data_streams`\r\n\r\n### `POST
/internal/api/data_usage/metrics`\r\n- skipped in MKI because we'll need
to make sure real credentials are\r\nbeing used via the
`xpack.dataUsage.autoops*`\r\n- we start a mock server at localhost:9000
and set that the
config\r\n(`xpack.dataUsage.autoops.api.url=http://localhost:9000'`)
along with\r\nfake credentials for the other `xpack.dataUsage.autoops*`
values. If\r\nwe're not in MKI these values will be used and the mock
server will\r\nrespond to the request at `http://localhost:9000`. If we
are in MKI, the\r\nreal values and credentials should be set, otherwise
it will fail as\r\nthese kibana config values in the tests are not
passed into the
MKI\r\nenvironment.\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"4f9ab47291362185a113755eefe2583df5f9827b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197112","number":197112,"mergeCommit":{"message":"[Data
Usage] setup integration tests (#197112)\n\n## Summary\r\n\r\nAdds
serverless api integration tests and basic functional smoke test\r\nfor
data usage plugin\r\n\r\nBoth are skipped in mki until
`xpack.dataUsage.enabled` is enabled by\r\ndefault in
serverless\r\n\r\n### `GET
/internal/api/data_usage/data_streams`\r\n\r\n### `POST
/internal/api/data_usage/metrics`\r\n- skipped in MKI because we'll need
to make sure real credentials are\r\nbeing used via the
`xpack.dataUsage.autoops*`\r\n- we start a mock server at localhost:9000
and set that the
config\r\n(`xpack.dataUsage.autoops.api.url=http://localhost:9000'`)
along with\r\nfake credentials for the other `xpack.dataUsage.autoops*`
values. If\r\nwe're not in MKI these values will be used and the mock
server will\r\nrespond to the request at `http://localhost:9000`. If we
are in MKI, the\r\nreal values and credentials should be set, otherwise
it will fail as\r\nthese kibana config values in the tests are not
passed into the
MKI\r\nenvironment.\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"4f9ab47291362185a113755eefe2583df5f9827b"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Signed-off-by: Ash <[email protected]>
Co-authored-by: Sandra G <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants