2012-10-29 12:14:42 -04:00
ENV [ 'FOG_RC' ] = ENV [ 'FOG_RC' ] || File . expand_path ( '../.fog' , __FILE__ )
ENV [ 'FOG_CREDENTIAL' ] = ENV [ 'FOG_CREDENTIAL' ] || 'default'
2012-10-18 20:14:23 -04:00
2011-01-10 01:12:48 -05:00
require 'fog'
2014-12-09 18:01:43 -05:00
require 'fog/bin' # for available_providers and registered_providers
2010-11-04 14:12:44 -04:00
2013-06-05 15:46:52 -04:00
Excon . defaults . merge! ( :debug_request = > true , :debug_response = > true )
2011-02-05 12:28:36 -05:00
require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , 'helpers' , 'mock_helper' ) )
2010-11-21 09:02:34 -05:00
2014-02-19 04:34:00 -05:00
# This overrides the default 600 seconds timeout during live test runs
if Fog . mocking?
FOG_TESTING_TIMEOUT = ENV [ 'FOG_TEST_TIMEOUT' ] || 2000
Fog . timeout = 2000
Fog :: Logger . warning " Setting default fog timeout to #{ Fog . timeout } seconds "
2014-12-10 17:24:22 -05:00
# These sets of tests do not behave nicely when running mocked tests
Thread . current [ :tags ] << '-xenserver'
Thread . current [ :tags ] << '-joyent'
Thread . current [ :tags ] << '-dreamhost'
2014-02-19 04:34:00 -05:00
else
FOG_TESTING_TIMEOUT = Fog . timeout
end
2011-01-21 20:42:56 -05:00
def lorem_file
File . open ( File . dirname ( __FILE__ ) + '/lorem.txt' , 'r' )
2011-01-14 14:01:02 -05:00
end
2011-10-26 10:08:48 -04:00
def array_differences ( array_a , array_b )
( array_a - array_b ) | ( array_b - array_a )
end
2010-11-22 20:49:27 -05:00
# check to see which credentials are available and add others to the skipped tags list
2012-08-15 12:24:17 -04:00
all_providers = Fog . registered_providers . map { | provider | provider . downcase }
# Manually remove these providers since they are local applications, not lacking credentials
2015-04-17 08:55:48 -04:00
all_providers = all_providers - [ " openvz " ]
2012-08-15 12:24:17 -04:00
2011-05-24 20:31:05 -04:00
available_providers = Fog . available_providers . map { | provider | provider . downcase }
2012-08-15 12:24:17 -04:00
unavailable_providers = all_providers - available_providers
2013-12-26 06:45:19 -05:00
if ! ENV [ 'PROVIDER' ] . nil? && unavailable_providers . include? ( ENV [ 'PROVIDER' ] )
2015-01-16 19:14:58 -05:00
Fog :: Formatador . display_line ( " [red]Requested provider #{ ENV [ 'PROVIDER' ] } is not available.[/] " +
2013-12-26 06:45:19 -05:00
" [red]Check if .fog file has correct configuration (see ' #{ Fog . credentials_path } ')[/] " )
exit ( 0 )
end
2012-08-15 12:24:17 -04:00
for provider in unavailable_providers
2015-01-16 19:14:58 -05:00
Fog :: Formatador . display_line ( " [yellow]Skipping tests for [bold] #{ provider } [/] [yellow]due to lacking credentials (add some to ' #{ Fog . credentials_path } ' to run them)[/] " )
2010-11-22 20:49:27 -05:00
end