Sha256: 2255e6097d932ab3694667aca9d69661e0c3138b6c7941db105486fa5e869786

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

def colorize(text, color_code)
  puts "\033[#{color_code}m#{text}\033[0m"
end

{
  :red      => 31,
  :green    => 32,
  :yellow   => 33
}.each do |key, color_code|
  define_method key do |text|
    colorize(text, color_code)
  end
end

namespace :acceptance do

  desc "Run full acceptance suite"
  task :full => [:check_env, :run_full]

  desc "Run smoke tests"
  task :smoke => [:check_env, :run_smoke]

  desc "shows components that can be tested separately"
  task :components do
    exec("bundle exec vagrant-spec components")
  end

  desc "checks if environment variables are set"
  task :check_env do
    yellow "NOTE: For acceptance tests to be functional, correct ssh key needs to be added to GCE metadata."

    if !ENV["GOOGLE_JSON_KEY_LOCATION"] && !ENV["GOOGLE_KEY_LOCATION"]
      abort ("Environment variables GOOGLE_JSON_KEY_LOCATION or GOOGLE_KEY_LOCATION are not set. Aborting.")
    end

    unless ENV["GOOGLE_PROJECT_ID"]
      abort ("Environment variable GOOGLE_PROJECT_ID is not set. Aborting.")
    end

    unless ENV["GOOGLE_CLIENT_EMAIL"]
      abort ("Environment variable GOOGLE_CLIENT_EMAIL is not set. Aborting.")
    end

    unless ENV["GOOGLE_SSH_USER"]
      puts "WARNING: GOOGLE_SSH_USER variable is not set. Will try to start tests using insecure Vagrant private key."
    end
  end

  task :run_full do
    components = %w(
      halt
      multi_instance
      preemptible
      reload
      scopes
      provisioner/shell
      provisioner/chef-solo
    ).map{ |s| "provider/google/#{s}" }

    command = "bundle exec vagrant-spec test --components=#{components.join(" ")}"
    puts command
    puts
    exec(command)
  end

  task :run_smoke do
    components = %w(
      provisioner/shell
    ).map{ |s| "provider/google/#{s}" }

    command = "bundle exec vagrant-spec test --components=#{components.join(" ")}"
    puts command
    puts
    exec(command)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-google-0.2.3 tasks/acceptance.rake
vagrant-google-0.2.2 tasks/acceptance.rake