MINIFICPP-2798 Mock library for C extensions#2170
Open
martinzink wants to merge 3 commits intoc_api_devfrom
Open
MINIFICPP-2798 Mock library for C extensions#2170martinzink wants to merge 3 commits intoc_api_devfrom
martinzink wants to merge 3 commits intoc_api_devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a C++ mock library intended to support testing/verification of C extensions, and refactors the C++ extension wrapper layer to rely on abstract ProcessContext / ProcessSession interfaces with concrete CFFI-backed implementations.
Changes:
- Refactor extension wrapper APIs (
ProcessContext,ProcessSession,Logger) to use abstract base classes and CFFI-backed concrete implementations (Cffi*). - Add a new
mocklib(mock process context/session/logger + stubbed C API symbols) for extension testing without a full agent runtime. - Extend/adjust C API utility helpers (
minifiStringView, conversions) and add new small common utilities (regex wrapper + attribute error category).
Reviewed changes
Copilot reviewed 24 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libminifi/test/integration/extension-verification-test/CApiExtension.cpp | Updates extension metadata string-view helper usage. |
| extensions/llamacpp/processors/RunLlamaCppInference.cpp | Adjusts property access to updated ProcessContext API. |
| extensions/llamacpp/processors/ExtensionInitializer.cpp | Updates extension metadata string-view helper usage. |
| extension-framework/cpp-extension-lib/src/core/ProcessSession.cpp | Implements CFFI-backed ProcessSession operations + new session APIs. |
| extension-framework/cpp-extension-lib/src/core/ProcessContext.cpp | Implements CFFI-backed ProcessContext operations + dynamic props/SSL data. |
| extension-framework/cpp-extension-lib/src/core/logging/Logger.cpp | Renames/implements CFFI-backed logger wrapper. |
| extension-framework/cpp-extension-lib/src/core/ControllerServiceContext.cpp | Updates controller service property lookup string-view helper usage. |
| extension-framework/cpp-extension-lib/mocklib/src/MockProcessSession.cpp | Adds mock session implementation for tests (flow file lifecycle, content, attributes). |
| extension-framework/cpp-extension-lib/mocklib/src/MockProcessContext.cpp | Adds mock context implementation for tests (properties, defaults). |
| extension-framework/cpp-extension-lib/mocklib/src/mock-minifi-c.cpp | Adds stubbed C API symbol definitions for mock/test linkage. |
| extension-framework/cpp-extension-lib/mocklib/include/MockUtils.h | Adds small helpers for building mock processor metadata/logger. |
| extension-framework/cpp-extension-lib/mocklib/include/MockStreams.h | Adds in-memory mock InputStream/OutputStream implementations. |
| extension-framework/cpp-extension-lib/mocklib/include/MockProcessSession.h | Declares mock session class and mock flow file data model. |
| extension-framework/cpp-extension-lib/mocklib/include/MockProcessContext.h | Declares mock process context class. |
| extension-framework/cpp-extension-lib/mocklib/include/MockLogger.h | Adds a test logger capturing log strings by level. |
| extension-framework/cpp-extension-lib/mocklib/CMakeLists.txt | Adds build target for the new mock library. |
| extension-framework/cpp-extension-lib/include/api/utils/Ssl.h | Introduces SSL data structs for the extension API surface. |
| extension-framework/cpp-extension-lib/include/api/utils/ProcessorConfigUtils.h | Updates property parsing helpers to use the new getProperty(PropertyReference, FlowFile*) API. |
| extension-framework/cpp-extension-lib/include/api/utils/minifi-c-utils.h | Introduces minifiStringView + adds conversions from MinifiStringView. |
| extension-framework/cpp-extension-lib/include/api/core/Resource.h | Updates registration helpers to use CFFI wrappers + adds variadic registration helpers. |
| extension-framework/cpp-extension-lib/include/api/core/ProcessSession.h | Refactors ProcessSession into abstract interface + adds CffiProcessSession. |
| extension-framework/cpp-extension-lib/include/api/core/ProcessContext.h | Refactors ProcessContext into abstract interface + adds CffiProcessContext and new APIs. |
| extension-framework/cpp-extension-lib/include/api/core/logging/Logger.h | Renames wrapper to CffiLogger. |
| extension-framework/cpp-extension-lib/CMakeLists.txt | Adds mocklib subdirectory to build. |
| core-framework/common/src/utils/RegexUtils.cpp | Adds regex implementation backing new RegexUtils header. |
| core-framework/common/src/utils/AttributeErrors.cpp | Adds attribute error category implementation. |
| core-framework/common/include/utils/RegexUtils.h | Adds regex wrapper interface and libstdc++ workaround. |
| core-framework/common/include/utils/AttributeErrors.h | Adds attribute error code/category declarations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on
Separates the CPP wrapper into a abstract interface and the Cffi layer (that commincates via the stable API), and also introduces a Mock alternative implementation, with its easier to create new unit tests that only test the processors controllers services business logic without the need to depend on the libminifi library.
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically main)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.