Permalink
Browse files

expose the test cluster as a commend

  • Loading branch information...
1 parent 8bbf1d7 commit 01dacc51b13a6a7f3fe93324944748009721d170 @copiousfreetime committed Apr 26, 2011
Showing with 42 additions and 14 deletions.
  1. +36 −0 bin/ashbe-test-cluster
  2. +1 −0 lib/ashbe.rb
  3. +5 −14 test/testing_cluster_helper.rb → lib/ashbe/test/cluster.rb
View
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require 'ashbe'
+
+options = {}
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: asbhe-test-cluster [options]"
+
+ opts.separator""
+
+ opts.on( "--jardir /foo,/bar/baz,/wibble", Array, "List of directories containing jars to require") do |list|
+ options['jardir'] = list
+ end
+
+ opts.on( "--config-files hbase-site.xml,mapred-site.xml", Array, "List of hbase/hadoop config files to use" ) do |list|
+ options['config-files'] = list
+ end
+
+ opts.on_tail( "-h", "--help", "Show this message") do
+ $stderr.puts opts
+ exit
+ end
+end
+
+opts.parse!( ARGV )
+
+Ashbe.initialize( options['jardir'] )
+
+config_files = options['config-files'] || Ashbe::Test::Cluster.config_files
+
+cluster = Ashbe::Test::Cluster.new( config_files )
+cluster.start
+puts "CLUSTER STARTED"
+trap 'INT' do
+ cluster.stop
+end
View
@@ -89,6 +89,7 @@ def self.require_lib
require 'ashbe/row_criteria'
require 'ashbe/table'
require 'ashbe/table/meta'
+ require 'ashbe/test/cluster'
end
@@ -1,16 +1,15 @@
-require 'spec_helper'
-
module Ashbe
- module Testing
+ module Test
class Cluster
def self.config_files
- spec_config_files
+ config_dir = File.expand_path( "../spec/data/config", File.dirname( __FILE__ ))
+ Dir.glob( File.join( config_dir, "*.xml" ) )
end
attr_reader :config
- def initialize
- @config = ::Ashbe::Configuration.new( Cluster.config_files )
+ def initialize( config_files = Cluster.config_files )
+ @config = ::Ashbe::Configuration.new( config_files )
@utility = org.apache.hadoop.hbase.HBaseTestingUtility.new( @config )
end
@@ -41,11 +40,3 @@ def stop
end
end
-if $0 == __FILE__ then
- @cluster = Ashbe::Testing::Cluster.new
- @cluster.start
- puts "CLUSTER STARTED"
- trap 'INT' do
- @cluster.stop
- end
-end

0 comments on commit 01dacc5

Please sign in to comment.