-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix get health #1032
Fix get health #1032
Conversation
80c8a11
to
acdfe32
Compare
34d0405
to
660af78
Compare
5138f14
to
dd40854
Compare
dd40854
to
b57a126
Compare
3af0432
to
11c45a6
Compare
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.
LGTM @arbulu89 , just a bit of (opinionated) nitpicking on naming
); | ||
|
||
export const getChecks = (checkResults) => | ||
checkResults.map(({ check_id }) => check_id); | ||
|
||
export const getHealth = (checkResults, checkID, agentID) => { | ||
export const getCheckHealthByAgent = (checkResults, checkID, agentID) => { |
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.
would it make more sense to call this getCheckResultHealthByAgent
?
} | ||
|
||
// expectation evaluation error , malformed expression most probably | ||
const evaluationErrors = agentCheckResult?.expectation_evaluations.filter( |
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 personally like adding a Count
suffix to variables that are just counting something, in this case e.g.: evaluationErrorCount
as it makes operations with the variable more obvious (e.g. the +
below is immediately understood as a sum and not a concatenation). Wdyt?
}; | ||
|
||
const addExpectation = (checkResult, name, expec, result) => { | ||
const { type } = expec; |
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.
expect maybe?
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.
This should be expectation
to me, you're right
return addExpectation(checkResult, name, expec, false); | ||
}; | ||
|
||
export const addExpectationWithError = (checkResult) => { |
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.
maybe addErroredExpectation
sound better and matches the same wording as the other functions?
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.
@dottorblaster It looks good.
Have a look only in one of the factory functions that I think you updated accidentaly.
Besides that, a small change in the test to make it more logical.
Green light, otherwise.
I cannot approve though, as I opened the PR XD
); | ||
|
||
export const executionFactFactory = Factory.define(() => ({ | ||
check_id: faker.datatype.uuid(), | ||
name: faker.animal.cat(), | ||
value: faker.datatype.number(), | ||
result: resultEnum(), |
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.
This change looks wrong. This is an execution fact, which is composed by check_id
, name
and value
, as it was before
import { renderWithRouter } from '@lib/test-utils'; | ||
import { | ||
addCriticalExpectation, |
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.
Is there any reason not to put the executions
under the factories import. All of them are exported in the index file.
@lib/test-utils/factories
@@ -87,7 +108,8 @@ describe('ExecutionResults', () => { | |||
const { | |||
clusterID, | |||
hostnames, | |||
checkID, | |||
checkID1, |
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.
Should we return maybe checks
? As we do with the hostnames
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.
Fair point
} from '@lib/test-utils/factories/executions'; | ||
import { catalogFactory, hostnameFactory } from '@lib/test-utils/factories'; | ||
|
||
import ExecutionResults from './ExecutionResults'; | ||
|
||
const prepareStateData = (checkExecutionStatus) => { | ||
const hostnames = hostnameFactory.buildList(2); | ||
const hostnames = hostnameFactory.buildList(4); |
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.
Why a 4
here?
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.
Leftover from an experiment LOL
}); | ||
|
||
const lastExecution = { | ||
executionLoading: false, | ||
executionData: { | ||
status: checkExecutionStatus, | ||
targets, | ||
check_results: [checkResult], | ||
check_results: [checkResult1, checkResult2], |
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.
@dottorblaster You fortot to change this executionData: executionResult
Improve the old
getHealth
(nowgetCheckHealthByAgent
) to consider all the possible scenarios: agentCheckError, expect_same, fact gathering error, etcI have added more factory improvements in order to make the check results mocks creation easy.
PD: I have fixed some other functions like
getHosts
by this will be removed once we get the other PR using thetargets
to create the results table