File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ class Integration
1212 def self . integration_with_puppetdb ( server_opts , opts )
1313 server_opts [ :rsa_key ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.key' ) )
1414 server_opts [ :cert ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.crt' ) )
15- test_server = SSLTestServer . new ( server_opts )
16- test_server . start
17- raise 'Unable to instantiate SSLTestServer' unless test_server . port > 0
15+ test_server = nil
16+ 3 . times do
17+ test_server = SSLTestServer . new ( server_opts )
18+ test_server . start
19+ break if test_server . port > 0
20+ end
21+ raise OctocatalogDiff ::Spec ::FixtureError , 'Unable to instantiate SSLTestServer' unless test_server . port > 0
1822 puppetdb_url_save = ENV [ 'PUPPETDB_URL' ]
1923 ENV [ 'PUPPETDB_URL' ] = "https://localhost:#{ test_server . port } "
2024 integration ( opts )
Original file line number Diff line number Diff line change @@ -11,9 +11,13 @@ def initialize(options = {})
1111 server_opts = options . dup
1212 server_opts [ :rsa_key ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.key' ) )
1313 server_opts [ :cert ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.crt' ) )
14- @test_server = SSLTestServer . new ( server_opts )
15- @test_server . start
16- raise 'Unable to instantiate SSLTestServer' unless @test_server . port > 0
14+ @test_server = nil
15+ 3 . times do
16+ @test_server = SSLTestServer . new ( server_opts )
17+ @test_server . start
18+ break if @test_server . port > 0
19+ end
20+ raise OctocatalogDiff ::Spec ::FixtureError , 'Unable to instantiate SSLTestServer' unless @test_server . port > 0
1721 end
1822
1923 def stop
Original file line number Diff line number Diff line change @@ -9,9 +9,13 @@ def initialize(options = {})
99 server_opts = options . dup
1010 server_opts [ :rsa_key ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.key' ) )
1111 server_opts [ :cert ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.crt' ) )
12- @test_server = SSLTestServer . new ( server_opts )
13- @test_server . start
14- raise 'Unable to instantiate SSLTestServer' unless @test_server . port > 0
12+ @test_server = nil
13+ 3 . times do
14+ @test_server = SSLTestServer . new ( server_opts )
15+ @test_server . start
16+ break if @test_server . port > 0
17+ end
18+ raise OctocatalogDiff ::Spec ::FixtureError , 'Unable to instantiate SSLTestServer' unless @test_server . port > 0
1519 end
1620
1721 def stop
Original file line number Diff line number Diff line change 99def ssl_test ( server_opts , opts = { } )
1010 server_opts [ :rsa_key ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.key' ) )
1111 server_opts [ :cert ] ||= File . read ( OctocatalogDiff ::Spec . fixture_path ( 'ssl/generated/server.crt' ) )
12- test_server = SSLTestServer . new ( server_opts )
13- test_server . start
14- raise 'Unable to instantiate SSLTestServer' unless test_server . port > 0
12+ test_server = nil
13+ 3 . times do
14+ test_server = SSLTestServer . new ( server_opts )
15+ test_server . start
16+ break if test_server . port > 0
17+ end
18+ raise OctocatalogDiff ::Spec ::FixtureError , 'Unable to instantiate SSLTestServer' unless test_server . port > 0
1519 testobj = OctocatalogDiff ::PuppetDB . new ( opts . merge ( puppetdb_url : "https://localhost:#{ test_server . port } " ) )
1620 return testobj . get ( '/foo' )
1721ensure
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ class Spec
3737 PUPPET_BINARY = File . expand_path ( '../../../script/puppet' , File . dirname ( __FILE__ ) ) . freeze
3838 raise "Puppet binary (#{ PUPPET_BINARY } ) is missing" unless File . file? ( PUPPET_BINARY )
3939
40+ # An error to raise if a fixture fails but code doesn't
41+ class FixtureError ; end
42+
4043 # One 'require' to rule them all. Find the code relative to the directory
4144 # of this spec file, so we can easily update this to reflect packaging changes.
4245 def self . require_path ( path )
You can’t perform that action at this time.
0 commit comments