From 41aaadca29aa71d4343d07ba69ada04683e8e2fc Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Thu, 9 Jan 2025 13:35:56 +0100 Subject: [PATCH 1/3] verbose test --- .github/workflows/ci.yml | 14 +++++++++++++- Gemfile | 2 ++ test/cases/helper_cockroachdb.rb | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3440743a..26d2c307 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,4 +88,16 @@ 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='--profile=5 --verbose' + - name: Upload queries file + uses: actions/upload-artifact@v3 + if: always() + with: + name: query_time.json + path: tmp/query_time.json + - name: Upload stackprof dump + uses: actions/upload-artifact@v3 + if: always() + with: + name: stackprof.dump + path: tmp/stackprof.dump diff --git a/Gemfile b/Gemfile index d6a46056..19cfb0d4 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 "stackprof" + # Gems used for tests meta-programming. gem "parser" diff --git a/test/cases/helper_cockroachdb.rb b/test/cases/helper_cockroachdb.rb index 04d7321e..7da01e61 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -222,3 +222,7 @@ def header(stream) class BaseCompatibilityTest < ActiveRecord::TestCase self.use_transactional_tests = false end + +require "stackprof" +StackProf.start(mode: :wall, interval: 1000) +Minitest.after_run { StackProf.stop; StackProf.results("tmp/stackprof.dump") } From fe3c598cb4c9c79d7ded99cf8f757013fb1a2d3c Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Tue, 21 Jan 2025 18:04:08 +0100 Subject: [PATCH 2/3] tmp --- .github/workflows/ci.yml | 14 ++++---------- bin/start-cockroachdb | 2 +- test/cases/helper_cockroachdb.rb | 3 ++- test/support/sql_logger.rb | 4 ++-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26d2c307..0327d983 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,15 +89,9 @@ jobs: cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure - name: Test run: AR_LOG=summary bundle exec rake test TESTOPTS='--profile=5 --verbose' - - name: Upload queries file - uses: actions/upload-artifact@v3 + - name: Upload test information + uses: actions/upload-artifact@v4 if: always() with: - name: query_time.json - path: tmp/query_time.json - - name: Upload stackprof dump - uses: actions/upload-artifact@v3 - if: always() - with: - name: stackprof.dump - path: tmp/stackprof.dump + name: crdb-${{ matrix.crdb }}_ruby-${{ matrix.ruby }}_test_information + path: tmp/* 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 7da01e61..d0f91d37 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -224,5 +224,6 @@ class BaseCompatibilityTest < ActiveRecord::TestCase end require "stackprof" -StackProf.start(mode: :wall, interval: 1000) +FileUtils.mkdir_p("tmp") +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) ) } From 7f069f2f74bb52c4a2b51e07bce1f1c21184b5fc Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Wed, 22 Jan 2025 11:29:38 +0100 Subject: [PATCH 3/3] correct stackprof --- .github/workflows/ci.yml | 2 +- Gemfile | 2 +- test/cases/helper_cockroachdb.rb | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0327d983..d7653745 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: done cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure - name: Test - run: AR_LOG=summary bundle exec rake test TESTOPTS='--profile=5 --verbose' + 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() diff --git a/Gemfile b/Gemfile index 19cfb0d4..13a74f58 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,7 @@ 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 "stackprof" + gem "minitest-stackprof" # Gems used for tests meta-programming. gem "parser" diff --git a/test/cases/helper_cockroachdb.rb b/test/cases/helper_cockroachdb.rb index d0f91d37..1acc8cb1 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -223,7 +223,8 @@ class BaseCompatibilityTest < ActiveRecord::TestCase self.use_transactional_tests = false end -require "stackprof" FileUtils.mkdir_p("tmp") -StackProf.start(mode: :wall, interval: 1000, out: "tmp/stackprof.dump", raw: true) -Minitest.after_run { StackProf.stop; StackProf.results("tmp/stackprof.dump") } + +# require "stackprof" +# StackProf.start(mode: :wall, interval: 1000, out: "tmp/stackprof.dump", raw: true) +# Minitest.after_run { StackProf.stop; StackProf.results("tmp/stackprof.dump") }