mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Reset metrics in tests
This commit is contained in:
parent
f4e7b5480d
commit
2a1834f7ed
@ -98,11 +98,7 @@ var _ = Describe("Density", func() {
|
|||||||
expectNoError(err)
|
expectNoError(err)
|
||||||
uuid = string(util.NewUUID())
|
uuid = string(util.NewUUID())
|
||||||
|
|
||||||
// Print latency metrics before the test.
|
expectNoError(resetMetrics(c))
|
||||||
// TODO: Remove this once we reset metrics before the test.
|
|
||||||
_, err = HighLatencyRequests(c, 3*time.Second, util.NewStringSet("events"))
|
|
||||||
expectNoError(err)
|
|
||||||
|
|
||||||
expectNoError(os.Mkdir(fmt.Sprintf(testContext.OutputDir+"/%s", uuid), 0777))
|
expectNoError(os.Mkdir(fmt.Sprintf(testContext.OutputDir+"/%s", uuid), 0777))
|
||||||
expectNoError(writePerfData(c, fmt.Sprintf(testContext.OutputDir+"/%s", uuid), "before"))
|
expectNoError(writePerfData(c, fmt.Sprintf(testContext.OutputDir+"/%s", uuid), "before"))
|
||||||
})
|
})
|
||||||
|
@ -73,6 +73,8 @@ var _ = Describe("Load capacity", func() {
|
|||||||
nsForTesting, err := createTestingNS("load", c)
|
nsForTesting, err := createTestingNS("load", c)
|
||||||
ns = nsForTesting.Name
|
ns = nsForTesting.Name
|
||||||
expectNoError(err)
|
expectNoError(err)
|
||||||
|
|
||||||
|
expectNoError(resetMetrics(c))
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO add flag that allows to skip cleanup on failure
|
// TODO add flag that allows to skip cleanup on failure
|
||||||
@ -85,7 +87,6 @@ var _ = Describe("Load capacity", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify latency metrics
|
// Verify latency metrics
|
||||||
// TODO: We should reset metrics before the test. Currently previous tests influence latency metrics.
|
|
||||||
highLatencyRequests, err := HighLatencyRequests(c, 1*time.Second, util.NewStringSet("events"))
|
highLatencyRequests, err := HighLatencyRequests(c, 1*time.Second, util.NewStringSet("events"))
|
||||||
expectNoError(err, "Too many instances metrics above the threshold")
|
expectNoError(err, "Too many instances metrics above the threshold")
|
||||||
Expect(highLatencyRequests).NotTo(BeNumerically(">", 0))
|
Expect(highLatencyRequests).NotTo(BeNumerically(">", 0))
|
||||||
|
@ -1395,6 +1395,19 @@ func HighLatencyRequests(c *client.Client, threshold time.Duration, ignoredResou
|
|||||||
return len(badMetrics), nil
|
return len(badMetrics), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset latency metrics in apiserver.
|
||||||
|
func resetMetrics(c *client.Client) error {
|
||||||
|
Logf("Resetting latency metrics in apiserver...")
|
||||||
|
body, err := c.Get().AbsPath("/resetMetrics").DoRaw()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if string(body) != "metrics reset\n" {
|
||||||
|
return fmt.Errorf("Unexpected response: ", string(body))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve metrics information
|
// Retrieve metrics information
|
||||||
func getMetrics(c *client.Client) (string, error) {
|
func getMetrics(c *client.Client) (string, error) {
|
||||||
body, err := c.Get().AbsPath("/metrics").DoRaw()
|
body, err := c.Get().AbsPath("/metrics").DoRaw()
|
||||||
|
Loading…
Reference in New Issue
Block a user