Class: BigBench::Executor::Executable

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bigbench/executor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject

Templates are here



12
13
14
# File 'lib/bigbench/executor.rb', line 12

def self.source_root
  File.join(File.dirname(__FILE__), "templates")
end

Instance Method Details

#bot(redis_url = nil, redis_password = nil) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/bigbench/executor.rb', line 75

def bot(redis_url = nil, redis_password = nil)
  BigBench::Store.setup!(redis_url, redis_password)

  loop {
    BigBench::Output.bot_is_checking
    BigBench::Bot.check_test!
    sleep(BigBench.config.bot_checks_every.to_i)
  }
end

#bots(file, redis_url = nil, redis_password = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/bigbench/executor.rb', line 35

def bots(file, redis_url = nil, redis_password = nil)
  
  # Load and validate tests
  test = File.open(file, "rb"){ |file| file.read }
  BigBench.load_test!(test)
  BigBench.config.mode = :bots

  # Initialize redis
  BigBench::Store.setup!(redis_url, redis_password)

  # Load current test to redis & start bots
  BigBench::Store.test = test
  BigBench::Store.start
  BigBench::Output.deployed_test

  # Wait for bots to run the tests
  @is_running = true
  timer = Thread.new{
    sleep(BigBench.duration.to_i)
    BigBench::Store.stop
    @is_running = false
  }

  BigBench::Output.starting_bots_loop
  loop{
    bots = BigBench::Store.bots
    BigBench::Output.running_bots_loop(bots)
    sleep(1)
    break if !@is_running and bots.size == 0
  }

  # Gather trackings from redis and write them to the file
  BigBench::Output.finished_bots_loop
  BigBench.write_store_trackings_to_file!
  BigBench.run_post_processors!
  BigBench::Store.reset!
end

#defaultObject



19
20
21
# File 'lib/bigbench/executor.rb', line 19

def default
  options.version? ? puts(BigBench::VERSION) : help
end

#generate(name) ⇒ Object



111
112
113
114
# File 'lib/bigbench/executor.rb', line 111

def generate(name)
  @name = name
  template "test_plan.rb.erb", "#{name}.rb"
end

#local(file) ⇒ Object



26
27
28
29
30
31
# File 'lib/bigbench/executor.rb', line 26

def local(file)
  BigBench.load_test! File.open(file, "rb"){ |file| file.read }
  BigBench.run!
  BigBench.write_local_trackings_to_file!
  BigBench.run_post_processors!
end

#process(file, post_processor = nil) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bigbench/executor.rb', line 87

def process(file, post_processor = nil)
  BigBench.load_test! File.open(file, "rb"){ |file| file.read }
  
  if post_processor
    BigBench::PostProcessor.reset!
    BigBench.post_process(post_processor)
    BigBench.run_post_processors!
  else
    BigBench.run_post_processors!
  end
end

#reset(redis_url = nil, redis_password = nil) ⇒ Object



101
102
103
104
105
106
107
# File 'lib/bigbench/executor.rb', line 101

def reset(redis_url = nil, redis_password = nil)
  BigBench::Store.setup!(redis_url, redis_password)
  BigBench::Store.reset!
  BigBench::Configuration.reset!
  BigBench::Benchmark.reset!
  BigBench::Output.reset
end