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

ignore status for chicklets #3254

Merged
merged 3 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions components/compliance-service/api/tests/02_nodes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@
]
}
],
"total" => 1,
"total" => 2,
"totalFailed" => 1,
"totalPassed" => 1
}.to_json
assert_equal_json_sorted(expected_nodes, actual_nodes.to_json)
Expand Down Expand Up @@ -715,8 +716,10 @@
]
}
],
"total" => 1,
"totalPassed" => 1
"total" => 5,
"totalFailed" => 3,
"totalPassed" => 1,
"totalSkipped" => 1
}.to_json
assert_equal_json_sorted(expected_nodes, actual_nodes.to_json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def reporting;
],
page: 1, per_page: 2)
expected_data = {
"counts" => { "waived" => 1 },
"counts" => { "total" => 1, "waived" => 1 },
"profiles" => [
{
"id" => "447542ecfb8a8800ed0146039da3af8fed047f575f6037cfba75f3b664a97ea5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def reporting;
}
],
"counts" => {
"total" => 2,
"total" => 3,
"failed" => 1,
"skipped" => 2
}
}
Expand Down
12 changes: 11 additions & 1 deletion components/compliance-service/reporting/relaxting/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,22 @@ func (backend *ES2Backend) GetNodes(from int32, size int32, filters map[string][
}

}
//take status out of filters similar to why we remove them from suggestions.. we want to always see what's available in this context
delete(filters, "status")
// get node counts of passed/failed/skipped/waived nodes to append to totals response
nodeSummary, err := backend.GetStatsSummaryNodes(filters)
if err != nil {
return nil, emptyTotals, errors.Wrapf(err, "%s error retrieving node count totals: ", myName)
}
return nodes, TotalNodeCounts{Total: int32(searchResult.TotalHits()), Passed: nodeSummary.Compliant, Failed: nodeSummary.Noncompliant, Skipped: nodeSummary.Skipped, Waived: nodeSummary.Waived}, nil

total := nodeSummary.Compliant + nodeSummary.Noncompliant + nodeSummary.Skipped + nodeSummary.Waived
return nodes, TotalNodeCounts{
Total: total,
Passed: nodeSummary.Compliant,
Failed: nodeSummary.Noncompliant,
Skipped: nodeSummary.Skipped,
Waived: nodeSummary.Waived,
}, nil
}

logrus.Debugf("%s Found no nodes\n", myName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (depth *ControlDepth) getProfileMinsFromNodesResults(

profileMins := make(map[string]reporting.ProfileMin)
var counts *reportingapi.ProfileCounts
statusMap := make(map[string]int, 4)

if aggRoot, found := depth.unwrap(&searchResult.Aggregations); found {
if impactBuckets, found := aggRoot.Aggregations.Terms("impact"); found && len(impactBuckets.Buckets) > 0 {
Expand Down Expand Up @@ -109,12 +110,15 @@ func (depth *ControlDepth) getProfileMinsFromNodesResults(
Status: profileStatus,
}
profileMins[summary.Id] = summaryRep

//let's keep track of the counts even if they're not in the filter so that we may know that they're there for UI chicklets
statusMap[profileStatus]++
counts = &reportingapi.ProfileCounts{
Total: summary.Failures + summary.Passed + summary.Skipped + summary.Waived,
Failed: summary.Failures,
Passed: summary.Passed,
Skipped: summary.Skipped,
Waived: summary.Waived,
Total: int32(statusMap["failed"] + statusMap["passed"] + statusMap["skipped"] + statusMap["waived"]),
Failed: int32(statusMap["failed"]),
Passed: int32(statusMap["passed"]),
Skipped: int32(statusMap["skipped"]),
Waived: int32(statusMap["waived"]),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ func (depth *ProfileDepth) getProfileMinsFromNodesResults(
int32(*sumSkipped.Value), int32(*sumWaived.Value))
}

//let's keep track of the counts even if they're not in the filter so that we may know that they're there for UI chicklets
statusMap[profileStatus]++

if len(statusFilters) > 0 && !stringutils.SliceContains(statusFilters, profileStatus) {
continue
}

statusMap[profileStatus]++

summary := reporting.ProfileMin{
Name: profileName,
ID: profileId,
Expand All @@ -98,7 +99,7 @@ func (depth *ProfileDepth) getProfileMinsFromNodesResults(
logrus.Debugf("%s Done with statusMap=%+v", myName, statusMap)
logrus.Debugf("%s Done with statusMap['something']=%+v", myName, statusMap["passed"])
counts := &reportingapi.ProfileCounts{
Total: int32(statusMap["failed"] + statusMap["passed"] + statusMap["skipped"]),
Total: int32(statusMap["failed"] + statusMap["passed"] + statusMap["skipped"] + statusMap["waived"]),
Failed: int32(statusMap["failed"]),
Passed: int32(statusMap["passed"]),
Skipped: int32(statusMap["skipped"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ func (depth *ReportDepth) getProfileMinsFromNodesResults(
logrus.Debugf("getProfileMinsFromNodesResults profile_name=%s, status=%s (sumFailures=%d, sumPassed=%d, sumSkipped=%d, sumWaived=%d)", profileName, profileStatus, int32(*sumFailures.Value), int32(*sumPassed.Value), int32(*sumSkipped.Value), int32(*sumWaived.Value))
}

//let's keep track of the counts even if they're not in the filter so that we may know that they're there for UI chicklets
statusMap[profileStatus]++

if len(statusFilters) > 0 && !stringutils.SliceContains(statusFilters, profileStatus) {
continue
}

statusMap[profileStatus]++

summary := reporting.ProfileMin{
Name: profileName,
ID: profileId,
Expand All @@ -95,7 +96,7 @@ func (depth *ReportDepth) getProfileMinsFromNodesResults(
logrus.Debugf("Done with statusMap=%+v", statusMap)
logrus.Debugf("Done with statusMap['something']=%+v", statusMap["passed"])
counts := &reportingapi.ProfileCounts{
Total: int32(statusMap["failed"]+statusMap["passed"]+statusMap["skipped"]) + int32(statusMap["waived"]),
Total: int32(statusMap["failed"] + statusMap["passed"] + statusMap["skipped"] + statusMap["waived"]),
Failed: int32(statusMap["failed"]),
Passed: int32(statusMap["passed"]),
Skipped: int32(statusMap["skipped"]),
Expand Down