Add tests for filtering node health checks
This commit is contained in:
parent
c27cc17991
commit
e36848111a
|
@ -1,11 +1,12 @@
|
|||
export default (collection, text) =>
|
||||
(scope = '.consul-health-check-list') => {
|
||||
return {
|
||||
scope,
|
||||
item: collection('li', {
|
||||
name: text('header h3'),
|
||||
type: text('[data-health-check-type]'),
|
||||
exposed: text('[data-test-exposed]'),
|
||||
}),
|
||||
};
|
||||
return collection({
|
||||
scope,
|
||||
itemScope: 'li',
|
||||
item: {
|
||||
name: text('header h2'),
|
||||
type: text('[data-health-check-type]'),
|
||||
exposed: text('[data-test-exposed]'),
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -9,8 +9,6 @@ export default class HealthChecksController extends Controller {
|
|||
|
||||
@action
|
||||
syntheticNodeHealthCheckFilter(item, healthcheck, index, list) {
|
||||
console.log('List to be filtered: ', list);
|
||||
console.log(healthcheck.Kind);
|
||||
return !(item.Node.Meta?.['synthetic-node'] && healthcheck?.Kind === 'node');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,3 +64,68 @@ Feature: dc / services / instances / health-checks
|
|||
Then the url should be /dc1/services/service-0/instances/another-node/service-1-with-id/health-checks
|
||||
And I see healthChecksIsSelected on the tabs
|
||||
And I don't see criticalSerfNotice on the tabs.healthChecksTab
|
||||
Scenario: Node health check should be hidden on agentless service instances
|
||||
Given 1 instance model from yaml
|
||||
---
|
||||
- Service:
|
||||
ID: service-0-with-id
|
||||
Node:
|
||||
Node: another-node
|
||||
Meta:
|
||||
synthetic-node: true
|
||||
Checks:
|
||||
- Type: ''
|
||||
Name: Node Health Check
|
||||
CheckID: serfHealth
|
||||
ServiceID: ''
|
||||
Status: passing
|
||||
Output: Agent alive and reachable
|
||||
- Type: ''
|
||||
Name: Serf Health Status
|
||||
CheckID: serfHealth
|
||||
Status: critical
|
||||
Output: ouch
|
||||
---
|
||||
When I visit the instance page for yaml
|
||||
---
|
||||
dc: dc1
|
||||
service: service-0
|
||||
node: another-node
|
||||
id: service-0-with-id
|
||||
---
|
||||
Then the url should be /dc1/services/service-0/instances/another-node/service-0-with-id/health-checks
|
||||
And I see healthChecksIsSelected on the tabs
|
||||
And I see 1 healthCheck model on the tabs.healthChecksTab component
|
||||
And I see 1 healthCheck model with the name "Serf Health Status"
|
||||
Scenario: Node health checks should be visible on non-agentless service instances
|
||||
Given 1 instance model from yaml
|
||||
---
|
||||
- Service:
|
||||
ID: service-0-with-id
|
||||
Node:
|
||||
Node: another-node
|
||||
Checks:
|
||||
- Type: ''
|
||||
Name: Node Health Check
|
||||
CheckID: serfHealth
|
||||
ServiceID: ''
|
||||
Status: passing
|
||||
Output: Agent alive and reachable
|
||||
- Type: ''
|
||||
Name: Serf Health Status
|
||||
CheckID: serfHealth
|
||||
Status: critical
|
||||
Output: ouch
|
||||
---
|
||||
When I visit the instance page for yaml
|
||||
---
|
||||
dc: dc1
|
||||
service: service-0
|
||||
node: another-node
|
||||
id: service-0-with-id
|
||||
---
|
||||
Then the url should be /dc1/services/service-0/instances/another-node/service-0-with-id/health-checks
|
||||
And I see healthChecksIsSelected on the tabs
|
||||
And I see 2 healthCheck models on the tabs.healthChecksTab component
|
||||
And I see 1 healthCheck model with the name "Serf Health Status"
|
||||
And I see 1 healthCheck model with the name "Node Health Check"
|
||||
|
|
|
@ -75,7 +75,7 @@ Feature: dc / services / instances / show: Show Service Instance
|
|||
|
||||
And I don't see upstreams on the tabs
|
||||
And I see healthChecksIsSelected on the tabs
|
||||
And I see 6 of the checks object
|
||||
And I see 6 healthCheck models
|
||||
|
||||
When I click tags&Meta on the tabs
|
||||
And I see tags&MetaIsSelected on the tabs
|
||||
|
|
|
@ -1,8 +1,25 @@
|
|||
export default function (scenario, assert, find, currentPage, pauseUntil, pluralize) {
|
||||
function getModelItems(model, component) {
|
||||
let obj;
|
||||
if (component) {
|
||||
obj = find(component);
|
||||
} else {
|
||||
obj = currentPage();
|
||||
}
|
||||
|
||||
let found = obj[pluralize(model)];
|
||||
|
||||
if (typeof found === 'function') {
|
||||
found = found();
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
scenario
|
||||
.then('pause until I see $number $model model[s]?', function (num, model) {
|
||||
return pauseUntil(function (resolve, reject, retry) {
|
||||
const len = currentPage()[pluralize(model)].filter(function (item) {
|
||||
const len = getModelItems(model).filter(function (item) {
|
||||
return item.isVisible;
|
||||
}).length;
|
||||
if (len === num) {
|
||||
|
@ -15,8 +32,7 @@ export default function (scenario, assert, find, currentPage, pauseUntil, plural
|
|||
'pause until I see $number $model model[s]? on the $component component',
|
||||
function (num, model, component) {
|
||||
return pauseUntil(function (resolve, reject, retry) {
|
||||
const obj = find(component);
|
||||
const len = obj[pluralize(model)].filter(function (item) {
|
||||
const len = getModelItems(model, component).filter(function (item) {
|
||||
return item.isVisible;
|
||||
}).length;
|
||||
if (len === num) {
|
||||
|
@ -27,7 +43,7 @@ export default function (scenario, assert, find, currentPage, pauseUntil, plural
|
|||
}
|
||||
)
|
||||
.then(['I see $num $model model[s]?'], function (num, model) {
|
||||
const len = currentPage()[pluralize(model)].filter(function (item) {
|
||||
const len = getModelItems(model).filter(function (item) {
|
||||
return item.isVisible;
|
||||
}).length;
|
||||
assert.equal(len, num, `Expected ${num} ${pluralize(model)}, saw ${len}`);
|
||||
|
@ -35,15 +51,13 @@ export default function (scenario, assert, find, currentPage, pauseUntil, plural
|
|||
.then(
|
||||
['I see $num $model model[s]? on the $component component'],
|
||||
function (num, model, component) {
|
||||
const obj = find(component);
|
||||
const len = obj[pluralize(model)].filter(function (item) {
|
||||
const len = getModelItems(model, component).filter(function (item) {
|
||||
return item.isVisible;
|
||||
}).length;
|
||||
|
||||
assert.equal(len, num, `Expected ${num} ${pluralize(model)}, saw ${len}`);
|
||||
}
|
||||
)
|
||||
// TODO: I${ dont } see
|
||||
.then(
|
||||
[`I see $num $model model[s]? with the $property "$value"`],
|
||||
function (
|
||||
|
@ -53,7 +67,7 @@ export default function (scenario, assert, find, currentPage, pauseUntil, plural
|
|||
property,
|
||||
value
|
||||
) {
|
||||
const len = currentPage()[pluralize(model)].filter(function (item) {
|
||||
const len = getModelItems(model).filter(function (item) {
|
||||
if (item.isVisible) {
|
||||
let prop = item[property];
|
||||
// cope with pageObjects that can have a multiple: true
|
||||
|
|
Loading…
Reference in New Issue