Class: Kymera::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kymera/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(real_time = true) ⇒ Client

The client is responsible for sending the run to the distributed network. It is responsible for parsing the tests and sending all needed information to the test broker The initializer take in a broker_address(String) identifying the location of the broker on the network, a results_bus_address(String) identifying the latching point of the bus where the client and get real-time test output as the tests are being executed and real_time(Boolean) indicating whether or not this client wants to get real-time updates. This is defaulted to true



12
13
14
15
16
17
18
19
20
21
# File 'lib/kymera/client.rb', line 12

def initialize(real_time = true)
  config = Kymera::Config.new
  @broker_address = config.client["broker_address"]
  @results_bus_address = config.client["results_bus_address"]
  @real_time = real_time.to_s
  @zmq = Kymera::SZMQ.new
  @client_id = Kymera::host_name
  Client.run_id +=1
  @full_run_id = @client_id + (Client.run_id.to_s)
end

Class Method Details

.run_idObject



27
28
29
# File 'lib/kymera/client.rb', line 27

def self.run_id
  @run_id ||= 0
end

.run_id=(num) ⇒ Object



23
24
25
# File 'lib/kymera/client.rb', line 23

def self.run_id=(num)
  @run_id = num
end

Instance Method Details

#run_tests(tests, runner, options, grouped = false, branch = 'develop') ⇒ Object

This is the kick off point for the test run. The tests parameter is the directory location of the tests you wish to run. This will be passed into a test parser that will determine which of the tests in the directory need to be run based on the options passed in. The runner parameter tells the system which test runner the system should use. Right now, the only supported test runner is Cucumber, but I would like to expand this at the very least to also support Rspec. The options parameter are the options to be passed into the specified runner



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
# File 'lib/kymera/client.rb', line 35

def run_tests(tests, runner, options, grouped = false, branch = 'develop')
  @start_time = Time.now
  tests = parse_tests(tests, runner, options)
  test_run = {:tests => tests, :runner => runner, :run_id => @full_run_id, :options => options, :branch => branch, :start_time => @start_time.to_s, :grouped => grouped }
  socket = @zmq.socket(@broker_address, 'push')
  socket.connect
  message = JSON.generate(test_run)
  # puts "Sending the following message: \n"
  # puts message
  socket.send_message(message)

  channels = ["end_#{@full_run_id}"]
  results_feed = @zmq.socket(@results_bus_address, 'sub')
  if @real_time == "true"
    channels << @full_run_id
  end
  results_feed.subscribe(channels) do |channel, results|
    if channel == "end_#{@full_run_id}"
      puts "###########Test Run Results########################"
      puts results
      results_feed.close
      report_time_taken
      exit
    else
      puts results
    end
  end

end