diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3440743a..d7653745 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,4 +88,10 @@ jobs: done cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure - name: Test - run: bundle exec rake test TESTOPTS='--profile=5' + run: AR_LOG=summary bundle exec rake test TESTOPTS='--stackprof=tmp/stackprof.dump --profile-setup --profile=5 --verbose' + - name: Upload test information + uses: actions/upload-artifact@v4 + if: always() + with: + name: crdb-${{ matrix.crdb }}_ruby-${{ matrix.ruby }}_test_information + path: tmp/* diff --git a/Gemfile b/Gemfile index d6a46056..13a74f58 100644 --- a/Gemfile +++ b/Gemfile @@ -58,6 +58,8 @@ group :development, :test do gem "minitest-github_action_reporter", github: "BuonOmo/minitest-github_action_reporter", require: "minitest/github_action_reporter_plugin" gem "ostruct", "~> 0.6" + gem "minitest-stackprof" + # Gems used for tests meta-programming. gem "parser" diff --git a/bin/start-cockroachdb b/bin/start-cockroachdb index a4268c37..1b8063bf 100755 --- a/bin/start-cockroachdb +++ b/bin/start-cockroachdb @@ -6,7 +6,7 @@ die() { echo "$0: $*" 1>&2 ; false; } root_dir="$(dirname $(dirname "$0:A"))" pid_file="$root_dir/tmp/cockroach.pid" -log_file="$root_dir/tmp/cockroachdb.log" +log_file="$root_dir/tmp/cockroach.log" mkdir -p "$root_dir/tmp" [[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file") || true diff --git a/test/cases/helper_cockroachdb.rb b/test/cases/helper_cockroachdb.rb index 04d7321e..1acc8cb1 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -222,3 +222,9 @@ def header(stream) class BaseCompatibilityTest < ActiveRecord::TestCase self.use_transactional_tests = false end + +FileUtils.mkdir_p("tmp") + +# require "stackprof" +# StackProf.start(mode: :wall, interval: 1000, out: "tmp/stackprof.dump", raw: true) +# Minitest.after_run { StackProf.stop; StackProf.results("tmp/stackprof.dump") } diff --git a/test/support/sql_logger.rb b/test/support/sql_logger.rb index e548e05e..d33bda49 100644 --- a/test/support/sql_logger.rb +++ b/test/support/sql_logger.rb @@ -21,9 +21,9 @@ def summary_log time = detail.values.sum { |(total, _, _)| total } / 1_000 count = detail.values.sum { |(_, _, count)| count } puts "Total time spent in SQL: #{time}s (#{count} queries)" - puts "Detail per query kind available in tmp/query_time.json (total time in ms, avg time in ms, query count). Sorted by avg time." + puts "Detail per query kind available in #{Dir.pwd}/tmp/query_time.json (total time in ms, avg time in ms, query count). Sorted by avg time." File.write( - "tmp/query_time.json", + Dir.pwd + "/tmp/query_time.json", JSON.pretty_generate(detail) ) }