flyte icon indicating copy to clipboard operation
flyte copied to clipboard

Switch workflowengine compiler mock to mockery generated

Open luckyarthur opened this issue 10 months ago • 5 comments

Tracking issue

Related to https://github.com/flyteorg/flyte/issues/149

Why are the changes needed?

FlyteAdmin currently relies on manually crafted mocks, which are cumbersome to maintain and extend for new interfaces. Switching to Mockery v2 generated mocks is a more efficient approach, eliminating repetitive boilerplate code and streamlining the development process, also add the go generate comment which automates update of mocks

What changes were proposed in this pull request?

this PR includes changes of mock for flyteadmin/pkg/workflowengine/interfaces/compiler.go, and update unit test usage of the new mockery generated mock

Check all the applicable boxes

  • [x] All new and existing tests passed.
  • [x] All commits are signed-off.

Summary by Bito

Modernization of testing infrastructure by replacing manual mocks with Mockery v2 generated mocks for the workflow engine compiler interface. The update includes adding go:generate directives and implementing new Mockery v2-based mocks. The changes streamline the codebase by removing old manual mock implementations while enhancing maintainability and consistency of test files.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 2

luckyarthur avatar Feb 20 '25 07:02 luckyarthur

Code Review Agent Run #285e27

Actionable Suggestions - 2
  • flyteadmin/pkg/manager/impl/workflow_manager_test.go - 1
    • Consider simplifying mock setup implementation · Line 235-237
  • flyteadmin/pkg/manager/impl/task_manager_test.go - 1
Review Details
  • Files reviewed - 5 · Commit Range: f12185a..6fbb5a6
    • flyteadmin/pkg/manager/impl/task_manager_test.go
    • flyteadmin/pkg/manager/impl/workflow_manager_test.go
    • flyteadmin/pkg/workflowengine/interfaces/compiler.go
    • flyteadmin/pkg/workflowengine/mocks/Compiler.go
    • flyteadmin/pkg/workflowengine/mocks/mock_compiler.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Feb 20 '25 07:02 flyte-bot

Codecov Report

:x: Patch coverage is 45.07042% with 39 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 36.85%. Comparing base (e9e227b) to head (23fe577). :warning: Report is 205 commits behind head on master.

Files with missing lines Patch % Lines
flyteadmin/pkg/workflowengine/mocks/Compiler.go 45.07% 27 Missing and 12 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6261      +/-   ##
==========================================
- Coverage   36.86%   36.85%   -0.01%     
==========================================
  Files        1318     1318              
  Lines      134773   134821      +48     
==========================================
+ Hits        49683    49695      +12     
- Misses      80758    80782      +24     
- Partials     4332     4344      +12     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 51.82% <45.07%> (-0.06%) :arrow_down:
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.22% <ø> (ø)
unittests-flyteplugins 54.00% <ø> (ø)
unittests-flytepropeller 42.78% <ø> (ø)
unittests-flytestdlib 55.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Feb 20 '25 07:02 codecov[bot]

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Testing - Mock Framework Migration to Mockery v2

task_manager_test.go - Updated test code to use new Mockery v2 generated compiler mock

workflow_manager_test.go - Migrated workflow manager tests to use new Mockery v2 compiler mock

builder.go - Added mockery-v2 generate directive for FlyteWorkflowBuilder interface

compiler.go - Added mockery-v2 generate directive for Compiler interface

executor.go - Added mockery-v2 generate directive for WorkflowExecutor interface

Compiler.go - Added new Mockery v2 generated mock implementation

mock_compiler.go - Removed old manual mock implementation

flyte-bot avatar Feb 20 '25 07:02 flyte-bot

Code Review Agent Run #74cc11

Actionable Suggestions - 1
  • flyteadmin/pkg/manager/impl/task_manager_test.go - 1
    • Consider more specific mock matcher condition · Line 176-176
Review Details
  • Files reviewed - 5 · Commit Range: 6fbb5a6..23fe577
    • flyteadmin/pkg/manager/impl/task_manager_test.go
    • flyteadmin/pkg/manager/impl/workflow_manager_test.go
    • flyteadmin/pkg/workflowengine/interfaces/builder.go
    • flyteadmin/pkg/workflowengine/interfaces/compiler.go
    • flyteadmin/pkg/workflowengine/interfaces/executor.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Feb 20 '25 10:02 flyte-bot

Thank you, can you fix the conficts, the lint warnings and make sure to run make -C flyteadmin regenerate from the root of the repo?

eapolinario avatar Mar 11 '25 00:03 eapolinario