-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Data Usage] setup integration tests #197112
Conversation
@@ -134,8 +135,10 @@ export class AutoOpsAPIService { | |||
} | |||
); | |||
|
|||
const validatedResponse = UsageMetricsAutoOpsResponseSchema.body().validate(response.data); |
There was a problem hiding this comment.
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.
@@ -21,5 +22,22 @@ export default createTestConfig({ | |||
kbnServerArgs: [ | |||
// useful for testing (also enabled in MKI QA) | |||
'--coreApp.allowDynamicConfigOverrides=true', | |||
'--xpack.dataUsage.enabled=true', |
There was a problem hiding this comment.
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.
55c96a7
to
c786ac9
Compare
>; | ||
>['metrics'][MetricTypes][number]; | ||
|
||
export type UsageMetricsAutoOpsResponseSchemaBody = Omit< |
There was a problem hiding this comment.
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.
41e2585
to
dff67dc
Compare
@@ -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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'--xpack.dataUsage.enabled=true', | |
'--xpack.dataUsage.autoops.enabled=true', |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'--xpack.dataUsage.enabled=true', | |
'--xpack.dataUsage.autoops.enabled=true', |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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';
x-pack/test_serverless/api_integration/test_suites/common/data_usage/tests/metrics.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
💚 Build Succeeded
Metrics [docs]
History
|
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
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]>
## 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]>
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
## 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
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
> [!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]>
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 serverlessGET /internal/api/data_usage/data_streams
POST /internal/api/data_usage/metrics
xpack.dataUsage.autoops*
xpack.dataUsage.autoops.api.url=http://localhost:9000'
) along with fake credentials for the otherxpack.dataUsage.autoops*
values. If we're not in MKI these values will be used and the mock server will respond to the request athttp://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.