-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #495 from makicamel/send-eager-loading-data
[Proposal] Introduce send_deferred_eager_loading_data configuration to reduce the load on Redis during deployment
- Loading branch information
Showing
4 changed files
with
74 additions
and
3 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require File.expand_path("../test_helper", File.dirname(__FILE__)) | ||
require "rack" | ||
|
||
class FullStackSendDeferredEagerTest < Minitest::Test | ||
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION | ||
TEST_RACK_APP = "../fake_app/basic_rack.rb" | ||
|
||
def setup | ||
super | ||
Coverband::Collectors::Coverage.instance.reset_instance | ||
Coverband.configure do |config| | ||
config.background_reporting_enabled = false | ||
config.track_gems = true | ||
config.defer_eager_loading_data = true | ||
config.send_deferred_eager_loading_data = false | ||
end | ||
Coverband.start | ||
Coverband::Collectors::Coverage.instance.eager_loading! | ||
@rack_file = require_unique_file "fake_app/basic_rack.rb" | ||
Coverband.report_coverage | ||
Coverband::Collectors::Coverage.instance.runtime! | ||
end | ||
|
||
test "call app" do | ||
# eager loaded class coverage starts empty | ||
Coverband.eager_loading_coverage! | ||
expected = {} | ||
assert_equal expected, Coverband.configuration.store.coverage | ||
|
||
Coverband::Collectors::Coverage.instance.runtime! | ||
request = Rack::MockRequest.env_for("/anything.json") | ||
middleware = Coverband::BackgroundMiddleware.new(fake_app_with_lines) | ||
results = middleware.call(request) | ||
assert_equal "Hello Rack!", results.last | ||
Coverband.report_coverage | ||
expected = [nil, nil, 0, nil, 0, 0, 1, nil, nil] | ||
assert_equal expected, Coverband.configuration.store.coverage[@rack_file]["data"] | ||
|
||
# eager loaded class coverage is skipped at first normal coverage report | ||
Coverband.eager_loading_coverage! | ||
expected = {} | ||
assert_equal expected, Coverband.configuration.store.coverage | ||
end | ||
|
||
private | ||
|
||
def fake_app_with_lines | ||
@fake_app_with_lines ||= ::HelloWorld.new | ||
end | ||
end |