@@ -60,29 +60,29 @@ def agent_version_inventory
6060 end
6161
6262 context "when running against puppet 5 or puppet 6" do
63- before ( :all ) do
64- # install puppet5
65- result = run_task ( 'puppet_agent::install' , 'puppet_5' , { 'collection' => 'puppet5' } ,
66- config : root_config , inventory : agent_version_inventory )
67- expect ( result . count ) . to eq ( 1 )
68- expect ( result [ 0 ] [ 'status' ] ) . to eq ( 'success' )
69-
70- result = run_task ( 'puppet_agent::version' , 'puppet_5' , inventory : agent_version_inventory )
71- expect ( result . count ) . to eq ( 1 )
72- expect ( result [ 0 ] [ 'status' ] ) . to eq ( 'success' )
73- expect ( result [ 0 ] [ 'result' ] [ 'version' ] ) . to match ( /^5/ )
74-
75- # install puppet6
76- result = run_task ( 'puppet_agent::install' , 'puppet_6' , { 'collection' => 'puppet6' } ,
77- config : root_config , inventory : agent_version_inventory )
78- expect ( result . count ) . to eq ( 1 )
79- expect ( result [ 0 ] [ 'status' ] ) . to eq ( 'success' )
80-
81- result = run_task ( 'puppet_agent::version' , 'puppet_6' , inventory : agent_version_inventory )
82- expect ( result . count ) . to eq ( 1 )
83- expect ( result [ 0 ] [ 'status' ] ) . to eq ( 'success' )
84- expect ( result [ 0 ] [ 'result' ] [ 'version' ] ) . to match ( /^6/ )
85- end
63+ # before(:all) do
64+ # # install puppet5
65+ # result = run_task('puppet_agent::install', 'puppet_5', { 'collection' => 'puppet5' },
66+ # config: root_config, inventory: agent_version_inventory)
67+ # expect(result.count).to eq(1)
68+ # expect(result[0]).to include('status' => 'success')
69+
70+ # result = run_task('puppet_agent::version', 'puppet_5', inventory: agent_version_inventory)
71+ # expect(result.count).to eq(1)
72+ # expect(result[0]['status']).to eq('success')
73+ # expect(result[0]['result']['version']).to match(/^5/)
74+
75+ # # install puppet6
76+ # result = run_task('puppet_agent::install', 'puppet_6', { 'collection' => 'puppet6' },
77+ # config: root_config, inventory: agent_version_inventory)
78+ # expect(result.count).to eq(1)
79+ # expect(result[0]['status']).to eq('success')
80+
81+ # result = run_task('puppet_agent::version', 'puppet_6', inventory: agent_version_inventory)
82+ # expect(result.count).to eq(1)
83+ # expect(result[0]['status']).to eq('success')
84+ # expect(result[0]['result']['version']).to match(/^6/)
85+ # end
8686
8787 it 'runs a ruby task' do
8888 with_tempfile_containing ( 'inventory' , YAML . dump ( agent_version_inventory ) , '.yaml' ) do |inv |
@@ -116,6 +116,47 @@ def agent_version_inventory
116116 expect ( result [ 'result' ] [ 'stdout' ] ) . to match ( /not found/ )
117117 end
118118 end
119+
120+ context "when running against device targets" do
121+ let ( :device_url ) { "file:///tmp/#{ SecureRandom . uuid } .json" }
122+ let ( :device_inventory ) do
123+ device_group = { 'name' => 'device_targets' ,
124+ 'nodes' => [
125+ { 'name' => "puppet5_device" ,
126+ 'config' => { 'remote' => { 'run-on' => 'puppet_5' } } ,
127+ } ,
128+ { 'name' => "puppet6_device" ,
129+ 'config' => { 'remote' => { 'run-on' => 'puppet_6' } } ,
130+ } ,
131+ ] ,
132+ 'config' => {
133+ 'transport' => 'remote' ,
134+ 'remote' => {
135+ 'device-type' => 'fake' ,
136+ 'url' => device_url ,
137+ }
138+ }
139+ }
140+ inv = agent_version_inventory
141+ inv [ 'groups' ] << device_group
142+ inv
143+ end
144+
145+ it 'gathers facts from devices' do
146+ with_tempfile_containing ( 'inventory' , YAML . dump ( device_inventory ) , '.yaml' ) do |inv |
147+ results = run_cli_json ( %W[ plan run device_test::facts --nodes device_targets
148+ --modulepath #{ modulepath } --inventoryfile #{ inv . path } ] )
149+
150+ require 'pry' ; binding . pry
151+ expect ( result ) . to eq ( [ ] )
152+ results . each do |result |
153+ expect ( result [ 'status' ] ) . to eq ( 'success' )
154+ report = result [ 'result' ] [ 'report' ]
155+ expect ( report [ 'resource_statuses' ] ) . to include ( "Notify[Apply: Hi!]" )
156+ end
157+ end
158+ end
159+ end
119160 end
120161
121162 context "when installing puppet" do
@@ -303,7 +344,7 @@ def config
303344 result = run_task ( 'puppet_agent::install' , conn_uri ( 'winrm' ) ,
304345 { 'collection' => 'puppet6' } , config : config )
305346 expect ( result . count ) . to eq ( 1 )
306- expect ( result [ 0 ] [ 'status' ] ) . to eq ( 'success' )
347+ expect ( result [ 0 ] ) . to include ( 'status' => 'success' )
307348
308349 result = run_task ( 'puppet_agent::version' , conn_uri ( 'winrm' ) , config : config )
309350 expect ( result . count ) . to eq ( 1 )
0 commit comments