Module: Kymera

Defined in:
lib/kymera.rb,
lib/kymera/broker.rb,
lib/kymera/client.rb,
lib/kymera/worker.rb,
lib/kymera/version.rb,
lib/kymera/szmq/szmq.rb,
lib/kymera/results_bus.rb,
lib/kymera/mongo_driver.rb,
lib/kymera/config/config.rb,
lib/kymera/platform_utils.rb,
lib/kymera/cucumber/test_parser.rb,
lib/kymera/test_results_collector.rb,
lib/kymera/cucumber/dry_run_formatter.rb,
lib/kymera/cucumber/cucumber_html_parser.rb,
lib/kymera/cucumber/cucumber_test_runner.rb,
lib/kymera/cucumber/cucumber_results_parser.rb

Defined Under Namespace

Modules: Cucumber Classes: Broker, Client, Config, MongoDriver, ResultsBus, SSocket, SZMQ, TestResultsCollector, Worker

Constant Summary collapse

VERSION =
"0.1.7"

Class Method Summary collapse

Class Method Details

.generate_configObject

Generate the default config.yaml file



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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/kymera.rb', line 45

def self.generate_config
  require 'yaml'
  puts "Generating congfig.yaml"
  config_options = {
      "client" => {
          "broker_address" => 'tcp://127.0.0.1:5550',
          "results_bus_address" => 'tcp://127.0.0.1:7001'
      },
      "broker" =>{
          "client_listening_port" => '5550',
          "worker_listening_port" => '5552',
          "internal_worker_port" => '5551',
          "number_of_connections" => '20'

      },
      "worker" => {
          'broker_address' => 'tcp://127.0.0.1:5552',
          'result_collector_address' => 'tcp://127.0.0.1:5556',
          'result_bus_address' => 'tcp://127.0.0.1:7000'
      },
      'result_collector' =>{
          'inc_listening_port' => '5556',
          'result_bus_address' => 'tcp://127.0.0.1:7000',
          'send_mongo_results' => false,
          'mongodb_address' => '127.0.0.1',
          'mongodb_port' => 27017,
          'mongodb_database_name' => 'default_db',
          'mongodb_collection_name' => 'default_collection'

      },
      'result_bus' => {
          'pub_port' => '7000',
          'sub_port' => '7001'
      }
  }
  config_file = File.open(File.join(Dir.pwd, '/kymera_config.yaml'), 'w+')
  config_options.to_yaml.split('\n').each do |line|
    config_file.write(line)
  end
  config_file.close
  config_options.to_yaml
end

.host_nameObject



69
70
71
# File 'lib/kymera/platform_utils.rb', line 69

def self.host_name
  Socket.gethostname
end

.hwprefs_available?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
# File 'lib/kymera/platform_utils.rb', line 28

def self.hwprefs_available?
  avail = true
  begin
    `hwprefs`
  rescue
    avail = false
  end
  avail
end

.ip_addressObject



58
59
60
61
62
63
64
65
# File 'lib/kymera/platform_utils.rb', line 58

def self.ip_address
  ips = Socket.ip_address_list
  ip = ''
  ips.each do |i|
    ip = i.ip_address if i.ipv4? && i.ip_address.start_with?("10")
  end
  ip
end

.is_linux?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
# File 'lib/kymera/platform_utils.rb', line 38

def self.is_linux?
  case RbConfig::CONFIG['host_os']
    when /linux|darwin/
      true
    else
      false
  end

end

.is_windows?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
# File 'lib/kymera/platform_utils.rb', line 48

def self.is_windows?
  case RbConfig::CONFIG['host_os']
    when /mswin|mingw/
      true
    else
      false
  end
end

.processor_countObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kymera/platform_utils.rb', line 5

def self.processor_count
  @processor_count ||= case RbConfig::CONFIG['host_os']
     when /darwin9/
       `hwprefs cpu_count`.to_i
     when /darwin/
       (hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
     when /linux|cygwin/
       `grep -c ^processor /proc/cpuinfo`.to_i
     when /(net|open|free)bsd/
       `sysctl -n hw.ncpu`.to_i
     when /mswin|mingw/
       require 'win32ole'
       wmi = WIN32OLE.connect("winmgmts://")
       cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
       cpu.to_enum.first.NumberOfLogicalProcessors
     when /solaris2/
       `psrinfo -p`.to_i # this is physical cpus afaik
     else
       $stderr.puts "Unknown architecture ( #{RbConfig::CONFIG["host_os"]} ) assuming one processor."
       1
   end
end

.run_tests(tests, test_runner, options, branch, grouped = false, real_time = true) ⇒ Object

Start a test run



19
20
21
22
# File 'lib/kymera.rb', line 19

def self.run_tests(tests, test_runner, options, branch, grouped = false, real_time = true)
  Kymera::Client.new(real_time).run_tests(tests, test_runner, options, grouped, branch)

end

.start_brokerObject

Start the test broker



25
26
27
# File 'lib/kymera.rb', line 25

def self.start_broker
  Kymera::Broker.new.start_broker
end

.start_busObject

Start the results bus



40
41
42
# File 'lib/kymera.rb', line 40

def self.start_bus
  Kymera::ResultsBus.new.start_bus
end

.start_collectorObject

Start the results collector



35
36
37
# File 'lib/kymera.rb', line 35

def self.start_collector
  Kymera::TestResultsCollector.new.listen
end

.start_workerObject

Start a worker



30
31
32
# File 'lib/kymera.rb', line 30

def self.start_worker
  Kymera::Worker.new.listen
end

.wait_for(&block) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/kymera/platform_utils.rb', line 73

def self.wait_for(&block)
  found = false
  i = 0
  until i == 60 || found
    found = yield
    sleep 1
    i +=1
  end
  found
end