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

Bug 1906896: show empty message for no alerts #7523

Merged
merged 1 commit into from Dec 24, 2020

Conversation

debsmita1
Copy link
Contributor

@debsmita1 debsmita1 commented Dec 11, 2020

Fixes:
https://issues.redhat.com/browse/ODC-5116

Analysis / Root cause:

Solution Description:

  • added a loader
  • it shows No Alerts found if there are no alerts

Unit test coverage report:
Added new test

Screen shots / Gifs for design review:
Screenshot from 2020-12-11 15-28-07
alerts

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

Copy link
Contributor

@sahil143 sahil143 left a comment

Choose a reason for hiding this comment

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

@debsmita1 When visiting the Alerts tab page starts to hang and becomes unresponsive. according to the warning in the console, useEffect hook is being called repeatedly.
Screenshot 2020-12-11 at 7 21 33 PM

@sahil143
Copy link
Contributor

@debsmita1 Unit tests are failing

return <LoadingBox />;
}
if (thanosAlertsAndRules?.alerts?.length === 0) {
return <EmptyBox label="Alerts" />;
Copy link
Contributor

Choose a reason for hiding this comment

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

localize the string.

@debsmita1 debsmita1 changed the title show empty message for no alerts Bug 1906896: show empty message for no alerts Dec 11, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. label Dec 11, 2020
@openshift-ci-robot
Copy link
Contributor

@debsmita1: This pull request references Bugzilla bug 1906896, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1906896: show empty message for no alerts

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Dec 11, 2020
@debsmita1
Copy link
Contributor Author

@debsmita1 When visiting the Alerts tab page starts to hang and becomes unresponsive. according to the warning in the console, useEffect hook is being called repeatedly.
Screenshot 2020-12-11 at 7 21 33 PM

@sahil143 This issue is being fixed in PR #7480

@debsmita1 debsmita1 force-pushed the alert-empty-state branch 2 times, most recently from db7490d to 0920284 Compare December 14, 2020 11:26
@debsmita1
Copy link
Contributor Author

@debsmita1 Unit tests are failing

fixed

@openshift-ci-robot
Copy link
Contributor

@debsmita1: This pull request references Bugzilla bug 1906896, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1906896: show empty message for no alerts

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@debsmita1
Copy link
Contributor Author

/test frontend

@debsmita1
Copy link
Contributor Author

/retest

Comment on lines 97 to 109
it('should render monitoring alerts', () => {
const wrapper = shallow(<MonitoringAlerts {...monitoringAlertsProps} />);
expect(wrapper.find(FilterToolbar).exists()).toBe(true);
expect(wrapper.find(Table).exists()).toBe(true);
expect(wrapper.find(TableHeader).exists()).toBe(true);
expect(wrapper.find(TableBody).exists()).toBe(true);
});
spyPrometheusRulesPoll.mockReturnValueOnce([{}, null, false]);
it('should show empty state message', () => {
const wrapper = shallow(<MonitoringAlerts {...monitoringAlertsProps} />);
expect(wrapper.find(EmptyBox).exists()).toBe(true);
});
Copy link
Member

Choose a reason for hiding this comment

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

@debsmita1 Really great to see more tests coming. In jest all testcases and code which is required to run a test case should be part of a it or beforeEach, afterEach, etc. function. Only test setup calls which are similar for all tests could be done before all tests.

In your case you modify the spyPrometheusRulesPoll mock between two test functions. This works only fine when you run your test from top to bottom 'once'. The first mock call saved one result, the second one the second (empty) version.

The it calls just register "test" calls (your callback function) and it will be run later. When you add console.log statements you can see that the tests are runned in this order:

console.log('1')
it('test 1' => {
  console.log('3')
})
console.log('2')
it('test 2' => {
  console.log('4')
})

And this is an issue if you don't run all tests at the same time or in a different order. You can test this with this command:

yarn test packages/dev-console/src/components/monitoring/alerts/__tests__/MonitoringAlerts.spec.tsx -t empty

This runs both mock "Once" calls and then runs the second it callback. But the mock returns the first value here.

So the general idea should be that each test works completely independent. You can reach this by just moving the setup of spyPrometheusRulesPoll also into the it function.

@jerolimov
Copy link
Member

/retest

Copy link
Member

@jerolimov jerolimov left a comment

Choose a reason for hiding this comment

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

Empty message was shown and I really like the new tests here, but found a small nit in the tests, also if they are green.
After this small change I would like to add a lgtm here. :)

@debsmita1 debsmita1 force-pushed the alert-empty-state branch 2 times, most recently from ef7344e to bfb963f Compare December 16, 2020 18:49
@openshift-merge-robot
Copy link
Contributor

@debsmita1: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/frontend bfb963f link /test frontend
ci/prow/e2e-gcp-console bfb963f link /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

return <LoadingBox />;
}
if (_.isEmpty(response?.data)) {
return <EmptyBox label={t('devconsle~Alerts')} />;
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
return <EmptyBox label={t('devconsle~Alerts')} />;
return <EmptyBox label={t('devconsole~Alerts')} />;

if (loading && !loadError) {
return <LoadingBox />;
}
if (_.isEmpty(response?.data)) {
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
if (_.isEmpty(response?.data)) {
if (_.isEmpty(response?.data?.groups)) {

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

4 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@debsmita1
Copy link
Contributor Author

/test kubevirt-plugin

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

16 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 24, 2020

@debsmita1: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/kubevirt-plugin 6f926d3 link /test kubevirt-plugin

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 94bcdd6 into openshift:master Dec 24, 2020
@openshift-ci-robot
Copy link
Contributor

@debsmita1: All pull requests linked via external trackers have merged:

Bugzilla bug 1906896 has been moved to the MODIFIED state.

In response to this:

Bug 1906896: show empty message for no alerts

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.7 milestone Jan 7, 2021
@debsmita1
Copy link
Contributor Author

/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants