-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
user configurable event buffer size #4411
Merged
+44
−28
Merged
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 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 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 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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
from dbt import events | ||
from dbt.events.functions import EVENT_HISTORY, fire_event | ||
|
||
from dbt.events.test_types import UnitTestInfo | ||
from argparse import Namespace | ||
from dbt.events import AdapterLogger | ||
from dbt.events.functions import event_to_serializable_dict | ||
from dbt.events.types import * | ||
from dbt.events.test_types import * | ||
from dbt.events.base_types import Event, Node | ||
from dbt.events.base_types import Event | ||
from dbt.events.stubs import _CachedRelation, BaseRelation, _ReferenceKey, ParsedModelNode | ||
from importlib import reload | ||
import dbt.events.functions as event_funcs | ||
import dbt.flags as flags | ||
import inspect | ||
import json | ||
import datetime | ||
from unittest import TestCase | ||
from dbt.contracts.graph.parsed import ( | ||
ParsedModelNode, NodeConfig, DependsOn, ParsedMacro | ||
ParsedModelNode, NodeConfig, DependsOn | ||
) | ||
from dbt.contracts.files import FileHash | ||
|
||
|
@@ -88,25 +89,29 @@ def test_event_codes(self): | |
|
||
class TestEventBuffer(TestCase): | ||
|
||
def setUp(self) -> None: | ||
flags.EVENT_BUFFER_SIZE = 10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much better |
||
reload(event_funcs) | ||
|
||
# ensure events are populated to the buffer exactly once | ||
def test_buffer_populates(self): | ||
fire_event(UnitTestInfo(msg="Test Event 1")) | ||
fire_event(UnitTestInfo(msg="Test Event 2")) | ||
event_funcs.fire_event(UnitTestInfo(msg="Test Event 1")) | ||
event_funcs.fire_event(UnitTestInfo(msg="Test Event 2")) | ||
self.assertTrue( | ||
EVENT_HISTORY.count(UnitTestInfo(msg='Test Event 1', code='T006')) == 1 | ||
event_funcs.EVENT_HISTORY.count(UnitTestInfo(msg='Test Event 1', code='T006')) == 1 | ||
) | ||
|
||
# ensure events drop from the front of the buffer when buffer maxsize is reached | ||
# TODO commenting out till we can make this not spit out 100k log lines. | ||
# def test_buffer_FIFOs(self): | ||
# for n in range(0,100001): | ||
# fire_event(UnitTestInfo(msg=f"Test Event {n}")) | ||
# self.assertTrue( | ||
# EVENT_HISTORY.count(EventBufferFull(code='Z048')) == 1 | ||
# ) | ||
# self.assertTrue( | ||
# EVENT_HISTORY.count(UnitTestInfo(msg='Test Event 1', code='T006')) == 0 | ||
# ) | ||
def test_buffer_FIFOs(self): | ||
for n in range(0,(flags.EVENT_BUFFER_SIZE + 1)): | ||
event_funcs.fire_event(UnitTestInfo(msg=f"Test Event {n}")) | ||
|
||
self.assertTrue( | ||
event_funcs.EVENT_HISTORY.count(EventBufferFull(code='Z048')) == 1 | ||
) | ||
self.assertTrue( | ||
event_funcs.EVENT_HISTORY.count(UnitTestInfo(msg='Test Event 1', code='T006')) == 0 | ||
) | ||
|
||
def MockNode(): | ||
return ParsedModelNode( | ||
|
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.
@nathaniel-may Sorry I missed this in the first PR feedback, but this pattern is required or
fire_event(EventBufferFull())
will create a recursion loop. :|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.
ahh right.