|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'collectd::plugin::python', :type => :define do |
| 4 | + |
| 5 | + context ':ensure => present' do |
| 6 | + let :facts do |
| 7 | + { |
| 8 | + :osfamily => 'Debian' |
| 9 | + } |
| 10 | + end |
| 11 | + let (:title) {'elasticsearch'} |
| 12 | + let :params do |
| 13 | + { |
| 14 | + :modulepath => '/usr/lib/collectd', |
| 15 | + :module => 'elasticsearch', |
| 16 | + :script_source => 'puppet:///modules/myorg/elasticsearch_collectd_python.py', |
| 17 | + :config => {'Cluster' => 'elasticsearch'}, |
| 18 | + } |
| 19 | + end |
| 20 | + |
| 21 | + it 'Will create /etc/collectd/conf.d/10-elasticsearch.conf' do |
| 22 | + should contain_file('elasticsearch.load').with({ |
| 23 | + :ensure => 'present', |
| 24 | + :path => '/etc/collectd/conf.d/10-elasticsearch.conf', |
| 25 | + :content => "<LoadPlugin \"python\">\n Globals true\n</LoadPlugin>\n\n<Plugin \"python\">\n ModulePath \"/usr/lib/collectd\"\n\n Import \"elasticsearch\"\n\n <Module \"elasticsearch\">\n Verbose false\n\t\tCluster \"elasticsearch\"\n </Module>\n</Plugin>\n", |
| 26 | + }) |
| 27 | + end |
| 28 | + it 'Will create /usr/lib/collectd/elasticsearch.py' do |
| 29 | + should contain_file('elasticsearch.script').with({ |
| 30 | + :ensure => 'present', |
| 31 | + :path => '/usr/lib/collectd/elasticsearch.py', |
| 32 | + #:content => "<Plugin network>\n <Server \"node1\" \"1234\">\n SecurityLevel \"Encrypt\"\n Username \"foo\"\n Password \"bar\"\n Interface \"eth0\"\n\n </Server>\n</Plugin>\n", |
| 33 | + }) |
| 34 | + end |
| 35 | + end |
| 36 | + |
| 37 | + context ':ensure => absent' do |
| 38 | + let :facts do |
| 39 | + { |
| 40 | + :osfamily => 'Debian' |
| 41 | + } |
| 42 | + end |
| 43 | + let (:title) {'elasticsearch'} |
| 44 | + let :params do |
| 45 | + { |
| 46 | + :ensure => 'absent', |
| 47 | + :modulepath => '/usr/lib/collectd', |
| 48 | + :module => 'elasticsearch', |
| 49 | + :script_source => 'puppet:///modules/myorg/elasticsearch_collectd_python.py', |
| 50 | + :config => {'Cluster' => 'elasticsearch'}, |
| 51 | + } |
| 52 | + end |
| 53 | + it 'Will not create /etc/collectd/conf.d/10-elasticsearch.conf' do |
| 54 | + should contain_file('elasticsearch.load').with({ |
| 55 | + :ensure => 'absent', |
| 56 | + :path => '/etc/collectd/conf.d/10-elasticsearch.conf', |
| 57 | + }) |
| 58 | + end |
| 59 | + it 'Will not create /usr/lib/collectd/elasticsearch.py' do |
| 60 | + should contain_file('elasticsearch.script').with({ |
| 61 | + :ensure => 'absent', |
| 62 | + :path => '/usr/lib/collectd/elasticsearch.py', |
| 63 | + }) |
| 64 | + end |
| 65 | + end |
| 66 | + |
| 67 | +end |
0 commit comments