File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
lib/puppet/indirector/catalog
spec/unit/indirector/catalog Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ def find(request)
1313
1414 session = Puppet . lookup ( :http_session )
1515 api = session . route_to ( :puppet )
16+
17+ ip_address = begin
18+ " (#{ Resolv . getaddress ( api . url . host ) } )"
19+ rescue Resolv ::ResolvError
20+ nil
21+ end
22+ Puppet . notice ( "Requesting catalog from #{ api . url . host } :#{ api . url . port } #{ ip_address } " )
23+
1624 _ , catalog = api . post_catalog (
1725 request . key ,
1826 facts : request . options [ :facts_for_catalog ] ,
Original file line number Diff line number Diff line change @@ -25,6 +25,23 @@ def catalog_response(catalog)
2525 expect ( described_class . indirection . find ( certname ) ) . to be_a ( Puppet ::Resource ::Catalog )
2626 end
2727
28+ it 'logs a notice when requesting a catalog' do
29+ expect ( Puppet ) . to receive ( :notice ) . with ( "Requesting catalog from compiler.example.com:8140" )
30+
31+ stub_request ( :post , uri ) . to_return ( **catalog_response ( catalog ) )
32+
33+ described_class . indirection . find ( certname )
34+ end
35+
36+ it 'logs a notice when the IP address is resolvable when requesting a catalog' do
37+ allow ( Resolv ) . to receive_message_chain ( :getaddress ) . and_return ( '192.0.2.0' )
38+ expect ( Puppet ) . to receive ( :notice ) . with ( "Requesting catalog from compiler.example.com:8140 (192.0.2.0)" )
39+
40+ stub_request ( :post , uri ) . to_return ( **catalog_response ( catalog ) )
41+
42+ described_class . indirection . find ( certname )
43+ end
44+
2845 it "serializes the environment" do
2946 stub_request ( :post , uri )
3047 . with ( query : hash_including ( 'environment' => 'outerspace' ) )
You can’t perform that action at this time.
0 commit comments