Skip to content

Commit

Permalink
Fix for tnf tool
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid committed Dec 14, 2023
1 parent 783a2c1 commit af7b248
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions cmd/tnf/claim/show/csv/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func buildCSV(claimScheme *claim.Schema, cnfType string, catalogMap map[string]c
"CNFName", "testID", "Suite",
"Description", "State",
"StartTime", "EndTime",
"FailureReason", "Output",
"SkipReason", "CheckDetails", "Output",
"Remediation", "CNFType",
"Mandatory/Optional",
})
Expand All @@ -164,7 +164,8 @@ func buildCSV(claimScheme *claim.Schema, cnfType string, catalogMap map[string]c
claimScheme.Claim.Results[testID].State,
claimScheme.Claim.Results[testID].StartTime,
claimScheme.Claim.Results[testID].EndTime,
claimScheme.Claim.Results[testID].FailureReason,
claimScheme.Claim.Results[testID].SkipReason,
claimScheme.Claim.Results[testID].CheckDetails,
claimScheme.Claim.Results[testID].CapturedTestOutput,
catalogMap[testID].Remediation,
cnfType, // Append the CNF type
Expand Down
6 changes: 3 additions & 3 deletions cmd/tnf/claim/show/failures/failures.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func printFailuresText(testSuites []FailedTestSuite) {

// In case this tc was not using report objects, just print the failure reason string.
if len(tc.NonCompliantObjects) == 0 {
fmt.Printf(" Failure reason: %s\n", tc.FailureReason)
fmt.Printf(" Failure reason: %s\n", tc.SkipReason)
continue
}

Expand Down Expand Up @@ -253,12 +253,12 @@ func getFailedTestCasesByTestSuite(claimResultsByTestSuite map[string][]*claim.T
TestCaseDescription: tc.CatalogInfo.Description,
}

nonCompliantObjects, err := getNonCompliantObjectsFromFailureReason(tc.FailureReason)
nonCompliantObjects, err := getNonCompliantObjectsFromFailureReason(tc.SkipReason)
if err != nil {
// This means the test case doesn't use the report objects yet. Just use the raw failure reason instead.
// Also, send the error into stderr, so it can be filtered out with "2>/errors.txt" or "2>/dev/null".
fmt.Fprintf(os.Stderr, "Failed to parse non compliant objects from test case %s (test suite %s): %v", tc.TestID.ID, testSuite, err)
failingTc.FailureReason = tc.FailureReason
failingTc.SkipReason = tc.SkipReason
} else {
failingTc.NonCompliantObjects = nonCompliantObjects
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/show/failures/failures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func TestGetFailedTestCasesByTestSuite(t *testing.T) {
{
TestCaseName: "access-control-sys-admin-capability-check",
TestCaseDescription: "Ensures that containers do not use SYS_ADMIN capability",
FailureReason: "pod xxx ns yyy container zzz uses SYS_ADMIN",
SkipReason: "pod xxx ns yyy container zzz uses SYS_ADMIN",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/tnf/claim/show/failures/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (spec *ObjectSpec) MarshalJSON() ([]byte, error) {
type FailedTestCase struct {
TestCaseName string `json:"name"`
TestCaseDescription string `json:"description"`
FailureReason string `json:"failureReason,omitempty"`
SkipReason string `json:"skipReason,omitempty"`
NonCompliantObjects []NonCompliantObject `json:"nonCompliantObjects,omitempty"`
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/tnf/pkg/claim/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
supportedClaimFormatVersion = "v0.2.0"
supportedClaimFormatVersion = "v0.3.0"
)

const (
Expand Down Expand Up @@ -43,7 +43,8 @@ type TestCaseResult struct {
EndTime string `json:"endTime"`
FailureLineContent string `json:"failureLineContent"`
FailureLocation string `json:"failureLocation"`
FailureReason string `json:"failureReason"`
SkipReason string `json:"skipReason"`
CheckDetails string `json:"checkDetails"`
StartTime string `json:"startTime"`
State string `json:"state"`
TestID struct {
Expand Down

0 comments on commit af7b248

Please sign in to comment.