A platform for community discussion. Free, open, simple.
DEV: Update bench.rb for core changes (#8670)
David Taylorfd6fbaa4ae73
diff --git a/script/bench.rb b/script/bench.rbindex 44645f5549b..02b96866579 100644--- a/script/bench.rb+++ b/script/bench.rb@@ -184,7 +184,7 @@ puts "Populating Profile DB"run("bundle exec ruby script/profile_db_generator.rb")puts "Getting api key"-api_key = `bundle exec rake api_key:get_or_create_master[bench]`.split("\n")[-1]+api_key = `bundle exec rake api_key:create_master[bench]`.split("\n")[-1]def bench(path, name)puts "Running apache bench warmup"@@ -225,22 +225,32 @@ beginendputs "Starting benchmark..."- append = "?api_key=#{api_key}&api_username=admin1"+ headers = { 'Api-Key' => api_key,+ 'Api-Username' => "admin1" }# asset precompilation is a dog, wget to force itrun "wget http://127.0.0.1:#{@port}/ -o /dev/null -O /dev/null"+ redirect_response = `curl -s -I "http://127.0.0.1:#{@port}/t/i-am-a-topic-used-for-perf-tests"`+ if redirect_response !~ /301 Moved Permanently/+ raise "Unable to locate topic for perf tests"+ end++ topic_url = redirect_response.match(/^location: .+(\/t\/i-am-a-topic-used-for-perf-tests\/.+)$/i)[1].strip+tests = [["categories", "/categories"],["home", "/"],- ["topic", "/t/i-am-a-topic-used-for-perf-tests/179"]+ ["topic", topic_url]# ["user", "/u/admin1/activity"],]- tests.concat(tests.map { |k, url| ["#{k}_admin", "#{url}#{append}"] })+ tests.concat(tests.map { |k, url| ["#{k}_admin", "#{url}", headers] })++ tests.each do |_, path, headers_for_path|+ header_string = headers_for_path&.map { |k, v| "-H \"#{k}: #{v}\"" }&.join(" ")- tests.each do |_, path|- if `curl -s -I "http://127.0.0.1:#{@port}#{path}"` !~ /200 OK/+ if `curl -s -I "http://127.0.0.1:#{@port}#{path}" #{header_string}` !~ /200 OK/raise "#{path} returned non 200 response code"endend@@ -311,12 +321,12 @@ beginif @mem_statsputs- puts open("http://127.0.0.1:#{@port}/admin/memory_stats#{append}").read+ puts open("http://127.0.0.1:#{@port}/admin/memory_stats", headers).readendif @dump_heapputs- puts open("http://127.0.0.1:#{@port}/admin/dump_heap#{append}").read+ puts open("http://127.0.0.1:#{@port}/admin/dump_heap", headers).readendif @result_filediff --git a/script/profile_db_generator.rb b/script/profile_db_generator.rbindex d356a0b6907..d2d459246fd 100644--- a/script/profile_db_generator.rb+++ b/script/profile_db_generator.rb@@ -65,7 +65,7 @@ unless Rails.env == "profile"enddef ensure_perf_test_topic_has_right_title!- t = Topic.find(179)+ t = Topic.where(archetype: :regular).lastt.title = "I am a topic used for perf tests"t.save! if t.title_changed?end