From 7e10579aca523020e6f9feaab328ede7ac163922 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 22 Jan 2024 15:50:04 -0700 Subject: [PATCH] add task for downloading benchmark data files --- profile/driver_bench/rake/tasks.rake | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/profile/driver_bench/rake/tasks.rake b/profile/driver_bench/rake/tasks.rake index 486051a6e2..b9e148df35 100644 --- a/profile/driver_bench/rake/tasks.rake +++ b/profile/driver_bench/rake/tasks.rake @@ -2,7 +2,37 @@ require_relative '../suite' -desc 'Runs the DriverBench benchmark suite' -task :driver_bench do - Mongo::DriverBench::Suite.run! +task driver_bench: %i[ driver_bench:data driver_bench:run ] + +SPECS_REPO_URI = 'git@github.com:mongodb/specifications.git' +SPECS_PATH = File.expand_path('../../../specifications', __dir__) +DRIVER_BENCH_DATA = File.expand_path('../../data/driver_bench', __dir__) + +namespace :driver_bench do + desc 'Downloads the DriverBench data files, if necessary' + task :data do + if File.directory?('./profile/data/driver_bench') + puts 'DriverBench data files are already downloaded' + next + end + + if File.directory?(SPECS_PATH) + puts 'specifications repo is already checked out' + else + sh 'git', 'clone', SPECS_REPO_URI + end + + mkdir_p DRIVER_BENCH_DATA + + Dir.glob(File.join(SPECS_PATH, 'source/benchmarking/data/*.tgz')) do |archive| + Dir.chdir(DRIVER_BENCH_DATA) do + sh 'tar', 'xzf', archive + end + end + end + + desc 'Runs the DriverBench benchmark suite' + task :run do + Mongo::DriverBench::Suite.run! + end end