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

cgu: add wait for condition and unit tests #474

Merged
merged 1 commit into from
Jun 16, 2024

Conversation

klaskosk
Copy link
Collaborator

In TALM and ZTP test cases there are many scenarios where we are waiting for a CGU to be in some condition. WaitForCondition generalizes these cases (and the existing WaitUntilComplete) into a single function. Unit tests have been added for WaitForCondition as well as the existing WaitUntilComplete.

Copy link
Collaborator

@cdvultur cdvultur left a comment

Choose a reason for hiding this comment

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

Looks good. Only one question to clarify

pkg/cgu/cgu.go Outdated Show resolved Hide resolved
pkg/cgu/cgu.go Outdated Show resolved Hide resolved
pkg/cgu/cgu.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@kononovn kononovn left a comment

Choose a reason for hiding this comment

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

Please fix few comments

pkg/cgu/cgu.go Outdated
}

builder.Definition = builder.Object

for _, condition := range builder.Object.Status.Conditions {
if condition.Status == isTrue && condition.Type == isComplete {
return true, nil
if (expected.Type != "" && condition.Type != expected.Type) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have any particular reason to implement such complicated if condition? Why do we need to change it ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kononovn The diff is a bit weird here. I'm adding a new more general method WaitForCondition and then reimplementing the WaitUntilComplete function using WaitForCondition so the if statement handles more now. I'll use WaitForCondition directly in eco-gotests as well.

I've updated the PR to split the if statement into separate ones for clarity though.

In TALM and ZTP test cases there are many scenarios where we are waiting for a CGU to be in some condition. WaitForCondition generalizes these cases (and the existing WaitUntilComplete) into a single function. Unit tests have been added for WaitForCondition as well as the existing WaitUntilComplete.
Copy link
Collaborator

@kononovn kononovn left a comment

Choose a reason for hiding this comment

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

/lgtm

@kononovn kononovn merged commit 4ad37eb into openshift-kni:main Jun 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants