From 525fc9c5aba5f2bc686009d6d3ed37adc6350a94 Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Thu, 3 Aug 2017 12:00:59 +0200 Subject: [PATCH 1/2] use fixtures for conf file tests should help to solve https://github.com/wywygmbh/puppet-fluentd/issues/4 --- spec/defines/filter_spec.rb | 9 ++------- spec/defines/match_spec.rb | 26 ++------------------------ spec/defines/source_spec.rb | 9 ++------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/spec/defines/filter_spec.rb b/spec/defines/filter_spec.rb index 87e9c74..6365302 100644 --- a/spec/defines/filter_spec.rb +++ b/spec/defines/filter_spec.rb @@ -29,12 +29,7 @@ describe 'fluentd::filter' do it do is_expected.to contain_file('/etc/td-agent/conf.d/20-filter-test.conf'). - with_content(//). - with_content(/type record_transformer/). - with_content(//). - with_content(/hostname \$\{hostname\}/). - with_content(/<\/record>/). - with_content(/<\/filter>/) + with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/filter_record_transformer.conf'))) end end -end \ No newline at end of file +end diff --git a/spec/defines/match_spec.rb b/spec/defines/match_spec.rb index 82a564c..c2da497 100644 --- a/spec/defines/match_spec.rb +++ b/spec/defines/match_spec.rb @@ -36,17 +36,7 @@ describe 'fluentd::match' do it do is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf'). - with_content(//). - with_content(/flush_interval 30s/). - with_content(/type secure_forward/). - with_content(/secure yes/). - with_content(/shared_key my_shared_key/). - with_content(/self_hostname instance.test.com/). - with_content(/ca_cert_path \/path\/to\/ca.cert/). - with_content(//). - with_content(/host test.server.com/). - with_content(/<\/server>/). - with_content(/<\/match>/) + with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_secure_forward.conf'))) end end @@ -76,19 +66,7 @@ describe 'fluentd::match' do it do is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf'). - with_content(//). - with_content(/type copy/). - with_content(//). - with_content(/type elasticsearch/). - with_content(/logstashformat true/). - with_content(/hosts 172.20.10.17:9200/). - with_content(/flush_interval 30s/). - with_content(/<\/store>/). - with_content(//). - with_content(/type file/). - with_content(/path \/tmp\/td-agent-debug.log/). - with_content(/<\/store>/). - with_content(/<\/match>/) + with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_copy.conf'))) end end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 996869f..c06feda 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -28,12 +28,7 @@ describe 'fluentd::source' do it do is_expected.to contain_file('/etc/td-agent/conf.d/10-source-test.conf'). - with_content(//). - with_content(/type tail/). - with_content(/format json/). - with_content(/path \/var\/log\/test-application\/\*.json/). - with_content(/tag application.test/). - with_content(/<\/source>/) + with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/source_tail.conf'))) end end -end \ No newline at end of file +end From 533857e49c6589912ab1d91b1a1b16ca168de8b2 Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Thu, 3 Aug 2017 12:11:13 +0200 Subject: [PATCH 2/2] added missing fixtures --- spec/fixtures/files/filter_record_transformer.conf | 6 ++++++ spec/fixtures/files/match_copy.conf | 13 +++++++++++++ spec/fixtures/files/match_secure_forward.conf | 11 +++++++++++ spec/fixtures/files/source_tail.conf | 6 ++++++ 4 files changed, 36 insertions(+) create mode 100644 spec/fixtures/files/filter_record_transformer.conf create mode 100644 spec/fixtures/files/match_copy.conf create mode 100644 spec/fixtures/files/match_secure_forward.conf create mode 100644 spec/fixtures/files/source_tail.conf diff --git a/spec/fixtures/files/filter_record_transformer.conf b/spec/fixtures/files/filter_record_transformer.conf new file mode 100644 index 0000000..58aadb6 --- /dev/null +++ b/spec/fixtures/files/filter_record_transformer.conf @@ -0,0 +1,6 @@ + + type record_transformer + + hostname ${hostname} + + diff --git a/spec/fixtures/files/match_copy.conf b/spec/fixtures/files/match_copy.conf new file mode 100644 index 0000000..7a45925 --- /dev/null +++ b/spec/fixtures/files/match_copy.conf @@ -0,0 +1,13 @@ + + type copy + + type elasticsearch + logstashformat true + hosts 172.20.10.17:9200 + flush_interval 30s + + + type file + path /tmp/td-agent-debug.log + + diff --git a/spec/fixtures/files/match_secure_forward.conf b/spec/fixtures/files/match_secure_forward.conf new file mode 100644 index 0000000..1218ba0 --- /dev/null +++ b/spec/fixtures/files/match_secure_forward.conf @@ -0,0 +1,11 @@ + + flush_interval 30s + type secure_forward + secure yes + shared_key my_shared_key + self_hostname instance.test.com + ca_cert_path /path/to/ca.cert + + host test.server.com + + diff --git a/spec/fixtures/files/source_tail.conf b/spec/fixtures/files/source_tail.conf new file mode 100644 index 0000000..15b5dad --- /dev/null +++ b/spec/fixtures/files/source_tail.conf @@ -0,0 +1,6 @@ + + type tail + format json + path /var/log/test-application/*.json + tag application.test +