Sha256: 81579127a99ccff1d360f92965e9cf764a05be920c46ba278ef1687e074bc201

Contents?: true

Size: 1.6 KB

Versions: 12

Compression:

Stored size: 1.6 KB

Contents

require "rspec/core"
require "rspec/core/rake_task"
require "open-uri"

TESTS = [
  %w{2.1.0 9293},
  %w{2.2.0 9294},
  %w{2.3.0 9295},
  %w{2.4.2 9296},
  %w{2.5.1 9297},
  %w{2.6.0 9298},
  %w{head  9299}
]

DATABASE_VERSION = TESTS.first.first

def start_pact_broker code_version, port
  Bundler.with_clean_env do
    command = "bundle exec appraisal #{code_version} rackup -p #{port}"
    puts command
    IO.popen(command)
  end
  sleep 4
end

def kill_servers
  Dir.chdir("pids") { Dir.glob("*") }.collect(&:to_i).each do | pid |
    begin
      puts "Killing broker with pid #{pid}"
      Process.kill "KILL", pid
    rescue Errno::ESRCH
      puts "Process with pid #{pid} already killed"
    end
  end
  sleep 2
end

def clean
  require "fileutils"
  FileUtils.rm_rf "pids"
  FileUtils.mkdir "pids"
  FileUtils.rm_rf "pact_broker_database.sqlite3"
  FileUtils.rm_rf "log"
end

RSpec::Core::RakeTask.new(:spec) do |task|
  task.pattern = "spec/**/*_spec.rb"
end

desc "Ensure code from previous versions is compatible with latest database"
task "db:check_backwards_compatibility" do
  ENV["PACT_BROKER_DATABASE_VERSION"] = DATABASE_VERSION
  clean
  begin
    TESTS.each do | (code_version, port) |
      start_pact_broker code_version, port
    end

    # All the brokers must be started before we run the tests
    # so that we have the latest version of the db running

    TESTS.each do | (code_version, port) |
      ENV["PACT_BROKER_CODE_VERSION"] = code_version
      ENV["PORT"] = port
      Rake::Task["spec"].execute
    end
  ensure
    kill_servers
  end
end

task :default => ["db:check_backwards_compatibility"]

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pact_broker-2.89.1 db/test/backwards_compatibility/Rakefile
pact_broker-2.89.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.88.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.87.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.86.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.85.1 db/test/backwards_compatibility/Rakefile
pact_broker-2.85.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.84.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.83.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.82.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.81.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.80.0 db/test/backwards_compatibility/Rakefile