Skip to content

Instantly share code, notes, and snippets.

@Mahito
Created August 12, 2014 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mahito/535b17e99c8e186eea4b to your computer and use it in GitHub Desktop.
Save Mahito/535b17e99c8e186eea4b to your computer and use it in GitHub Desktop.
Serverspec to xml file
require 'serverspec'
require 'nokogiri'
describe file('/etc/hadoop/hadoop-0.20.2/conf/mapred-site.xml') do
it { should be_file }
it do
doc = Nokogiri::Slop(subject.content)
doc.configuration.each do |property|
case property.name.content
when 'mapred.child.java.opts'
property.value.content.should eq '-Xmx1024m'
when 'mapred.map.tasks'
property.value.content.should eq '3'
when 'mapred.reduce.tasks'
property.value.content.should eq '1'
when 'mapred.tasktracker.map.tasks.maximum'
property.value.content.should eq '3'
when 'mapred.tasktracker.reduce.tasks.maximum'
property.value.content.should eq '1'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment