Skip to content

Commit

Permalink
Print remediations time in e2e tests using AfterSuite
Browse files Browse the repository at this point in the history
AfterSuite is run after the whole suite is finished
  • Loading branch information
razo7 committed Dec 13, 2023
1 parent e14fcc6 commit f6886d8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions test/e2e/far_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
pollDeletion = 250 * time.Millisecond
pollInterval = 10 * time.Second
)
var remediationsTime []time.Duration

var _ = Describe("FAR E2e", func() {
var (
Expand Down Expand Up @@ -84,7 +85,6 @@ var _ = Describe("FAR E2e", func() {
pod *corev1.Pod
startTime, nodeBootTimeBefore time.Time
err error
remediationTimes []time.Duration
)
BeforeEach(func() {
nodes = &corev1.NodeList{}
Expand Down Expand Up @@ -134,27 +134,26 @@ var _ = Describe("FAR E2e", func() {
When("running FAR to reboot two nodes", func() {
It("should successfully remediate the first node", func() {
checkRemediation(nodeName, nodeBootTimeBefore, pod)
remediationTimes = append(remediationTimes, time.Since(startTime))
remediationsTime = append(remediationsTime, time.Since(startTime))
})
It("should successfully remediate the second node", func() {
checkRemediation(nodeName, nodeBootTimeBefore, pod)
remediationTimes = append(remediationTimes, time.Since(startTime))
remediationsTime = append(remediationsTime, time.Since(startTime))
})
})
AfterEach(func() {
if len(remediationTimes) == 2 {
averageTimeDuration := 0.0
for index, remTime := range remediationTimes {
averageTimeDuration += remTime.Seconds()
fmt.Printf("\nRemediation time #%d: %s\n", index+1, remTime)
}
averageTime := int(averageTimeDuration) / len(remediationTimes)
fmt.Printf("\nAverage remediation time: %d minutes and %d seconds\n", averageTime/60, averageTime%60)
}
})
})
})

var _ = AfterSuite( func() {
averageTimeDuration := 0.0
for _, remTime := range remediationsTime {
averageTimeDuration += remTime.Seconds()
log.Info("Remediation was finished", "remediation time", remTime)
}
averageTime := int(averageTimeDuration) / len(remediationsTime)
log.Info("Average remediation time", "minutes", averageTime/60, "seconds", averageTime%60)
})

// buildSharedParameters returns a map key-value of shared parameters based on cluster platform type if it finds the credentials, otherwise an error
func buildSharedParameters(clusterPlatform *configv1.Infrastructure, action string) (map[v1alpha1.ParameterName]string, error) {
const (
Expand Down

0 comments on commit f6886d8

Please sign in to comment.