Sha256: 6a1957912f52730657a84545b78da7f9fa68f17b850b765c36a1b059f50509dd

Contents?: true

Size: 1.6 KB

Versions: 13

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 2
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

13 entries across 13 versions & 1 rubygems

Version Path
pact_broker-2.15.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.14.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.13.1 db/test/backwards_compatibility/Rakefile
pact_broker-2.13.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.12.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.11.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.10.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.9.0 db/test/backwards_compatibility/Rakefile
pact_broker-2.9.0.beta.5 db/test/backwards_compatibility/Rakefile
pact_broker-2.8.0.beta.5 db/test/backwards_compatibility/Rakefile
pact_broker-2.8.0.beta.4 db/test/backwards_compatibility/Rakefile
pact_broker-2.7.0.beta.3 db/test/backwards_compatibility/Rakefile
pact_broker-2.7.0.beta.2 db/test/backwards_compatibility/Rakefile