Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Jan 20, 2021
1 parent fc4f12f commit 80eff8e
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 19 deletions.
6 changes: 0 additions & 6 deletions x-pack/plugins/monitoring/server/alerts/base_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ export class BaseAlert {
}

public isEnabled(licenseService: MonitoringLicenseService) {
// if (this.alertOptions.legacy) {
// const watcherFeature = licenseService.getWatcherFeature();
// if (!watcherFeature.isAvailable || !watcherFeature.isEnabled) {
// return false;
// }
// }
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ describe('ClusterHealthAlert', () => {
});
});

it('should not fire actions if there is no legacy alert', async () => {
it('should not fire actions if the cluster health is green', async () => {
(fetchClusterHealth as jest.Mock).mockImplementation(() => {
return [];
return [
{
health: AlertClusterHealthType.Green,
clusterUuid,
ccs,
},
];
});
const alert = new ClusterHealthAlert();
const type = alert.getAlertType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@ describe('ElasticsearchVersionMismatchAlert', () => {
});
});

it('should not fire actions if there is no legacy alert', async () => {
it('should not fire actions if there is no mismatch', async () => {
(fetchElasticsearchVersions as jest.Mock).mockImplementation(() => {
return [];
return [
{
versions: ['8.0.0'],
clusterUuid,
ccs,
},
];
});
const alert = new ElasticsearchVersionMismatchAlert();
const type = alert.getAlertType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@ describe('KibanaVersionMismatchAlert', () => {
});
});

it('should not fire actions if there is no legacy alert', async () => {
it('should not fire actions if there is no mismatch', async () => {
(fetchKibanaVersions as jest.Mock).mockImplementation(() => {
return [];
return [
{
versions: ['8.0.0'],
clusterUuid,
ccs,
},
];
});
const alert = new KibanaVersionMismatchAlert();
const type = alert.getAlertType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jest.mock('moment', () => {
};
};
moment.duration = () => ({ humanize: () => 'HUMANIZED_DURATION' });
moment.utc = () => '';
moment.utc = () => ({
add: () => ({
isAfter: () => false,
}),
});
return moment;
});

Expand Down Expand Up @@ -186,9 +190,16 @@ describe('LicenseExpirationAlert', () => {
});
});

it('should not fire actions if there is no legacy alert', async () => {
it('should not fire actions if the license is not expired', async () => {
(fetchLicenses as jest.Mock).mockImplementation(() => {
return [];
return [
{
status: 'active',
type: 'gold',
expiryDateMS: 1,
clusterUuid,
},
];
});
const alert = new LicenseExpirationAlert();
const type = alert.getAlertType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ describe('LogstashVersionMismatchAlert', () => {
});
});

it('should not fire actions if there is no legacy alert', async () => {
it('should not fire actions if there is no mismatch', async () => {
(fetchLogstashVersions as jest.Mock).mockImplementation(() => {
return [];
return [
{
versions: ['8.0.0'],
clusterUuid,
ccs,
},
];
});
const alert = new LogstashVersionMismatchAlert();
const type = alert.getAlertType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,28 @@ describe('NodesChangedAlert', () => {
});
});

it('should not fire actions if there is no legacy alert', async () => {
it('should not fire actions if no nodes have changed', async () => {
(fetchNodesFromClusterStats as jest.Mock).mockImplementation(() => {
return [];
return [
{
recentNodes: [
{
nodeUuid,
nodeEphemeralId,
nodeName,
},
],
priorNodes: [
{
nodeUuid,
nodeEphemeralId,
nodeName,
},
],
clusterUuid,
ccs,
},
];
});
const alert = new NodesChangedAlert();
const type = alert.getAlertType();
Expand Down

0 comments on commit 80eff8e

Please sign in to comment.