#!/usr/bin/ruby

def run(cmd)
  puts cmd
  if !system(cmd)
    STDERR.puts "Command failed. Exiting."
    exit 1
  end
end

run("docker run --name=rubygems -d rubygems")
run("docker run --name=api.rubygems -d api.rubygems")
run("docker run --name=obs -d obs")
sleep 3

run("docker run --link rubygems:rubygems.org --link api.rubygems:api.rubygems.org --link obs:api.opensuse.org client")

run("docker kill rubygems")
run("docker kill api.rubygems")
run("docker kill obs")

run("docker rm rubygems")
run("docker rm api.rubygems")
run("docker rm obs")

puts "Success."

#!/usr/bin/ruby

def run(cmd)
  puts cmd
  if !system(cmd)
    STDERR.puts "Command failed. Exiting."
    exit 1
  end
end

servers = {
  "rubygems" => "rubygems.org",
  "api.rubygems" => "api.rubygems.org",
  "obs" => "api.opensuse.org"
}

servers.keys.each do |name|
  run("docker run --name=#{name} -d #{name}")
end
sleep 3

links = servers.map { |name, server| "--link #{name}:#{server}" }.join(" ")
run("docker run #{links} client")

servers.keys.each do |name|
  run("docker kill #{name}")
  run("docker rm #{name}")
end

puts "Success."

Clean up test runner script
Clean up test runner script
