-
Notifications
You must be signed in to change notification settings - Fork 47
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
Refactor applicationEventQueueLoop so it can be unit tested, and write new unit tests for it #502
Refactor applicationEventQueueLoop so it can be unit tested, and write new unit tests for it #502
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jgwest The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test all |
@@ -114,8 +114,34 @@ func startApplicationEventQueueLoopWithFactory(ctx context.Context, aeqlParam Ap | |||
|
|||
} | |||
|
|||
type applicationEventQueueLoopState struct { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer: I moved these out of applicationEventQueueLoop
, and added some comments, they are otherwise the same as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I don't see where these fields are moved out from applicationEventQueueLoop
at line 65. You'd think that there would be a git diff on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, GitHub diff isn't very good here, in this case I often find I have to copy/paste the change into a text file, and compare them using another tool like VS Code, Meld Merge, or BeyondCompare.
log.V(logutil.LogLevel_Debug).Info("applicationEventQueueLoop received event", | ||
"event", eventlooptypes.StringEventLoopEvent(eventLoopMessage)) | ||
// returns true if the event loop should be terminated, false otherwise. | ||
func processApplicationEventQueueLoopMessage(ctx context.Context, newEvent RequestMessage, state *applicationEventQueueLoopState, input chan RequestMessage, k8sClient client.Client, log logr.Logger) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer: I moved the contents of applicationEventQueueLoop
into its own function, so it was easier to unit test. The code is otherwise the same (the GitHub compare is mangling it 😄 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looks like you did move the contents of that loop out to the new function.
I think you added the two new const booleans.
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.SyncRunModified, | ||
ReqResource: eventlooptypes.GitOpsDeploymentSyncRunTypeName, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.SyncRunModified, | ||
ReqResource: eventlooptypes.GitOpsDeploymentSyncRunTypeName, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.DeploymentModified, | ||
ReqResource: eventlooptypes.GitOpsDeploymentTypeName, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.DeploymentModified, | ||
ReqResource: eventlooptypes.GitOpsDeploymentTypeName, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.ManagedEnvironmentModified, | ||
ReqResource: eventlooptypes.GitOpsDeploymentManagedEnvironmentTypeName, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
MessageType: eventlooptypes.ApplicationEventLoopMessageType_Event, | ||
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.UpdateDeploymentStatusTick, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
MessageType: eventlooptypes.ApplicationEventLoopMessageType_WorkComplete, | ||
Event: &eventlooptypes.EventLoopEvent{ | ||
EventType: eventlooptypes.UpdateDeploymentStatusTick, | ||
WorkspaceID: string(workspaceUID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with: WorkspaceID: workspaceUID,
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #502 +/- ##
==========================================
+ Coverage 51.60% 52.48% +0.87%
==========================================
Files 109 108 -1
Lines 19041 19091 +50
==========================================
+ Hits 9827 10020 +193
+ Misses 8029 7858 -171
- Partials 1185 1213 +28
☔ View full report in Codecov by Sentry. |
Description:
applicationEventQueueLoop
into a separate struct, so that the state can be verified by unit testsprocessApplicationEventQueueLoopMessage
processApplicationEventQueueLoopMessage
via new unit testsLink to JIRA Story (if applicable): N/A