This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Added user configurable options for streaming message queues. #308
Open
sayar
wants to merge
1
commit into
master
Choose a base branch
from
feat-user-config-options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| """Event Hub Streaming Class Unit Tests""" | ||
|
|
||
| from unittest.mock import patch | ||
|
|
||
| from azure.eventprocessorhost import EPHOptions | ||
| from agogosml.common.eventhub_streaming_client import EventHubStreamingClient | ||
|
|
||
|
|
||
| @patch('agogosml.utils.logger.Logger') | ||
| def test_create_eventhub_eph_options(mock_logger): | ||
| """Test the create eventhub eph options method.""" | ||
|
|
||
| # Pass in empty config | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options({}, mock_logger) | ||
|
|
||
| # Assert default config is returned. | ||
| assert isinstance(eph_options, EPHOptions) | ||
| assert not eph_options.debug_trace | ||
|
|
||
| # Pass in null config | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': None | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert isinstance(eph_options, EPHOptions) | ||
| assert not eph_options.debug_trace | ||
|
|
||
| # Pass in invalid string | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': 'invalid' | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert mock_logger.warning.called | ||
| assert isinstance(eph_options, EPHOptions) | ||
| assert not eph_options.debug_trace | ||
|
|
||
| mock_logger.reset_mock() | ||
|
|
||
| # Pass in invalid string and valid debug variable | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': 'invalid', | ||
| 'EVENT_HUB_DEBUG': 'True' | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert mock_logger.warning.called | ||
| assert isinstance(eph_options, EPHOptions) | ||
| assert eph_options.debug_trace | ||
|
|
||
| mock_logger.reset_mock() | ||
|
|
||
| # Pass in string and valid debug variable | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': '{"debug_trace": "True"}', | ||
| 'EVENT_HUB_DEBUG': 'False' | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert not mock_logger.warning.called | ||
| assert isinstance(eph_options, EPHOptions) | ||
| # NOTE: EVENT_HUB_EPH_OPTIONS should overwrite EVENT_HUB_DEBUG | ||
| assert eph_options.debug_trace | ||
|
|
||
| mock_logger.reset_mock() | ||
|
|
||
| # Pass in valid string | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': '{"keep_alive_interval": "30"}' | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert not mock_logger.warning.called | ||
| assert isinstance(eph_options, EPHOptions) | ||
| assert eph_options.keep_alive_interval == 30 | ||
|
|
||
| mock_logger.reset_mock() | ||
|
|
||
| # Pass in invalid string | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': '{"keep_alive_interval": "True"}' | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert mock_logger.warning.called | ||
| assert isinstance(eph_options, EPHOptions) | ||
| assert eph_options.keep_alive_interval is None | ||
|
|
||
| mock_logger.reset_mock() | ||
|
|
||
| # Pass in custom EPH Options | ||
| eph_options = EPHOptions() | ||
| eph_options.keep_alive_interval = "-1" | ||
| eph_options.debug_trace = True | ||
| config = { | ||
| 'EVENT_HUB_EPH_OPTIONS': eph_options, | ||
| 'EVENT_HUB_DEBUG': 'False' | ||
| } | ||
| eph_options = EventHubStreamingClient.create_eventhub_eph_options(config, mock_logger) | ||
| # Assert default config is returned. | ||
| assert not mock_logger.warning.called | ||
| assert isinstance(eph_options, EPHOptions) | ||
| # NOTE: EVENT_HUB_EPH_OPTIONS should overwrite EVENT_HUB_DEBUG | ||
| assert eph_options.keep_alive_interval == "-1" | ||
| assert eph_options.debug_trace |
Oops, something went wrong.
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.
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.
here we have to ensure that user_config.get('EVENTHUB_KAFKA_CONNECTION_STRING') won't return an empty string if it's not set