Skip to content

Commit

Permalink
Merge branch 'create-log-dirs'
Browse files Browse the repository at this point in the history
  • Loading branch information
mthssdrbrg committed Jul 11, 2014
2 parents 3b035b1 + 4c61af9 commit 20cb965
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ suites:
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
log:
dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper:
connect: ['localhost:2181']
connection_timeout_ms: 15_000
Expand All @@ -58,6 +60,8 @@ suites:
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
log:
dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper:
connect: ['localhost:2181']
connection_timeout_ms: 15_000
Expand All @@ -76,6 +80,8 @@ suites:
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
log:
dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper:
connect: ['localhost:2181']
connection_timeout_ms: 15_000
Expand All @@ -89,6 +95,8 @@ suites:
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
log:
dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper:
connect: ['localhost:2181']
connection_timeout_ms: 15_000
Expand Down
9 changes: 9 additions & 0 deletions recipes/_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@
recursive true
end
end

node[:kafka][:log][:dirs].each do |dir|
directory dir do
owner node[:kafka][:user]
group node[:kafka][:group]
mode '755'
recursive true
end
end
21 changes: 21 additions & 0 deletions spec/recipes/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@
})
end

context 'log dirs for Kafka data' do
let :kafka_attrs do
{
log: {
dirs: %w[/mnt/kafka-1 /mnt/kafka-2]
}
}
end

it 'creates a directory for each path in `log.dirs`' do
%w[/mnt/kafka-1 /mnt/kafka-2].each do |path|
expect(chef_run).to create_directory(path).with({
owner: 'kafka',
group: 'kafka',
mode: '755',
recursive: true,
})
end
end
end

it 'creates config directory' do
expect(chef_run).to create_directory('/opt/kafka/config').with({
owner: 'kafka',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
end
end
end

context 'configured `log.dirs`' do
%w[/mnt/kafka-logs-1 /mnt/kafka-logs-2].each do |directory|
describe directory do
it_behaves_like 'a kafka directory', skip_files: true do
let :path do
directory
end
end
end
end
end
end

shared_examples_for 'a _configure recipe' do
Expand Down

0 comments on commit 20cb965

Please sign in to comment.