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

[ObsUX] Fix timestamp for anomaly alert test #169255

Merged

Conversation

MiriamAparicio
Copy link
Contributor

@MiriamAparicio MiriamAparicio commented Oct 18, 2023

Closes #160769

What was done

The anomaly alert test was failing with timeout because was not generating alerts, the data and spikes were added to far away in time, so when the job is created doesn't take into account data that far in the past
We fixed the timerange of the data generated and the spikes.

BEFORE:

image

AFTER:

image

Flaky test runner:

@MiriamAparicio MiriamAparicio requested a review from a team as a code owner October 18, 2023 14:25
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Oct 18, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@MiriamAparicio MiriamAparicio added the release_note:skip Skip the PR/issue when compiling release notes label Oct 18, 2023
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

Comment on lines 30 to 31
const start = Date.now() - 1000 * 60 * 60 * 24 * 2; // day ago
const end = Date.now();
Copy link
Member

@sorenlouv sorenlouv Oct 18, 2023

Choose a reason for hiding this comment

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

nit: moment with subtract() and add() is easier to read.

start: moment(end).subtract(7, 'minutes').toISOString(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed here bf3d743

const spikeStart = new Date('2021-01-07T23:15:00.000Z').getTime();
const spikeEnd = new Date('2021-01-08T00:15:00.000Z').getTime();
const spikeStart = new Date(Date.now() - 1000 * 60 * 15).getTime(); // 15 minutes ago
const spikeEnd = new Date(Date.now()).getTime();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const spikeEnd = new Date(Date.now()).getTime();
const spikeEnd = Date.now();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated here bf3d743

@MiriamAparicio MiriamAparicio force-pushed the 160769-anomaly-alert-skipped-test branch from 29c268f to 9c1b116 Compare October 18, 2023 15:46
@MiriamAparicio MiriamAparicio force-pushed the 160769-anomaly-alert-skipped-test branch from 9c1b116 to bf3d743 Compare October 18, 2023 15:48
Comment on lines 31 to 32
const start = moment().subtract(1, 'days').toISOString();
const end = moment().toISOString();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this also be timestamps? Then you don't have to convert them later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point

Comment on lines 37 to 38
const NORMAL_DURATION = 100;
const NORMAL_RATE = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Inline these. Having them extracted makes the code harder to read.

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

just some nits

@MiriamAparicio MiriamAparicio force-pushed the 160769-anomaly-alert-skipped-test branch from 773d7f5 to 99f1599 Compare October 19, 2023 07:04

let ruleId: string;

before(async () => {
await cleanup();
Copy link
Contributor

@kpatticha kpatticha Oct 19, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to clean before and after the test

Copy link
Member

Choose a reason for hiding this comment

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

During development it's much easier if cleanup happens before running the test. On CI it is better to have cleanup after to avoid contamination between tests. I don't have strong opinions whether we need to cleanup both before and after though. Perhaps you can comment out the cleanup in the before step. It's still easy to enable for debug purposes.

@MiriamAparicio MiriamAparicio force-pushed the 160769-anomaly-alert-skipped-test branch from 94a8adc to 05805c9 Compare October 19, 2023 15:25
@kibanamachine kibanamachine requested a review from a team as a code owner October 19, 2023 15:32
getAddRuleFlyout: jest
.fn()
.mockReturnValue(<div data-test-subj="add-rule-flyout">Add Rule Flyout</div>),
getAddRuleFlyout: jest.fn().mockReturnValue(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elastic/actionable-observability
I'm not sure how this end up in my PR, and is actually creating a conflict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed merging with main

@MiriamAparicio MiriamAparicio force-pushed the 160769-anomaly-alert-skipped-test branch from 6137417 to 9bb3eff Compare October 20, 2023 09:02
@@ -174,7 +174,6 @@ export function registerAnomalyRuleType({
range: {
timestamp: {
gte: dateStart,
format: 'epoch_millis',
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure about this change? Don't we pass an epoch timestamp anymore?

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 checked the other endpoints, and we don't pass it anywhere else, also dateStart is typed as string, I had a conversation about it on slack

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

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

@MiriamAparicio MiriamAparicio merged commit 17c78db into elastic:main Oct 23, 2023
2 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 23, 2023
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 release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] API Test hangs and Timeout, hence skipped
7 participants