appmap 0.37.0 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +1 -1
- data/.rubocop.yml +12 -1
- data/.travis.yml +2 -23
- data/CHANGELOG.md +24 -0
- data/CONTRIBUTING.md +22 -0
- data/README.md +79 -50
- data/Rakefile +3 -3
- data/lib/appmap/class_map.rb +25 -8
- data/lib/appmap/config.rb +22 -10
- data/lib/appmap/event.rb +16 -1
- data/lib/appmap/hook.rb +11 -3
- data/lib/appmap/hook/method.rb +18 -12
- data/lib/appmap/rails/request_handler.rb +25 -4
- data/lib/appmap/railtie.rb +1 -5
- data/lib/appmap/trace.rb +18 -7
- data/lib/appmap/version.rb +2 -2
- data/spec/abstract_controller_base_spec.rb +132 -67
- data/spec/fixtures/hook/instance_method.rb +4 -0
- data/spec/fixtures/hook/labels.rb +6 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.dockerignore +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.gitignore +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.rspec +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.ruby-version +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile.pg +0 -0
- data/spec/fixtures/rails5_users_app/Gemfile +50 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Rakefile +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/api/users_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/application_controller.rb +0 -0
- data/spec/fixtures/{rails4_users_app/app/assets/images → rails5_users_app/app/controllers/concerns}/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/health_controller.rb +0 -0
- data/spec/fixtures/rails5_users_app/app/controllers/users_controller.rb +13 -0
- data/spec/fixtures/{rails4_users_app/app/models → rails5_users_app/app/models/activerecord}/user.rb +0 -0
- data/spec/fixtures/{rails4_users_app/app/controllers → rails5_users_app/app/models}/concerns/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/sequel/user.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/app/views/layouts/application.html.haml +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/app/views/users/index.html.haml +0 -0
- data/spec/fixtures/rails5_users_app/appmap.yml +4 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/appmap +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/byebug +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/gli +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/htmldiff +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ldiff +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/nokogiri +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rackup +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rails +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rake +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rspec +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-parse +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-rewrite +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sequel +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/setup +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sprockets +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/thor +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/update +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config.ru +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/application.rb +2 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/boot.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/credentials.yml.enc +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/database.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environment.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/development.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/production.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/test.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/application_controller_renderer.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/cors.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/config/initializers/filter_parameter_logging.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/config/initializers/inflections.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/config/initializers/mime_types.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/record_button.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/wrap_parameters.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/locales/en.yml +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/config/routes.rb +1 -2
- data/spec/fixtures/{rails_users_app → rails5_users_app}/create_app +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/db/migrate/20190728211408_create_users.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/db/schema.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/docker-compose.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/api_users.feature +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/env.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/hooks.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/steps.rb +0 -0
- data/spec/fixtures/{rails4_users_app/app/mailers → rails5_users_app/lib/tasks}/.keep +0 -0
- data/spec/fixtures/{rails4_users_app/app/models → rails5_users_app/log}/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/public/robots.txt +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/controllers/users_controller_api_spec.rb +1 -1
- data/spec/fixtures/rails5_users_app/spec/controllers/users_controller_spec.rb +27 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/models/user_spec.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/rails_helper.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails5_users_app}/spec/spec_helper.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/users_app/.gitignore +0 -0
- data/spec/fixtures/rails6_users_app/.dockerignore +1 -0
- data/spec/fixtures/rails6_users_app/.gitignore +39 -0
- data/spec/fixtures/rails6_users_app/.rspec +1 -0
- data/spec/fixtures/rails6_users_app/.ruby-version +1 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/Dockerfile +3 -4
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/Dockerfile.pg +1 -1
- data/spec/fixtures/{rails_users_app → rails6_users_app}/Gemfile +3 -4
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/Rakefile +1 -1
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/app/controllers/api/users_controller.rb +1 -1
- data/spec/fixtures/rails6_users_app/app/controllers/application_controller.rb +2 -0
- data/spec/fixtures/{rails4_users_app/app/models → rails6_users_app/app/controllers}/concerns/.keep +0 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/app/controllers/health_controller.rb +1 -1
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +13 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/app/models/activerecord/user.rb +0 -0
- data/spec/fixtures/{rails4_users_app/lib/assets → rails6_users_app/app/models/concerns}/.keep +0 -0
- data/spec/fixtures/rails6_users_app/app/models/sequel/user.rb +25 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/app/views/layouts/application.html.haml +0 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/app/views/users/index.html.haml +0 -0
- data/spec/fixtures/rails6_users_app/appmap.yml +5 -0
- data/spec/fixtures/rails6_users_app/bin/appmap +29 -0
- data/spec/fixtures/rails6_users_app/bin/byebug +29 -0
- data/spec/fixtures/rails6_users_app/bin/gli +29 -0
- data/spec/fixtures/rails6_users_app/bin/htmldiff +29 -0
- data/spec/fixtures/rails6_users_app/bin/ldiff +29 -0
- data/spec/fixtures/rails6_users_app/bin/nokogiri +29 -0
- data/spec/fixtures/rails6_users_app/bin/rackup +29 -0
- data/spec/fixtures/rails6_users_app/bin/rails +4 -0
- data/spec/fixtures/rails6_users_app/bin/rake +29 -0
- data/spec/fixtures/rails6_users_app/bin/rspec +29 -0
- data/spec/fixtures/rails6_users_app/bin/ruby-parse +29 -0
- data/spec/fixtures/rails6_users_app/bin/ruby-rewrite +29 -0
- data/spec/fixtures/rails6_users_app/bin/sequel +29 -0
- data/spec/fixtures/rails6_users_app/bin/setup +25 -0
- data/spec/fixtures/rails6_users_app/bin/sprockets +29 -0
- data/spec/fixtures/rails6_users_app/bin/thor +29 -0
- data/spec/fixtures/rails6_users_app/bin/update +25 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config.ru +2 -1
- data/spec/fixtures/rails6_users_app/config/application.rb +53 -0
- data/spec/fixtures/rails6_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails6_users_app/config/credentials.yml.enc +1 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config/database.yml +2 -2
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config/environment.rb +1 -1
- data/spec/fixtures/rails6_users_app/config/environments/development.rb +40 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config/environments/production.rb +19 -30
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config/environments/test.rb +5 -11
- data/spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/fixtures/rails6_users_app/config/initializers/cors.rb +16 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/config/initializers/filter_parameter_logging.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/config/initializers/inflections.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/config/initializers/mime_types.rb +0 -0
- data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +3 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config/initializers/wrap_parameters.rb +1 -6
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/config/locales/en.yml +10 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/config/routes.rb +1 -1
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/create_app +7 -3
- data/spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb +9 -0
- data/spec/fixtures/rails6_users_app/db/schema.rb +23 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/docker-compose.yml +3 -1
- data/spec/fixtures/rails6_users_app/features/api_users.feature +13 -0
- data/spec/fixtures/rails6_users_app/features/support/env.rb +4 -0
- data/spec/fixtures/rails6_users_app/features/support/hooks.rb +11 -0
- data/spec/fixtures/rails6_users_app/features/support/steps.rb +18 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/lib/tasks/.keep +0 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/log/.keep +0 -0
- data/spec/fixtures/rails6_users_app/public/robots.txt +1 -0
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_spec.rb +27 -0
- data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +39 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app}/spec/rails_helper.rb +3 -32
- data/spec/fixtures/{rails_users_app → rails6_users_app}/spec/spec_helper.rb +0 -0
- data/spec/fixtures/{rails4_users_app → rails6_users_app/users_app}/.gitignore +8 -1
- data/spec/hook_spec.rb +111 -57
- data/spec/rails_spec_helper.rb +5 -5
- data/spec/railtie_spec.rb +31 -32
- data/spec/record_sql_rails_pg_spec.rb +62 -63
- data/spec/remote_recording_spec.rb +90 -89
- data/spec/rspec_feature_metadata_spec.rb +17 -18
- data/spec/spec_helper.rb +1 -0
- metadata +148 -139
- data/spec/abstract_controller4_base_spec.rb +0 -67
- data/spec/fixtures/rails4_users_app/.rbenv-gemsets +0 -2
- data/spec/fixtures/rails4_users_app/.ruby-version +0 -1
- data/spec/fixtures/rails4_users_app/Gemfile +0 -77
- data/spec/fixtures/rails4_users_app/README.rdoc +0 -28
- data/spec/fixtures/rails4_users_app/app/assets/javascripts/application.js +0 -16
- data/spec/fixtures/rails4_users_app/app/assets/stylesheets/application.css +0 -15
- data/spec/fixtures/rails4_users_app/app/controllers/application_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/controllers/users_controller.rb +0 -5
- data/spec/fixtures/rails4_users_app/app/helpers/application_helper.rb +0 -2
- data/spec/fixtures/rails4_users_app/appmap.yml +0 -3
- data/spec/fixtures/rails4_users_app/bin/rails +0 -9
- data/spec/fixtures/rails4_users_app/bin/setup +0 -29
- data/spec/fixtures/rails4_users_app/bin/spring +0 -17
- data/spec/fixtures/rails4_users_app/config/application.rb +0 -26
- data/spec/fixtures/rails4_users_app/config/boot.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/environments/development.rb +0 -41
- data/spec/fixtures/rails4_users_app/config/initializers/assets.rb +0 -11
- data/spec/fixtures/rails4_users_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/initializers/session_store.rb +0 -3
- data/spec/fixtures/rails4_users_app/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/fixtures/rails4_users_app/config/secrets.yml +0 -22
- data/spec/fixtures/rails4_users_app/db/migrate/20191127112304_create_users.rb +0 -10
- data/spec/fixtures/rails4_users_app/db/schema.rb +0 -26
- data/spec/fixtures/rails4_users_app/db/seeds.rb +0 -7
- data/spec/fixtures/rails4_users_app/public/404.html +0 -67
- data/spec/fixtures/rails4_users_app/public/422.html +0 -67
- data/spec/fixtures/rails4_users_app/public/500.html +0 -66
- data/spec/fixtures/rails4_users_app/public/favicon.ico +0 -0
- data/spec/fixtures/rails4_users_app/public/robots.txt +0 -5
- data/spec/fixtures/rails4_users_app/spec/controllers/users_controller_api_spec.rb +0 -49
- data/spec/fixtures/rails4_users_app/test/fixtures/users.yml +0 -9
- data/spec/fixtures/rails_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/controllers/users_controller.rb +0 -5
- data/spec/fixtures/rails_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/appmap.yml +0 -3
- data/spec/fixtures/rails_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails_users_app/log/.keep +0 -0
- data/spec/record_sql_rails4_pg_spec.rb +0 -76
data/spec/rails_spec_helper.rb
CHANGED
@@ -29,10 +29,10 @@ def run_cmd(*cmd, &failed)
|
|
29
29
|
raise 'Command failed'
|
30
30
|
end
|
31
31
|
|
32
|
-
shared_context 'Rails app pg database' do
|
33
|
-
|
34
|
-
raise 'you must set @fixure_dir' unless @fixture_dir
|
32
|
+
shared_context 'Rails app pg database' do |fixture_dir|
|
33
|
+
define_method(:fixture_dir) { fixture_dir }
|
35
34
|
|
35
|
+
before(:all) do
|
36
36
|
print_pg_logs = lambda do
|
37
37
|
logs, = run_cmd 'docker-compose logs pg'
|
38
38
|
puts "docker-compose logs for pg:"
|
@@ -40,7 +40,7 @@ shared_context 'Rails app pg database' do
|
|
40
40
|
puts logs
|
41
41
|
end
|
42
42
|
|
43
|
-
Dir.chdir
|
43
|
+
Dir.chdir fixture_dir do
|
44
44
|
run_cmd 'docker-compose down -v'
|
45
45
|
cmd = 'docker-compose up -d pg'
|
46
46
|
run_cmd cmd
|
@@ -54,7 +54,7 @@ shared_context 'Rails app pg database' do
|
|
54
54
|
after(:all) do
|
55
55
|
if ENV['NOKILL'] != 'true'
|
56
56
|
cmd = 'docker-compose down -v'
|
57
|
-
run_cmd cmd, chdir:
|
57
|
+
run_cmd cmd, chdir: fixture_dir
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/spec/railtie_spec.rb
CHANGED
@@ -1,43 +1,42 @@
|
|
1
1
|
require 'rails_spec_helper'
|
2
2
|
|
3
3
|
describe 'AppMap tracer via Railtie' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let(:env) { {} }
|
4
|
+
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
|
5
|
+
let(:env) { {} }
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
let(:cmd) { %(docker-compose run --rm -e RAILS_ENV -e APPMAP app ./bin/rails r "puts Rails.configuration.appmap.enabled.inspect") }
|
8
|
+
let(:command_capture2) do
|
9
|
+
require 'open3'
|
10
|
+
Open3.capture3(env, cmd, chdir: fixture_dir).tap do |result|
|
11
|
+
unless result[2] == 0
|
12
|
+
warn <<~STDERR
|
13
|
+
Failed to run rails5_users_app container
|
14
|
+
<<< Output:
|
15
|
+
#{result[0]}
|
16
|
+
#{result[1]}
|
17
|
+
>>> End of output
|
18
|
+
STDERR
|
19
|
+
raise 'Failed to run rails5_users_app container'
|
20
|
+
end
|
22
21
|
end
|
23
22
|
end
|
24
|
-
|
25
|
-
|
26
|
-
let(:command_result) { command_capture2[2] }
|
27
|
-
|
28
|
-
it 'is disabled by default' do
|
29
|
-
expect(command_output).to eq('nil')
|
30
|
-
end
|
23
|
+
let(:command_output) { command_capture2[0].strip }
|
24
|
+
let(:command_result) { command_capture2[2] }
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
it 'is enabled' do
|
35
|
-
expect(command_output.split("\n")).to include('true')
|
26
|
+
it 'is disabled by default' do
|
27
|
+
expect(command_output).to eq('nil')
|
36
28
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
29
|
+
|
30
|
+
describe 'with APPMAP=true' do
|
31
|
+
let(:env) { { 'APPMAP' => 'true' } }
|
32
|
+
it 'is enabled' do
|
33
|
+
expect(command_output.split("\n")).to include('true')
|
34
|
+
end
|
35
|
+
context 'and RAILS_ENV=test' do
|
36
|
+
let(:env) { { 'APPMAP' => 'true', 'RAILS_ENV' => 'test' } }
|
37
|
+
it 'is disabled' do
|
38
|
+
expect(command_output).to eq('nil')
|
39
|
+
end
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
@@ -1,89 +1,88 @@
|
|
1
1
|
require 'rails_spec_helper'
|
2
2
|
|
3
3
|
describe 'SQL events' do
|
4
|
-
|
5
|
-
|
4
|
+
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
|
5
|
+
around(:each) do |example|
|
6
|
+
FileUtils.rm_rf tmpdir
|
7
|
+
FileUtils.mkdir_p tmpdir
|
8
|
+
cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
|
9
|
+
run_cmd cmd, chdir: fixture_dir
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
FileUtils.mkdir_p tmpdir
|
10
|
-
cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
|
11
|
-
run_cmd cmd, chdir: @fixture_dir
|
12
|
-
|
13
|
-
example.run
|
14
|
-
end
|
11
|
+
example.run
|
12
|
+
end
|
15
13
|
|
16
|
-
|
14
|
+
let(:tmpdir) { "tmp/spec/record_sql_rails_pg_spec" }
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
describe 'fields' do
|
17
|
+
let(:test_line_number) { 8 }
|
18
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
19
|
+
let(:orm_module) { 'sequel' }
|
20
|
+
let(:appmap) { JSON.parse(File.read(appmap_json)) }
|
21
|
+
describe 'on a call event' do
|
22
|
+
let(:event) do
|
23
|
+
appmap['events'].find do |event|
|
24
|
+
event['event'] == 'call' &&
|
25
|
+
event.keys.include?('sql_query')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
it 'do not include function-only fields' do
|
29
|
+
expect(event.keys).to_not include('defined_class')
|
30
|
+
expect(event.keys).to_not include('method_id')
|
31
|
+
expect(event.keys).to_not include('path')
|
32
|
+
expect(event.keys).to_not include('lineno')
|
28
33
|
end
|
29
|
-
end
|
30
|
-
it 'do not include function-only fields' do
|
31
|
-
expect(event.keys).to_not include('defined_class')
|
32
|
-
expect(event.keys).to_not include('method_id')
|
33
|
-
expect(event.keys).to_not include('path')
|
34
|
-
expect(event.keys).to_not include('lineno')
|
35
34
|
end
|
36
35
|
end
|
37
|
-
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
describe 'in a Rails app' do
|
38
|
+
let(:appmap) { JSON.parse(File.read(appmap_json)).to_yaml }
|
39
|
+
context 'while creating a new record' do
|
40
|
+
let(:test_line_number) { 8 }
|
41
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
context 'using Sequel ORM' do
|
44
|
+
let(:orm_module) { 'sequel' }
|
45
|
+
it 'detects the sql INSERT' do
|
46
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
49
47
|
sql_query:
|
50
48
|
sql: INSERT INTO "users" ("login") VALUES ('alice') RETURNING *
|
51
|
-
|
49
|
+
SQL_QUERY
|
50
|
+
end
|
52
51
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
expect(appmap).to include(<<-SQL_QUERY.strip)
|
52
|
+
context 'using ActiveRecord ORM' do
|
53
|
+
let(:orm_module) { 'activerecord' }
|
54
|
+
it 'detects the sql INSERT' do
|
55
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
58
56
|
sql_query:
|
59
57
|
sql: INSERT INTO "users" ("login") VALUES ($1) RETURNING "id"
|
60
|
-
|
58
|
+
SQL_QUERY
|
59
|
+
end
|
61
60
|
end
|
62
61
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
expect(appmap).to include(<<-SQL_QUERY.strip)
|
62
|
+
|
63
|
+
context 'while listing records' do
|
64
|
+
let(:test_line_number) { 23 }
|
65
|
+
let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_GET_api_users_lists_the_users.appmap.json') }
|
66
|
+
|
67
|
+
context 'using Sequel ORM' do
|
68
|
+
let(:orm_module) { 'sequel' }
|
69
|
+
it 'detects the sql SELECT' do
|
70
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
73
71
|
sql_query:
|
74
72
|
sql: SELECT * FROM "users"
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
SQL_QUERY
|
74
|
+
|
75
|
+
expect(appmap).to include('sql:')
|
76
|
+
end
|
78
77
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
expect(appmap).to include(<<-SQL_QUERY.strip)
|
78
|
+
context 'using ActiveRecord ORM' do
|
79
|
+
let(:orm_module) { 'activerecord' }
|
80
|
+
it 'detects the sql SELECT' do
|
81
|
+
expect(appmap).to include(<<-SQL_QUERY.strip)
|
84
82
|
sql_query:
|
85
83
|
sql: SELECT "users".* FROM "users"
|
86
|
-
|
84
|
+
SQL_QUERY
|
85
|
+
end
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
@@ -3,115 +3,116 @@ require 'net/http'
|
|
3
3
|
require 'socket'
|
4
4
|
|
5
5
|
describe 'remote recording', :order => :defined do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
port_cmd = 'docker-compose port app 3000'
|
17
|
-
port_out, = run_cmd port_cmd, chdir: @fixture_dir
|
18
|
-
@service_port = port_out.strip.split(':')[1]
|
19
|
-
|
20
|
-
service_running = false
|
21
|
-
retry_count = 0
|
22
|
-
uri = URI("http://localhost:#{@service_port}/health")
|
6
|
+
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
|
7
|
+
before(:all) do
|
8
|
+
fixture_dir = 'spec/fixtures/rails5_users_app'
|
9
|
+
start_cmd = 'docker-compose up -d app'
|
10
|
+
run_cmd({ 'ORM_MODULE' => 'sequel', 'APPMAP' => 'true' }, start_cmd, chdir: fixture_dir)
|
11
|
+
Dir.chdir fixture_dir do
|
12
|
+
wait_for_container 'app'
|
13
|
+
end
|
23
14
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
port_cmd = 'docker-compose port app 3000'
|
16
|
+
port_out, = run_cmd port_cmd, chdir: fixture_dir
|
17
|
+
@service_port = port_out.strip.split(':')[1]
|
18
|
+
|
19
|
+
service_running = false
|
20
|
+
retry_count = 0
|
21
|
+
uri = URI("http://localhost:#{@service_port}/health")
|
22
|
+
|
23
|
+
until service_running
|
24
|
+
sleep(0.25)
|
25
|
+
begin
|
26
|
+
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
27
|
+
http.request(Net::HTTP::Get.new(uri))
|
28
|
+
end
|
29
|
+
|
30
|
+
status = res.response.code.to_i
|
31
|
+
service_running = true if status >= 200 && status < 300
|
32
|
+
|
33
|
+
# give up after a certain error threshold is met
|
34
|
+
# we don't want to wait forever if there's an unrecoverable issue
|
35
|
+
raise 'gave up waiting on fixture service' if (retry_count += 1) == 10
|
36
|
+
rescue Errno::ETIMEDOUT, Errno::ECONNRESET, EOFError
|
37
|
+
$stderr.print('.')
|
29
38
|
end
|
30
|
-
|
31
|
-
status = res.response.code.to_i
|
32
|
-
service_running = true if status >= 200 && status < 300
|
33
|
-
|
34
|
-
# give up after a certain error threshold is met
|
35
|
-
# we don't want to wait forever if there's an unrecoverable issue
|
36
|
-
raise 'gave up waiting on fixture service' if (retry_count += 1) == 10
|
37
|
-
rescue Errno::ETIMEDOUT, Errno::ECONNRESET, EOFError
|
38
|
-
$stderr.print('.')
|
39
39
|
end
|
40
40
|
end
|
41
|
-
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def json_body(res)
|
43
|
+
JSON.parse(res.body).deep_symbolize_keys
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
after(:all) do
|
47
|
+
fixture_dir = 'spec/fixtures/rails5_users_app'
|
48
|
+
run_cmd 'docker-compose rm -fs app', chdir: fixture_dir
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
let(:service_address) { URI("http://localhost:#{@service_port}") }
|
52
|
+
let(:users_path) { '/users' }
|
53
|
+
let(:record_path) { '/_appmap/record' }
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
it 'returns the recording status' do
|
56
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
57
|
+
http.request(Net::HTTP::Get.new(record_path))
|
58
|
+
}
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
expect(res).to be_a(Net::HTTPOK)
|
61
|
+
expect(res['Content-Type']).to eq('application/json')
|
62
|
+
expect(json_body(res)).to eq(enabled: false)
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
it 'starts a new recording session' do
|
66
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
67
|
+
http.request(Net::HTTP::Post.new(record_path))
|
68
|
+
}
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
expect(res).to be_a(Net::HTTPOK)
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
it 'reflects the recording status' do
|
74
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
75
|
+
http.request(Net::HTTP::Get.new(record_path))
|
76
|
+
}
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
expect(res).to be_a(Net::HTTPOK)
|
79
|
+
expect(res['Content-Type']).to eq('application/json')
|
80
|
+
expect(json_body(res)).to eq(enabled: true)
|
81
|
+
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
it 'fails to start a new recording session while recording is already active' do
|
84
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
85
|
+
http.request(Net::HTTP::Post.new(record_path))
|
86
|
+
}
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
expect(res).to be_a(Net::HTTPConflict)
|
89
|
+
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
it 'stops recording' do
|
92
|
+
# Generate some events
|
93
|
+
Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
94
|
+
http.request(Net::HTTP::Get.new(users_path) )
|
95
|
+
}
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
98
|
+
http.request(Net::HTTP::Delete.new(record_path))
|
99
|
+
}
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
expect(res).to be_a(Net::HTTPOK)
|
102
|
+
expect(res['Content-Type']).to eq('application/json')
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
data = json_body(res)
|
105
|
+
expect(data[:metadata]).to be_truthy
|
106
|
+
expect(data[:classMap].length).to be > 0
|
107
|
+
expect(data[:events].length).to be > 0
|
108
|
+
end
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
it 'fails to stop recording if there is no active recording session' do
|
111
|
+
res = Net::HTTP.start(service_address.hostname, service_address.port) { |http|
|
112
|
+
http.request(Net::HTTP::Delete.new(record_path))
|
113
|
+
}
|
114
114
|
|
115
|
-
|
115
|
+
expect(res).to be_a(Net::HTTPNotFound)
|
116
|
+
end
|
116
117
|
end
|
117
118
|
end
|