Skip to content

Commit

Permalink
init velero analyzer tests
Browse files Browse the repository at this point in the history
Signed-off-by: Archit Sharma <[email protected]>
  • Loading branch information
arcolife committed Nov 1, 2023
1 parent 8bc5047 commit 23d393d
Show file tree
Hide file tree
Showing 2 changed files with 963 additions and 18 deletions.
44 changes: 26 additions & 18 deletions pkg/analyze/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (a *AnalyzeVelero) veleroStatus(analyzer *troubleshootv1beta2.VeleroAnalyze
results = append(results, analyzePodVolumeRestores(podVolumeRestores)...)
results = append(results, analyzeRestores(restores)...)
results = append(results, analyzeSchedules(schedules)...)
results = append(results, analyzeServerStatusRequests(serverStatusRequests)...)
// results = append(results, analyzeServerStatusRequests(serverStatusRequests)...)
results = append(results, analyzeVolumeSnapshotLocations(volumeSnapshotLocations)...)

return aggregateResults(results), nil
Expand Down Expand Up @@ -558,11 +558,11 @@ func analyzeSchedules(schedules []*velerov1.Schedule) []*AnalyzeResult {
return results
}

func analyzeServerStatusRequests(serverStatusRequests []*velerov1.ServerStatusRequest) []*AnalyzeResult {
results := []*AnalyzeResult{}
// TODO
return results
}
// func analyzeServerStatusRequests(serverStatusRequests []*velerov1.ServerStatusRequest) []*AnalyzeResult {
// results := []*AnalyzeResult{}

// return results
// }

func analyzeVolumeSnapshotLocations(volumeSnapshotLocations []*velerov1.VolumeSnapshotLocation) []*AnalyzeResult {
results := []*AnalyzeResult{}
Expand Down Expand Up @@ -598,24 +598,24 @@ func analyzeLogs(logs map[string][]byte) []*AnalyzeResult {
for _, logBytes := range logs {
logContent := string(logBytes)
result := &AnalyzeResult{
Title: fmt.Sprintf("Velero logs for pod [node-agent] "),
Title: fmt.Sprintf("Velero logs for pod [node-agent]"),
}
if strings.Contains(logContent, "permission denied") {
result.IsFail = true
result.Message = fmt.Sprintf("Found 'permission denied' in node-agent log file(s)")
result.IsWarn = true
result.Message = fmt.Sprintf("Found 'permission denied' in node-agent* pod log file(s)")
results = append(results, result)
continue
}

if strings.Contains(logContent, "error") || strings.Contains(logContent, "panic") || strings.Contains(logContent, "fatal") {
result.IsWarn = true
result.Message = fmt.Sprintf("Found error|panic|fatal in node-agent log file(s)")
result.Message = fmt.Sprintf("Found error|panic|fatal in node-agent* pod log file(s)")
results = append(results, result)
}
}

results = append(results, &AnalyzeResult{
Title: "Velero Logs",
Title: "Velero Logs analysis",
IsPass: true,
Message: fmt.Sprintf("Found %d log files", len(logs)),
})
Expand All @@ -632,13 +632,21 @@ func aggregateResults(results []*AnalyzeResult) []*AnalyzeResult {
}
out = append(out, result)
}

if resultFailed == false {
out = append(out, &AnalyzeResult{
Title: "Velero Status",
IsPass: true,
Message: "Backups and CRDs are healthy",
})
if len(results) > 0 {
if resultFailed == false {
out = append(out, &AnalyzeResult{
Title: "Velero Status",
IsPass: true,
Message: "Velero setup is healthy",
})
}
if resultFailed == true {
out = append(out, &AnalyzeResult{
Title: "Velero Status",
IsWarn: true,
Message: "Velero setup is not entirely healthy",
})
}
}

return out
Expand Down
Loading

0 comments on commit 23d393d

Please sign in to comment.