Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove recipe for installing Kafka from source #66

Merged
merged 1 commit into from
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,3 @@ suites:
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-sysv
run_list:
- recipe[java::default]
- recipe[kafka::default]
attributes:
kafka:
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
install_method: 'source'
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', nil) %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', nil) %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
59 changes: 0 additions & 59 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,62 +89,3 @@ suites:
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-upstart
run_list:
- recipe[java::default]
- recipe[kafka::default]
excludes:
- centos-6.5
- centos-7.0
- debian-7.4
- fedora-20
attributes:
kafka:
install_method: 'source'
init_style: 'upstart'
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
ulimit_file: 128000
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-sysv
run_list:
- recipe[java::default]
- recipe[kafka::default]
excludes:
- centos-7.0
attributes:
kafka:
install_method: 'source'
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
ulimit_file: 128000
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-systemd
run_list:
- recipe[java::default]
- recipe[kafka::default]
includes:
- fedora-20
- centos-7.0
attributes:
kafka:
install_method: 'source'
init_style: 'systemd'
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Installs Kafka `v0.8.1.1`, and probably any newer versions.
Based on the Kafka cookbook released by WebTrends (thanks!), but with a few
notable differences:

* supports both source and binary releases.
* does not depend on runit cookbook.
* does not depend on zookeeper cookbook, thus it will not search for nodes with
a specific role or such, that is left up to you to decide.
Expand Down Expand Up @@ -64,16 +63,6 @@ This section describes the different recipes that are available.

### default

Includes either `source` or `binary` recipe depending on what
`node.kafka.install_method` is set to (`:source, :binary`).

### source

Downloads, compiles and installs Kafka from the official source releases.
Defaults to installing `v0.8.1.1` of Kafka.

### binary

Downloads and installs Kafka from the official binary releases.
Defaults to installing `v0.8.1.1` of Kafka.

Expand Down
4 changes: 0 additions & 4 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
# Scala version of Kafka.
default.kafka.scala_version = '2.9.2'

#
# Decides how to install Kafka, valid values are currently :binary and :source.
default.kafka.install_method = :binary

#
# Directory where to install Kafka.
default.kafka.install_dir = '/opt/kafka'
Expand Down
32 changes: 2 additions & 30 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,8 @@ def kafka_base
%(kafka_#{node.kafka.scala_version}-#{node.kafka.version})
end

def kafka_src
%(kafka-#{node.kafka.version}-src)
end

def kafka_target_path
if kafka_binary_install?
::File.join(node.kafka.build_dir, kafka_base)
else
if kafka_v0_8_0?
::File.join(node.kafka.build_dir, kafka_src, 'target', 'RELEASE', kafka_base)
else
::File.join(node.kafka.build_dir, kafka_src, 'core', 'build', 'distributions', kafka_base)
end
end
::File.join(node.kafka.build_dir, kafka_base)
end

def kafka_jar_path
Expand All @@ -40,37 +28,21 @@ def kafka_download_uri(filename)
end

def kafka_archive_ext
if kafka_v0_8_0? && kafka_binary_install?
if kafka_v0_8_0?
'tar.gz'
else
'tgz'
end
end

def kafka_build_command
if kafka_v0_8_0?
%(./sbt update && ./sbt "++#{node.kafka.scala_version} release-zip")
else
%(./gradlew -PscalaVersion=#{node.kafka.scala_version} releaseTarGz -x signArchives)
end
end

def kafka_v0_8_0?
node.kafka.version == '0.8.0'
end

def kafka_install_method
node.kafka.install_method.to_sym
end

def kafka_init_style
node.kafka.init_style.to_sym
end

def kafka_binary_install?
kafka_install_method == :binary
end

def kafka_init_opts
@kafka_init_opts ||= Hash.new.tap do |opts|
case kafka_init_style
Expand Down
2 changes: 1 addition & 1 deletion recipes/binary.rb → recipes/_install.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Cookbook Name:: kafka
# Recipe:: binary
# Recipe:: _install
#

kafka_tar_gz = [kafka_base, kafka_archive_ext].join('.')
Expand Down
13 changes: 4 additions & 9 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
# Recipe:: default
#

case kafka_install_method
when :source, :binary
include_recipe 'kafka::_defaults'
include_recipe 'kafka::_setup'
include_recipe 'kafka::%s' % node.kafka.install_method
include_recipe 'kafka::_configure'
else
Chef::Application.fatal!('Unknown install_method: %s' % node.kafka.install_method.inspect)
end
include_recipe 'kafka::_defaults'
include_recipe 'kafka::_setup'
include_recipe 'kafka::_install'
include_recipe 'kafka::_configure'
35 changes: 0 additions & 35 deletions recipes/source.rb

This file was deleted.

67 changes: 9 additions & 58 deletions spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,23 @@
require 'spec_helper'

describe 'kafka::default' do
TerminatedExecutionError = Class.new(StandardError)

let :chef_run do
ChefSpec::Runner.new do |node|
node.set[:kafka][:install_method] = install_method
end.converge(described_recipe)
end

shared_examples_for 'a valid install method' do
it 'includes kafka::_setup' do
expect(chef_run).to include_recipe('kafka::_setup')
end

it 'includes kafka::install_method recipe' do
expect(chef_run).to include_recipe(%(kafka::#{install_method}))
end

it 'includes kafka::_configure' do
expect(chef_run).to include_recipe('kafka::_configure')
end
ChefSpec::Runner.new.converge(described_recipe)
end

context 'when node.kafka.install_method equals :source' do
it_behaves_like 'a valid install method' do
let :install_method do
:source
end
end
it 'includes kafka::_defaults' do
expect(chef_run).to include_recipe('kafka::_defaults')
end

context 'when node.kafka.install_method equals \'source\'' do
it_behaves_like 'a valid install method' do
let :install_method do
'source'
end
end
it 'includes kafka::_setup' do
expect(chef_run).to include_recipe('kafka::_setup')
end

context 'when node.kafka.install_method equals :binary' do
it_behaves_like 'a valid install method' do
let :install_method do
:binary
end
end
it 'includes kafka::_install recipe' do
expect(chef_run).to include_recipe('kafka::_install')
end

context 'when node.kafka.install_method equals \'binary\'' do
it_behaves_like 'a valid install method' do
let :install_method do
'binary'
end
end
end

context 'when node.kafka.install_method is something else' do
let :install_method do
:bork
end

before do
allow(Chef::Application).to receive(:fatal!).and_raise(TerminatedExecutionError)
end

it 'terminates the chef run' do
expect { chef_run.converge(described_recipe) }.to raise_error(TerminatedExecutionError)
expect(Chef::Application).to have_received(:fatal!).with(/Unknown install_method: :bork/).once
end
it 'includes kafka::_configure' do
expect(chef_run).to include_recipe('kafka::_configure')
end
end
7 changes: 3 additions & 4 deletions spec/recipes/binary_spec.rb → spec/recipes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

require 'spec_helper'

describe 'kafka::binary' do
describe 'kafka::_install' do
let :chef_run do
ChefSpec::Runner.new(step_into: %w(kafka_download kafka_install)) do |node|
node.set[:kafka][:install_method] = :binary
end.converge(described_recipe)
r = ChefSpec::Runner.new(step_into: %w(kafka_download kafka_install))
r.converge(described_recipe)
end

it 'downloads remote binary release of Kafka' do
Expand Down
Loading