mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
debuging metrics
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
This commit is contained in:
parent
fcb792964d
commit
28b053e54e
1 changed files with 46 additions and 0 deletions
|
@ -3,7 +3,9 @@ package metrics
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kyverno/kyverno/test/e2e"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -26,5 +28,49 @@ func Test_MetricsServerAvailability(t *testing.T) {
|
|||
fmt.Println("==============================================================")
|
||||
fmt.Println(newStr)
|
||||
fmt.Println("==============================================================")
|
||||
processMetrics(newStr, "multi-tenancy", time.Now())
|
||||
Expect(response.StatusCode).To(Equal(200))
|
||||
}
|
||||
|
||||
func processMetrics(newStr, e2ePolicyName string, e2eTime time.Time) {
|
||||
var action, policyName string
|
||||
var timeInTimeFormat time.Time
|
||||
var err error
|
||||
splitByNewLine := strings.Split(newStr, "\n")
|
||||
for _, lineSplitedByNewLine := range splitByNewLine {
|
||||
if strings.HasPrefix(lineSplitedByNewLine, "kyverno_policy_changes_info{") {
|
||||
// fmt.Println(lineSplitedByNewLine)
|
||||
splitByComma := strings.Split(lineSplitedByNewLine, ",")
|
||||
for _, lineSplitedByComma := range splitByComma {
|
||||
// fmt.Println(lineSplitedByComma)
|
||||
if strings.HasPrefix(lineSplitedByComma, "policy_change_type=") {
|
||||
// action = lineSplitedByComma
|
||||
splitByQuote := strings.Split(lineSplitedByComma, "\"")
|
||||
action = splitByQuote[1]
|
||||
}
|
||||
if strings.HasPrefix(lineSplitedByComma, "policy_name=") {
|
||||
splitByQuote := strings.Split(lineSplitedByComma, "\"")
|
||||
policyName = splitByQuote[1]
|
||||
}
|
||||
if strings.HasPrefix(lineSplitedByComma, "timestamp=") {
|
||||
splitByQuote := strings.Split(lineSplitedByComma, "\"")
|
||||
timeInTimeFormat, err = time.Parse(splitByQuote[1], "2014-11-17 23:02:03 +0000 UTC")
|
||||
if err != nil {
|
||||
fmt.Println("error: ", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
fmt.Println("action: ", action)
|
||||
fmt.Println("policyName: ", policyName)
|
||||
fmt.Println("timeInTimeFormat: ", timeInTimeFormat)
|
||||
|
||||
diff := time.Now().Sub(timeInTimeFormat)
|
||||
fmt.Println(diff)
|
||||
|
||||
diff = timeInTimeFormat.Sub(time.Now())
|
||||
fmt.Println(diff)
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue