Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print Remediation Time in E2E Tests #111

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions test/e2e/far_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const (
pollInterval = 10 * time.Second
)

var remediationsTime []time.Duration

var _ = Describe("FAR E2e", func() {
var (
fenceAgent, nodeIdentifierPrefix string
Expand Down Expand Up @@ -84,7 +86,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 +135,28 @@ 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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I think the old name was correct... 🤔
multiple times of a single remediation
this now sounds like overall time of all remediations

})
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() {
if len(remediationsTime) > 0 {
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