kymera 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.idea/.name +1 -0
  4. data/.idea/.rakeTasks +7 -0
  5. data/.idea/encodings.xml +5 -0
  6. data/.idea/inspectionProfiles/Project_Default.xml +7 -0
  7. data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
  8. data/.idea/kymera.iml +187 -0
  9. data/.idea/misc.xml +5 -0
  10. data/.idea/modules.xml +9 -0
  11. data/.idea/scopes/scope_settings.xml +5 -0
  12. data/.idea/vcs.xml +7 -0
  13. data/.idea/workspace.xml +1035 -0
  14. data/Gemfile +13 -0
  15. data/LICENSE.txt +22 -0
  16. data/README.md +96 -0
  17. data/Rakefile +1 -0
  18. data/bin/kymera +63 -0
  19. data/kymera.gemspec +31 -0
  20. data/lib/kymera/broker.rb +112 -0
  21. data/lib/kymera/client.rb +98 -0
  22. data/lib/kymera/config/config.rb +36 -0
  23. data/lib/kymera/cucumber/cucumber_html_parser.rb +80 -0
  24. data/lib/kymera/cucumber/cucumber_results_parser.rb +93 -0
  25. data/lib/kymera/cucumber/cucumber_test_runner.rb +76 -0
  26. data/lib/kymera/cucumber/dry_run_formatter.rb +31 -0
  27. data/lib/kymera/cucumber/test_parser.rb +36 -0
  28. data/lib/kymera/mongo_driver.rb +39 -0
  29. data/lib/kymera/platform_utils.rb +64 -0
  30. data/lib/kymera/results_bus.rb +26 -0
  31. data/lib/kymera/szmq/szmq.rb +252 -0
  32. data/lib/kymera/test_results_collector.rb +126 -0
  33. data/lib/kymera/version.rb +3 -0
  34. data/lib/kymera/worker.rb +83 -0
  35. data/lib/kymera.rb +88 -0
  36. data/lib/spec/broker_spec.rb +25 -0
  37. data/lib/spec/client_spec.rb +21 -0
  38. data/lib/spec/client_test_run_spec.rb +3 -0
  39. data/lib/spec/config_options.txt +51 -0
  40. data/lib/spec/full_run_for_linux_spec.rb +44 -0
  41. data/lib/spec/full_run_spec.rb +44 -0
  42. data/lib/spec/get_bus_data.rb +43 -0
  43. data/lib/spec/html_parser_spec.rb +61 -0
  44. data/lib/spec/html_parsing_alg.txt +31 -0
  45. data/lib/spec/json_message_example.txt +6 -0
  46. data/lib/spec/mongo_driver_spec.rb +5 -0
  47. data/lib/spec/plain_broker_spec.rb +44 -0
  48. data/lib/spec/plain_reply_socket_spec.rb +13 -0
  49. data/lib/spec/plain_request_socket_spec.rb +13 -0
  50. data/lib/spec/result_bus_spec.rb +13 -0
  51. data/lib/spec/results_parser_test_run_spec.rb +18 -0
  52. data/lib/spec/send_bus_data.rb +16 -0
  53. data/lib/spec/startup_broker_bus_collector_spec.rb +35 -0
  54. data/lib/spec/test_file_paths_spec.rb +2 -0
  55. data/lib/spec/worker_spec.rb +15 -0
  56. data/lib/spec/worker_test_run_spec.rb +21 -0
  57. data/lib/spec/zmq_network_test_spec.rb +13 -0
  58. metadata +228 -0
@@ -0,0 +1,83 @@
1
+ require_relative 'szmq/szmq'
2
+ require 'json'
3
+
4
+ module Kymera
5
+ class Worker
6
+
7
+ def initialize
8
+ config = Kymera::Config.new
9
+ @test_address = config.worker["broker_address"]
10
+ @results_address = config.worker["result_collector_address"]
11
+ @result_bus_address = config.worker["result_bus_address"]
12
+ @zmq = SZMQ.new
13
+ #For the moment I am using a push/pull configuration for running of tests. Initial runs indicated that this may not work as all tests are being sent to just one
14
+ #worker at a time instead of load balancing them. It may be more advantageous to use a request/reply structure for sending tests and managing the test run queue
15
+ #manually.
16
+ @test_socket = @zmq.socket(@test_address, 'reply')
17
+ @results_socket = @zmq.socket(@results_address, 'push')
18
+ @result_bus_socket = @zmq.socket(@result_bus_address, 'pub')
19
+ @result_bus_socket.connect
20
+ @test_socket.connect
21
+ #Even though this is a push socket, I am connecting instead of binding because the static point is going to be the pull socket where the results are aggregated
22
+ #Static points are bound, dynamic points are connected
23
+ @results_socket.connect
24
+ end
25
+
26
+ def listen
27
+ puts "Worker started..."
28
+ @test_socket.receive do |message|
29
+ #This is a preliminary kill command. I will need to give more thought into the life cycle of the workers
30
+ if message == 'STOP'
31
+ stop
32
+ break
33
+ else
34
+ results = run_test(message)
35
+ @results_socket.send_message(results)
36
+ @test_socket.send_message ''
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ #I need to pass in the runner and runner options. Thinking about using JSON to get those options and instantiate a runner object based on that information
43
+ #The idea is to be able to take in any number of different test runners (cucumber/rspec) without having the restart the worker object
44
+ #This is why passing in the runner on worker instantiation isnt really an option
45
+ def run_test(test)
46
+ test = JSON.parse(test)
47
+ runner = get_runner(test["runner"], test["options"], test["run_id"])
48
+ test_path = nil
49
+ if Kymera.is_linux?
50
+ if test["test"].include? 'c:'
51
+ test_path = test["test"].gsub('c:','~')
52
+ else
53
+ test_path = test["test"].gsub('C:','~')
54
+ end
55
+ else
56
+ test_path = test["test"]
57
+ end
58
+
59
+ results = runner.run_test(test_path, test['branch'])
60
+ JSON.generate({:run_id => test["run_id"], :test_count => test["test_count"], :runner => test["runner"], :results => results, :start_time => test["start_time"]} )
61
+ end
62
+
63
+ def stop
64
+ @test_socket.close
65
+ @results_socket.close
66
+ end
67
+
68
+ private
69
+
70
+ #TODO - I would like to add a way to dynamically add runners so that a user can custom build a runner and use it with this gem.
71
+ #Right now I am just doing some simple if/then logic to get predefined runners.
72
+ def get_runner(runner, options, run_id)
73
+ if runner.downcase == 'cucumber'
74
+ Kymera::Cucumber::Runner.new(options, run_id, @result_bus_socket)
75
+ else
76
+ nil
77
+ end
78
+ end
79
+
80
+
81
+ end
82
+ end
83
+
data/lib/kymera.rb ADDED
@@ -0,0 +1,88 @@
1
+ require 'ffi-rzmq'
2
+ require_relative 'kymera/szmq/szmq'
3
+ require_relative 'kymera/cucumber/cucumber_test_runner'
4
+ require_relative 'kymera/worker'
5
+ require_relative 'kymera/broker'
6
+ require_relative 'kymera/client'
7
+ require_relative 'kymera/cucumber/test_parser'
8
+ require_relative 'kymera/results_bus'
9
+ require_relative 'kymera/platform_utils'
10
+ require_relative 'kymera/test_results_collector'
11
+ require_relative 'kymera/cucumber/cucumber_results_parser'
12
+ require_relative '../lib/kymera/cucumber/cucumber_html_parser'
13
+ require_relative 'kymera/config/config'
14
+
15
+ module Kymera
16
+
17
+ #Start a test run
18
+ def self.run_tests(tests, test_runner, options, branch, real_time = true)
19
+ Kymera::Client.new(real_time).run_tests(tests, test_runner, options, branch)
20
+
21
+ end
22
+
23
+ #Start the test broker
24
+ def self.start_broker
25
+ Kymera::Broker.new.start_broker
26
+ end
27
+
28
+ #Start a worker
29
+ def self.start_worker
30
+ Kymera::Worker.new.listen
31
+ end
32
+
33
+ #Start the results collector
34
+ def self.start_collector
35
+ Kymera::TestResultsCollector.new.listen
36
+ end
37
+
38
+ #Start the results bus
39
+ def self.start_bus
40
+ Kymera::ResultsBus.new.start_bus
41
+ end
42
+
43
+ #Generate the default config.yaml file
44
+ def self.generate_config
45
+ require 'yaml'
46
+ puts "Generating congfig.yaml"
47
+ config_options = {
48
+ "client" => {
49
+ "broker_address" => 'tcp://127.0.0.1:5550',
50
+ "results_bus_address" => 'tcp://127.0.0.1:7001'
51
+ },
52
+ "broker" =>{
53
+ "client_listening_port" => '5550',
54
+ "worker_listening_port" => '5552',
55
+ "internal_worker_port" => '5551',
56
+ "number_of_connections" => '20'
57
+
58
+ },
59
+ "worker" => {
60
+ 'broker_address' => 'tcp://127.0.0.1:5552',
61
+ 'result_collector_address' => 'tcp://127.0.0.1:5556',
62
+ 'result_bus_address' => 'tcp://127.0.0.1:7000'
63
+ },
64
+ 'result_collector' =>{
65
+ 'inc_listening_port' => '5556',
66
+ 'result_bus_address' => 'tcp://127.0.0.1:7000',
67
+ 'send_mongo_results' => false,
68
+ 'mongodb_address' => '127.0.0.1',
69
+ 'mongodb_port' => 27017,
70
+ 'mongodb_database_name' => 'default_db',
71
+ 'mongodb_collection_name' => 'default_collection'
72
+
73
+ },
74
+ 'result_bus' => {
75
+ 'pub_port' => '7000',
76
+ 'sub_port' => '7001'
77
+ }
78
+ }
79
+ puts Dir.pwd
80
+ puts File.join(Dir.pwd, '/kymera_config.yaml')
81
+ config_file = File.open(File.join(Dir.pwd, '/kymera_config.yaml'), 'w+')
82
+ config_options.to_yaml.split('\n').each do |line|
83
+ config_file.write(line)
84
+ end
85
+ config_file.close
86
+ config_options.to_yaml
87
+ end
88
+ end
@@ -0,0 +1,25 @@
1
+ require 'ffi-rzmq'
2
+ require_relative '../../lib/kymera'
3
+ #require_relative '../../lib/kymera/v_3/kymera'
4
+ #
5
+ #broker = Kymera::Broker.new
6
+ #broker.set_test_queue('tcp://*:5556', 'tcp://*:5557')
7
+ #broker.set_confiq_queue('tcp://*:5540', 'tcp://*:5541')
8
+ #broker.set_result_queue('tcp://*:5530', 'tcp://*:5531')
9
+ #broker.start_broker
10
+
11
+ #zmq = Kymera::SZMQ.new
12
+ #
13
+ #front_end = zmq.socket('tcp://*:5555', 'router')
14
+ #back_end = zmq.socket('tcp://*:5556', 'dealer')
15
+ #zmq.start_proxy(front_end, back_end)
16
+
17
+ #context = ZMQ::Context.new
18
+ #front_end = context.socket(ZMQ::ROUTER)
19
+ #back_end = context.socket(ZMQ::DEALER)
20
+
21
+ broker = Kymera::Broker.new('tcp://*:5550', 'tcp://127.0.0.1:5551', 'tcp://*:5552', 20)
22
+ broker.start_broker
23
+
24
+
25
+
@@ -0,0 +1,21 @@
1
+ require 'ffi-rzmq'
2
+ require_relative '../../lib/kymera/v_4/kymera'
3
+ #client = Kymera::Client.new('tcp://localhost:5556')
4
+ #client.send_message("This is the message")
5
+ zmq = SZMQ.new
6
+
7
+ client = zmq.socket('tcp://127.0.0.1:5555', 'request')
8
+ client.connect
9
+
10
+ reply = client.send_message("This is a test")
11
+ puts reply
12
+
13
+ #context = ZMQ::Context.new
14
+ #socket = context.socket(ZMQ::PUSH)
15
+ #socket.bind('tcp://*:5555')
16
+ #socket.send_string("This is a message")
17
+ #reply = ''
18
+ #unless socket.recv_string(reply) == -1
19
+ # socket.recv_string(reply)
20
+ # puts reply
21
+ #end
@@ -0,0 +1,3 @@
1
+ # require_relative '../../lib/kymera'
2
+ require 'kymera'
3
+ Kymera.run_tests('~/apollo/source/integration_tests/features/login_and_session/login.feature', 'cucumber', ['-p default'], 'develop', true)
@@ -0,0 +1,51 @@
1
+ This is a list of different config options for the kymera gem
2
+
3
+ Client -
4
+ Broker address: ip address and port where the test broker is located
5
+ Results bus address: the ip address and port where the results bus is located
6
+
7
+ Broker -
8
+ Client Listening Port: what port to listen to for incoming test run requests
9
+ Worker Listening Port: What port to listen to for incoming worker connections
10
+ Number of Connections: This parameter is used to set the number of threads the broker will spawn for running tests. It is important to note that this number
11
+ needs to be larger than the number of connected workers. If not, the workers connected in excess of the number of threads will not be utilized
12
+ There are plans to change this behavior in the future
13
+
14
+ Worker -
15
+ Broker address: the ip address and port where the broker is located
16
+ Results Collector Address: the ip address and port where the results collector is located
17
+ Results Bus Address: the ip address and port where the results bus is located
18
+
19
+ Results Collector -
20
+ Incoming Listening Port: The port number where results will be coming in
21
+ Results Bus Address: The ip address and port where the outgoing aggregated results will be sent
22
+ Use Mongo DB: This is a bool telling the collector whether or not to send the results to a mongodb instance
23
+ MongoDB Address: The ip address and port number where the completed results will be sent for archiving
24
+ MongoDB Name: The name of the database that test collector will send the results to
25
+ MongoDB Collection Name: The name of the collection that the results will belong to
26
+
27
+ Results Bus -
28
+ Publish Port: The port which will be used for publishers to publish messages to the bus
29
+ Subscription Port: The port which will be used for subscribers to subscribe to
30
+
31
+
32
+ Passable arguments for each component of Kymera
33
+
34
+ Client -
35
+ real_time : This parameter is used to tell the client whether or not to display the realtime output from all of the test workers
36
+ tests : The file or director that contains the tests that need to be run
37
+ test_runner : This is the runner that Kymera will used to run the tests. Currently only Cucumber is supported. There are plans to extend that later
38
+ test_runner_options: These are the options specific to the test runner.
39
+ branch : This is the branch that the Kymera Workers should pull from to get the code that the user wishes to execute or test against
40
+
41
+ Broker -
42
+ none
43
+
44
+ Worker -
45
+ none
46
+
47
+ Results Collector -
48
+ none
49
+
50
+ Results Bus -
51
+ none
@@ -0,0 +1,44 @@
1
+ require 'kymera'
2
+ threads = []
3
+
4
+ trap('INT') do
5
+ threads.each do |thread|
6
+ thread.kill
7
+ end unless threads.empty?
8
+ end
9
+
10
+ #Results bus thread
11
+ threads << Thread.new {
12
+ bus = Kymera::ResultsBus.new('tcp://*:7000', 'tcp://*:7001')
13
+ bus.start_bus
14
+ }
15
+
16
+ #Broker thread
17
+ threads << Thread.new {
18
+ broker = Kymera::Broker.new('tcp://*:5550', 'tcp://127.0.0.1:5551', 'tcp://127.0.0.1:5552', 20)
19
+ broker.start_broker
20
+ }
21
+
22
+ #Results collector thread
23
+ threads << Thread.new {
24
+ results_collector = Kymera::TestResultsCollector.new('tcp://*:5556', 'tcp://127.0.0.1:7000')
25
+ results_collector.listen
26
+ }
27
+
28
+ #Worker thread
29
+ threads << Thread.new {
30
+ worker = Kymera::Worker.new('tcp://127.0.0.1:5552', 'tcp://127.0.0.1:5556', 'tcp://127.0.0.1:7000')
31
+ worker.listen
32
+ }
33
+
34
+ #give stuff a chance to start up
35
+ sleep 2
36
+
37
+ client = Kymera::Client.new('tcp://127.0.0.1:5550','tcp://127.0.0.1:7001')
38
+ client.run_tests('~/apollo/source/integration_tests/features/login_and_session/logout.feature', 'cucumber', ['-p default'])
39
+ #client.run_tests('c:/apollo/source/integration_tests/features', 'cucumber', ['-p dev'])
40
+
41
+
42
+
43
+
44
+
@@ -0,0 +1,44 @@
1
+ require 'kymera'
2
+ threads = []
3
+
4
+ trap('INT') do
5
+ threads.each do |thread|
6
+ thread.kill
7
+ end unless threads.empty?
8
+ end
9
+
10
+ #Results bus thread
11
+ threads << Thread.new {
12
+ bus = Kymera::ResultsBus.new('tcp://*:7000', 'tcp://*:7001')
13
+ bus.start_bus
14
+ }
15
+
16
+ #Broker thread
17
+ threads << Thread.new {
18
+ broker = Kymera::Broker.new('tcp://*:5550', 'tcp://127.0.0.1:5551', 'tcp://127.0.0.1:5552', 20)
19
+ broker.start_broker
20
+ }
21
+
22
+ #Results collector thread
23
+ threads << Thread.new {
24
+ results_collector = Kymera::TestResultsCollector.new('tcp://*:5556', 'tcp://127.0.0.1:7000')
25
+ results_collector.listen
26
+ }
27
+
28
+ #Worker thread
29
+ threads << Thread.new {
30
+ worker = Kymera::Worker.new('tcp://127.0.0.1:5552', 'tcp://127.0.0.1:5556', 'tcp://127.0.0.1:7000')
31
+ worker.listen
32
+ }
33
+
34
+ #give stuff a chance to start up
35
+ sleep 2
36
+
37
+ client = Kymera::Client.new('tcp://127.0.0.1:5550','tcp://127.0.0.1:7001')
38
+ client.run_tests('c:/apollo/source/integration_tests/features/login_and_session/logout.feature', 'cucumber', ['-p default'])
39
+ client.run_tests('c:/apollo/source/integration_tests/features', 'cucumber', ['-p dev'])
40
+
41
+
42
+
43
+
44
+
@@ -0,0 +1,43 @@
1
+ require_relative '../../lib/kymera'
2
+
3
+ zmq = Kymera::SZMQ.new
4
+ sub_socket = zmq.socket('tcp://127.0.0.1:7001', 'sub')
5
+
6
+ #sub_socket2 = zmq.socket('tcp://127.0.0.1:7001', 'sub')
7
+
8
+ sub_socket.subscribe('results') do |channel, message|
9
+ $stdout << "."
10
+ puts channel
11
+ puts message
12
+ end
13
+ #Thread.new {
14
+ # sub_socket2.subscribe('BVTCQD0CZ11') do |channel, message|
15
+ # $stdout << "."
16
+ # end
17
+ #}
18
+ #
19
+ #
20
+ #sub_socket.subscribe('end_BVTCQD0CZ11') do |channel, message|
21
+ # puts channel
22
+ # puts message
23
+ #end
24
+
25
+
26
+ #context = ZMQ::Context.new
27
+ #socket = context.socket(ZMQ::SUB)
28
+ #socket.setsockopt(ZMQ::SUBSCRIBE, 'end_BVTCQD0CZ11')
29
+ #socket.connect('tcp://127.0.0.1:7001')
30
+ #
31
+ #socket_2 = context.socket(ZMQ::SUB)
32
+ #socket_2.setsockopt(ZMQ::SUBSCRIBE, 'BVTCQD0CZ11')
33
+ #socket_2.connect('tcp://127.0.0.1:7001')
34
+ #
35
+ #channel = ''
36
+ #message = ''
37
+ #
38
+ #loop do
39
+ # socket.recv_string(channel)
40
+ # socket.recv_string(message)
41
+ # puts channel
42
+ # puts message
43
+ #end
@@ -0,0 +1,61 @@
1
+
2
+ # require 'kymera'
3
+ require_relative '../../lib/kymera/cucumber/cucumber_html_parser'
4
+
5
+ results = "Using the default profile...
6
+ [36m@smoke_prod
7
+ Feature: Login
8
+
9
+ As a user
10
+ I want to login
11
+ So that I can do freight matching
12
+
13
+ # JS - no longer valid
14
+ # Scenario: e. the footer is present on the login page
15
+ # Given I am at the login page
16
+ # Then I see the Terms and Conditions link
17
+ # And I see the Privacy link
18
+ # And I see the DAT copyright string
19
+ Scenario: f. the footer is present on the welcome page # c:\apollo\source\integration_tests\features\login_and_session\login.feature:39
20
+ [32mGiven I am logged in # features/step_definitions/login/login_steps.rb:5
21
+ [32mThen I see the home page has the Terms and Conditions link # features/step_definitions/login/login_steps.rb:109
22
+ [32mAnd I see the home page has the Privacy link # features/step_definitions/login/login_steps.rb:113
23
+ [32mAnd I see the home page has the DAT copyright string # features/step_definitions/login/login_steps.rb:117
24
+
25
+ 1 scenario (1 passed)
26
+ 4 steps (4 passed)
27
+ 0m14.218s
28
+ Using the default profile...
29
+ [36m@smoke_prod
30
+ Feature: Login
31
+
32
+ As a user
33
+ I want to login
34
+ So that I can do freight matching
35
+
36
+ Scenario: d. invalid username, valid password # c:\apollo\source\integration_tests\features\login_and_session\login.feature:28
37
+ [32mGiven I login with invalid username and valid password # features/step_definitions/login/login_steps.rb:14
38
+ [32mThen I see an invalid login message # features/step_definitions/login/login_steps.rb:78
39
+
40
+ 1 scenario (1 passed)
41
+ 2 steps (2 passed)
42
+ 0m22.000s
43
+ Using the default profile...
44
+ [36m@smoke_prod
45
+ Feature: Login
46
+
47
+ As a user
48
+ I want to login
49
+ So that I can do freight matching
50
+
51
+ Scenario: c. valid username, invalid password # c:\apollo\source\integration_tests\features\login_and_session\login.feature:23
52
+ [32mGiven I login with valid username and invalid password # features/step_definitions/login/login_steps.rb:9
53
+ [32mThen I see an invalid login message # features/step_definitions/login/login_steps.rb:78
54
+
55
+ 1 scenario (1 passed)
56
+ 2 steps (2 passed)
57
+ 0m23.261s"
58
+
59
+
60
+ parsed_results = Kymera::Cucumber::HTMLResultsParser.to_html(results)
61
+ puts parsed_results
@@ -0,0 +1,31 @@
1
+ 1. take the results and parse them into an array with new line (\n) as the delimiter
2
+ 2. iterate over the array
3
+ 3. if line starts with "Using"
4
+ 3a. create a string variable with an open div hmtl tag with the class feature
5
+ 3b. append a open paragraph html tag to that variable
6
+ 3c. append the line to the variable
7
+
8
+ 4. until line starts with "Using"
9
+ 4a. move to the next line
10
+ 4b. if the line contains \e
11
+ 4c. iterate over the line and for every \e do the following
12
+ 4d. if the next 3 characters match 36m
13
+ 4e. append an open span tag to the string variable with the style color blue
14
+ 4f. if the next 3 characters match 90m
15
+ 4g.append an open span tag to the string variable with the style color gray
16
+ 4h. if the next 3 characters match 31m
17
+ 4i. append an open span tag to the string variable with the style color red
18
+ 4j if the next 3 characters match 0m
19
+ 4k. append a closing span tag to the string variable and start again at step 4a
20
+ 4l. if there are no other instances of \e
21
+ 4m. append the remainder of the line and a close span tag to the string variable
22
+ 4n. if there are more instances of \e
23
+ 4o. until you reach the next instance of \e
24
+ 4p. continue iterating over the line, appending each character to the sting variable
25
+ 4q. when you reach the next instance of \e start again at step 4d
26
+
27
+ add check for characters after 0m
28
+
29
+
30
+
31
+
@@ -0,0 +1,6 @@
1
+ { "run_id" : "1",
2
+ "test" : "./feature/login_and_session/login.feature",
3
+ "runner" : "cucumber",
4
+ "options" : ["-p default"]
5
+ }
6
+
@@ -0,0 +1,5 @@
1
+ require_relative '../../lib/kymera'
2
+
3
+ message = JSON.generate({name: "test"})
4
+
5
+ Kymera::MongoDriver.log_results(message)
@@ -0,0 +1,44 @@
1
+ require 'ffi-rzmq'
2
+
3
+ context = ZMQ::Context.new
4
+ front_end_socket = context.socket(ZMQ::ROUTER)
5
+ front_end_socket.bind('tcp://*:5550')
6
+
7
+ back_end_socket = context.socket(ZMQ::DEALER)
8
+ back_end_socket.bind('tcp://*:5551')
9
+
10
+ ZMQ::Device.new(front_end_socket, back_end_socket)
11
+
12
+ #require 'rubygems'
13
+ #require 'ffi-rzmq'
14
+ #
15
+ #context = ZMQ::Context.new
16
+ #frontend = context.socket(ZMQ::ROUTER)
17
+ #backend = context.socket(ZMQ::DEALER)
18
+ #
19
+ #frontend.bind('tcp://*:5550')
20
+ #backend.connect('tcp://127.0.0.1:5551')
21
+ #
22
+ #message = []
23
+ #
24
+ #frontend.recv_strings message
25
+ #puts message
26
+ #
27
+ #backend.send_strings(message)
28
+
29
+ #poller = ZMQ::Poller.new
30
+ #poller.register(frontend, ZMQ::POLLIN)
31
+ #poller.register(backend, ZMQ::POLLIN)
32
+ #
33
+ #loop do
34
+ # poller.poll(:blocking)
35
+ # poller.readables.each do |socket|
36
+ # if socket === frontend
37
+ # socket.recv_strings(messages = [])
38
+ # backend.send_strings(messages)
39
+ # elsif socket === backend
40
+ # socket.recv_strings(messages = [])
41
+ # frontend.send_strings(messages)
42
+ # end
43
+ # end
44
+ #end
@@ -0,0 +1,13 @@
1
+ require 'ffi-rzmq'
2
+
3
+ context = ZMQ::Context.new
4
+ socket = context.socket(ZMQ::REP)
5
+ socket.connect 'tcp://127.0.0.1:5551'
6
+
7
+ message = ''
8
+
9
+ socket.recv_string message
10
+
11
+ puts message
12
+
13
+ socket.send_string "Got the messsage"
@@ -0,0 +1,13 @@
1
+ require 'ffi-rzmq'
2
+
3
+ context = ZMQ::Context.new
4
+ socket = context.socket(ZMQ::REQ)
5
+ socket.connect('tcp://127.0.0.1:5550')
6
+
7
+ socket.send_string "This is a message"
8
+
9
+ reply = ''
10
+
11
+ socket.recv_string reply
12
+
13
+ puts reply
@@ -0,0 +1,13 @@
1
+ require_relative '../../lib/kymera'
2
+
3
+ bus = Kymera::ResultsBus.new('tcp://*:7000', 'tcp://*:7001')
4
+ bus.start_bus
5
+
6
+ #context = ZMQ::Context.new
7
+ #front_end_socket = context.socket(ZMQ::XSUB)
8
+ #back_end_socket = context.socket(ZMQ::XPUB)
9
+ #
10
+ #front_end_socket.connect('tcp://127.0.0.1:7000')
11
+ #back_end_socket.bind('tcp://*:7001')
12
+ #
13
+ #ZMQ::Device.new(front_end_socket, back_end_socket)
@@ -0,0 +1,18 @@
1
+ require_relative '../../lib/kymera'
2
+ #zmq = Kymera::SZMQ.new
3
+ #
4
+ #socket = zmq.socket('tcp://*:5556', 'pull')
5
+ #socket.bind
6
+ #socket.receive do |results|
7
+ # puts results
8
+ #end
9
+
10
+ #context = ZMQ::Context.new
11
+ #socket = context.socket(ZMQ::PULL)
12
+ #socket.bind('tcp://127.0.0.1:5555')
13
+ #message = ''
14
+ #socket.recv_string(message)
15
+ #puts message
16
+
17
+ results_parser = Kymera::TestResultsCollector.new('tcp://*:5556', 'tcp://127.0.0.1:7000')
18
+ results_parser.listen
@@ -0,0 +1,16 @@
1
+ require_relative '../../lib/kymera'
2
+
3
+ zmq = Kymera::SZMQ.new
4
+ #
5
+ pub_socket = zmq.socket('tcp://127.0.0.1:7000', 'pub')
6
+ pub_socket.connect
7
+ pub_socket.publish_message('results', 'these are results')
8
+
9
+ #context = ZMQ::Context.new
10
+ #socket = context.socket(ZMQ::PUB)
11
+ #socket.connect('tcp://127.0.0.1:7000')
12
+ #sleep 5
13
+ #socket.send_string('results', ZMQ::SNDMORE)
14
+ #socket.send_string('these are some more results')
15
+
16
+
@@ -0,0 +1,35 @@
1
+ require 'kymera'
2
+ threads = []
3
+
4
+ trap('INT') do
5
+ threads.each do |thread|
6
+ thread.kill
7
+ end unless threads.empty?
8
+ @close = true
9
+ end
10
+
11
+ #Results bus thread
12
+ threads << Thread.new {
13
+ # bus = Kymera::ResultsBus.new('tcp://*:7000', 'tcp://*:7001')
14
+ # bus.start_bus
15
+ Kymera.start_bus
16
+ }
17
+
18
+ #Broker thread
19
+ threads << Thread.new {
20
+ # broker = Kymera::Broker.new('tcp://*:5550', 'tcp://*:5551', 'tcp://*:5552', 20)
21
+ # broker.start_broker
22
+ Kymera.start_broker
23
+ }
24
+
25
+ #Results collector thread
26
+ threads << Thread.new {
27
+ # results_collector = Kymera::TestResultsCollector.new('tcp://*:5556', 'tcp://127.0.0.1:7000')
28
+ # results_collector = Kymera::TestResultsCollector.new('tcp://*:5556', 'tcp://10.6.49.60:7000')
29
+ # results_collector.listen
30
+ Kymera.start_collector
31
+ }
32
+
33
+ loop do
34
+ raise SystemExit if @close
35
+ end