-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ci: remove reference to mock object after test #5055
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
Conversation
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.
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.
Thanks for this fix!
Even with this fix, the test still sometimes fails on my local environment.
Looks like we need the following points.
- We should do
GC.start
forObjectSpaceInputTest
to ensure GC. Fluent::Test.setup
must ensure the initialization ofFluent::Engine
.- It is very strange, but even if we do both
remove_const
andGC.start
, some objects can still exist. So, it appears that we need to setnil
explicitly, as your fix.
- It is very strange, but even if we do both
For example, how about the following fix?
diff --git a/lib/fluent/test.rb b/lib/fluent/test.rb
index ed2c3a26..6a08d5d8 100644
--- a/lib/fluent/test.rb
+++ b/lib/fluent/test.rb
@@ -40,7 +40,11 @@ module Fluent
$log = dummy_logger
- Fluent.__send__(:remove_const, :Engine)
+ old_engine = Fluent.__send__(:remove_const, :Engine)
+ # Ensure that GC can remove the objects of the old engine.
+ # Some objects can still exist after `remove_const`. See https://github.com/fluent/fluentd/pull/5055.
+ old_engine.instance_variable_set(:@root_agent, nil)
+
engine = Fluent.const_set(:Engine, EngineClass.new).init(SystemConfig.new)
engine.define_singleton_method(:now=) {|n|
diff --git a/test/plugin/test_in_object_space.rb b/test/plugin/test_in_object_space.rb
index 6e8bfa52..e734f398 100644
--- a/test/plugin/test_in_object_space.rb
+++ b/test/plugin/test_in_object_space.rb
@@ -21,6 +21,7 @@ class ObjectSpaceInputTest < Test::Unit::TestCase
def setup
Fluent::Test.setup
+ GC.start
# Overriding this behavior in the global scope will have an unexpected influence on other tests.
# So this should be overridden here and be removed in `teardown`.
def FailObject.class
hmm, I approve to add GC.start, but I wonder if we need |
This patch should fix fluent#5054 Signed-off-by: Shizuo Fujita <[email protected]>
Signed-off-by: Shizuo Fujita <[email protected]>
Lines 43 to 44 in fd711c5
What I want to say is that each test should not consider the initialization of |
Hmmm, sounds it is not related to this PR. |
OK. Let's separate the PRs. |
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.
LGTM! Thanks!
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.
LGTM.
**Which issue(s) this PR fixes**: Continued from * #5054 * #5055 (6cac9f0) **What this PR does / why we need it**: Each test should not consider the initialization of `Fluent::Engine`. It should be the responsibility of `Fluent::Test.setup`. Note: Set `nil` explicitly to ensure that GC can remove the objects, though it is very strange that some objects can still exist after `remove_const` and `GC.start`. **Docs Changes**: Not needed. **Release Note**: CI improvements. Signed-off-by: Daijiro Fukuda <[email protected]>
**Which issue(s) this PR fixes**: Continued from * fluent#5054 * fluent#5055 (6cac9f0) **What this PR does / why we need it**: Each test should not consider the initialization of `Fluent::Engine`. It should be the responsibility of `Fluent::Test.setup`. Note: Set `nil` explicitly to ensure that GC can remove the objects, though it is very strange that some objects can still exist after `remove_const` and `GC.start`. **Docs Changes**: Not needed. **Release Note**: CI improvements. Signed-off-by: Daijiro Fukuda <[email protected]>
**Which issue(s) this PR fixes**: Fixes fluent#5054 **What this PR does / why we need it**: This PR will resolve CI error. **Docs Changes**: N/A **Release Note**: N/A --------- Signed-off-by: Shizuo Fujita <[email protected]> Signed-off-by: Daijiro Fukuda <[email protected]>
Which issue(s) this PR fixes:
Fixes #5054
What this PR does / why we need it:
This PR will resolve CI error.
Docs Changes:
N/A
Release Note:
N/A