-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
base: main
Are you sure you want to change the base?
[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.
/ci |
1 similar comment
/ci |
@@ -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';
.set('elastic-api-version', '1') | ||
.send(requestBody); | ||
expect(res.statusCode).to.be(200); | ||
// TODO: decide on how to generate 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 have a function that takes in a date range and spits out some metrics for that range. Maybe a data point every hour?
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'm thinking to use synthtrace
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.
ResponseOps changes (in x-pack/test_serverless/api_integration/test_suites/observability/config.ts
) LGTM.
Side note: no idea why Response Ops is marked for these files, which is why we got pinged:
Lines 1488 to 1489 in c41178d
/x-pack/test_serverless/api_integration/test_suites/observability/config.ts @elastic/response-ops | |
/x-pack/test_serverless/api_integration/test_suites/observability/index.ts @elastic/response-ops |
Perhaps fix that in this PR as well?
💚 Build Succeeded
Metrics [docs]
History
|
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.
x-pack/test_serverless/api_integration/test_suites/observability/common_configs/config.group1.ts
and x-pack/test_serverless/tsconfig.json
changes LGTM
Summary
Adds serverless api integration tests for data usage plugin
Both are skipped in mki until
xpack.dataUsage.enabled
is enabled by default in serverlessPOST /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.