Sha256: baacfadcb87d17875f23e905b3bea4abb2e23e02ec527cc8725b9bd78f845cdc

Contents?: true

Size: 1.6 KB

Versions: 95

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

95 entries across 95 versions & 1 rubygems

Version Path
pact_broker-2.36.1 db/test/backwards_compatibility/Rakefile
pact_broker-2.36.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.35.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.34.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.33.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.32.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.31.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.30.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.29.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.27.6 db/test/backwards_compatibility/Rakefile
pact_broker-2.27.5 db/test/backwards_compatibility/Rakefile
pact_broker-2.27.4 db/test/backwards_compatibility/Rakefile
pact_broker-2.27.3 db/test/backwards_compatibility/Rakefile
pact_broker-2.27.2 db/test/backwards_compatibility/Rakefile
pact_broker-2.27.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.26.1 db/test/backwards_compatibility/Rakefile
pact_broker-2.26.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.25.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.24.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.23.4 db/test/backwards_compatibility/Rakefile