oats 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -2
- data/bin/oats +2 -9
- data/lib/oats/driver.rb +10 -61
- data/lib/oats/report.rb +1 -1
- data/lib/oats/user_api.rb +1 -1
- data/lib/oats/version.rb +1 -1
- data/lib/oats.rb +1 -2
- data/oats.gemspec +1 -8
- data/oats_tests/bin/oats +1 -7
- data/oats_tests/bin/oats.rb +11 -0
- metadata +4 -38
- data/bin/agent +0 -174
- data/bin/occ +0 -29
- data/bin/results_cleanup +0 -6
- data/lib/oats/patches_for_eventmachine_12.10.rb +0 -66
- data/lib/oats/ragent.rb +0 -321
- data/lib/oats/rclient.rb +0 -42
data/Gemfile
CHANGED
data/bin/oats
CHANGED
@@ -1,10 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
$:.unshift File.expand_path('../lib', dir )
|
5
|
-
require 'oats'
|
6
|
-
if $oats_execution['options']["_:agent"]
|
7
|
-
Oats::Driver.agent
|
8
|
-
else
|
9
|
-
Oats.run
|
10
|
-
end
|
2
|
+
require File.expand_path('../../lib/oats', __FILE__ )
|
3
|
+
Oats.run
|
data/lib/oats/driver.rb
CHANGED
@@ -9,39 +9,7 @@ module Oats
|
|
9
9
|
|
10
10
|
module Driver
|
11
11
|
|
12
|
-
def Driver.
|
13
|
-
ENV['KILL_AGENT' ] = 'KILL_AGENT' if $oats_execution['options']["_:kill_agent"]
|
14
|
-
ENV['OATS_USER' ] = $oats_execution['options']["_:oats_user"] if $oats_execution['options']["_:oats_user"]
|
15
|
-
ENV['OATS_TESTS_REPOSITORY_VERSION' ] = $oats_execution['options']["_:repository_version"] if $oats_execution['options']["_:repository_version"]
|
16
|
-
nick = $oats_execution['options']["execution:occ:agent_nickname"]
|
17
|
-
ENV['OATS_AGENT_NICKNAME' ] = nick if nick
|
18
|
-
port = $oats_execution['options']["execution:occ:agent_port"].to_s
|
19
|
-
ENV['OATS_AGENT_PORT'] = port if port
|
20
|
-
dir = ENV['HOME'] + "/results_archive/#{nick}/agent_logs"
|
21
|
-
FileUtils.mkdir_p(dir) unless File.exists?(dir)
|
22
|
-
ENV['OATS_AGENT_CONFIG_FILE'] = "#{dir}/config-agent.txt"
|
23
|
-
dat = `date +'%m%d%H%M%S'`.chomp
|
24
|
-
log_file = "#{dir}/agent_#{dat}.log"
|
25
|
-
ENV['OATS_AGENT_LOGFILE'] = log_file
|
26
|
-
agent_log_file = "#{dir}/agent.log"
|
27
|
-
cmd = ENV['OATS_HOME'] + '/bin/agent'
|
28
|
-
pid = `#{cmd}`.chomp
|
29
|
-
puts "Running PID: " + pid + ', Log: ' + log_file
|
30
|
-
# echo "$NICKNAME $PORT $PID $DISPLAY_NUM" >| $config_agent_file
|
31
|
-
10.times do
|
32
|
-
if File.exist? log_file
|
33
|
-
FileUtils.rm_f agent_log_file
|
34
|
-
FileUtils.ln log_file, agent_log_file
|
35
|
-
break
|
36
|
-
end
|
37
|
-
sleep 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Main method that starts oats execution in either agent or standalone mode.
|
42
|
-
# Parameters are command-line arguments
|
43
|
-
# Returns oats_info object containing execution results
|
44
|
-
def Driver.run(args)
|
12
|
+
def Driver.init(args=nil)
|
45
13
|
unless ENV['HOSTNAME']
|
46
14
|
if RUBY_PLATFORM =~ /(mswin|mingw)/
|
47
15
|
ENV['HOSTNAME'] = ENV['COMPUTERNAME']
|
@@ -49,7 +17,6 @@ module Oats
|
|
49
17
|
ENV['HOSTNAME'] = `hostname`.chomp
|
50
18
|
end
|
51
19
|
end
|
52
|
-
|
53
20
|
Log4r::Logger.root.level = Log4r::DEBUG
|
54
21
|
Log4r::StdoutOutputter.new('console', :level=>1,
|
55
22
|
:formatter=>Log4r::PatternFormatter.new(:depth=>50,
|
@@ -62,33 +29,15 @@ module Oats
|
|
62
29
|
@@quiet = options['_:quiet'] # save quiet option from initial commandline options
|
63
30
|
$log.remove('console') if @@quiet
|
64
31
|
ENV['HOME'] = Util.expand_path(ENV['HOME']) if ENV['HOME'] # Normalize for cygwin
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
options['execution:occ:agent_port'] = $oats['execution']['occ']['agent_port']
|
75
|
-
options['execution:occ:agent_nickname'] = ($oats['execution']['occ']['agent_nickname'] || options['execution:occ:agent_host'].sub(/\..*/,''))
|
76
|
-
$oats['execution']['occ']['agent_nickname'] = options['execution:occ:agent_nickname']
|
77
|
-
|
78
|
-
if options['_:command']
|
79
|
-
require 'oats/rclient'
|
80
|
-
options['_:id'] = Time.now.to_i.to_s
|
81
|
-
request = { :command => options['_:command'], :args => options['_:args'] }
|
82
|
-
request[:id] = options['_:id'] if options['_:id']
|
83
|
-
EventMachine::run { EventMachine::connect options['execution:occ:agent_host'],
|
84
|
-
options['execution:occ:agent_port'].to_i, Rclient, options['execution:occ:agent_host'], request
|
85
|
-
}
|
86
|
-
else
|
87
|
-
Ragent.start $oats['execution']['occ']
|
88
|
-
end
|
89
|
-
else
|
90
|
-
Driver.start(nil,options)
|
91
|
-
end
|
32
|
+
options
|
33
|
+
end
|
34
|
+
|
35
|
+
# Main method that starts oats execution in either agent or standalone mode.
|
36
|
+
# Parameters are command-line arguments
|
37
|
+
# Returns oats_info object containing execution results
|
38
|
+
def Driver.run(args)
|
39
|
+
options = Driver.init(args)
|
40
|
+
Driver.start(nil,options)
|
92
41
|
$oats_info
|
93
42
|
end
|
94
43
|
|
data/lib/oats/report.rb
CHANGED
@@ -140,8 +140,8 @@ module Oats
|
|
140
140
|
$log.error exc
|
141
141
|
return oats_info
|
142
142
|
end
|
143
|
+
OatsAgent::Ragent.snapshot_oats_info(rinfo) if $oats_execution['agent']
|
143
144
|
begin
|
144
|
-
Ragent.snapshot_oats_info(rinfo) if $oats_execution['agent']
|
145
145
|
FileUtils.mv(results_file_tmp, results_file)
|
146
146
|
rescue
|
147
147
|
$log.error "Error moving [#{results_file_tmp}]. Skipping saving the intermediate results."
|
data/lib/oats/user_api.rb
CHANGED
@@ -183,7 +183,7 @@ module Oats
|
|
183
183
|
oats_data['execution']['dir_results'] = Util.expand_path(oats_data['execution']['dir_results'])
|
184
184
|
oats_data['result_archive_dir'] = oats_data['execution']['dir_results'] + '_archive'
|
185
185
|
if $oats_execution['agent']
|
186
|
-
agent_nickname = Ragent.occ['agent_nickname']
|
186
|
+
agent_nickname = OatsAgent::Ragent.occ['agent_nickname']
|
187
187
|
if oats_data['execution']['dir_results'] !~ /#{agent_nickname}$/
|
188
188
|
# Should move to a better place.This is unrelated to results, Just picking up the agent file.
|
189
189
|
agent_ini_file = File.join(ENV['HOME'], agent_nickname + '_oats.yml')
|
data/lib/oats/version.rb
CHANGED
data/lib/oats.rb
CHANGED
@@ -23,9 +23,8 @@ require 'oats/keywords'
|
|
23
23
|
|
24
24
|
# GEMS needed by OATS.
|
25
25
|
require 'rubygems'
|
26
|
-
require "bundler/setup"
|
26
|
+
#require "bundler/setup"
|
27
27
|
#Bundler.require
|
28
|
-
#gem 'log4r'
|
29
28
|
#require 'deep_merge' # Need modified version of https://github.com/danielsdeleo/deep_merge for 1.9 compatibility
|
30
29
|
require 'log4r' # http://log4r.sourceforge.net/rdoc/index.html
|
31
30
|
|
data/oats.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = File.directory?('.git') ? `git ls-files -- {test,spec,features}/*`.split("\n") : []
|
18
18
|
end
|
19
19
|
# s.test_files = ["test/test_cgi_wrapper.rb" ]
|
20
|
-
s.executables = %w{oats
|
20
|
+
s.executables = %w{oats}
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
23
|
# s.extra_rdoc_files = ["CHANGELOG", "COPYING", "lib/oats/oats.rb", "LICENSE", "README"]
|
@@ -32,12 +32,5 @@ Gem::Specification.new do |s|
|
|
32
32
|
|
33
33
|
if RUBY_PLATFORM =~ /(mswin|mingw)/ # Assume won't use the agent
|
34
34
|
s.add_dependency 'win32-process'
|
35
|
-
else
|
36
|
-
s.add_dependency 'json'
|
37
|
-
s.add_dependency 'em-http-request'
|
38
|
-
if RUBY_PLATFORM =~ /linux/ # Seems to be needed by Ubuntu
|
39
|
-
s.add_dependency 'execjs'
|
40
|
-
s.add_dependency 'therubyracer'
|
41
|
-
end
|
42
35
|
end
|
43
36
|
end
|
data/oats_tests/bin/oats
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
ENV['OATS_TESTS'] ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
|
3
|
+
oats_lib = File.expand_path('../oats/lib', ENV['OATS_TESTS'])
|
4
|
+
if File.directory?(oats_lib) and false
|
5
|
+
$:.unshift(oats_lib)
|
6
|
+
else
|
7
|
+
require 'rubygems' unless defined? Gem
|
8
|
+
gem 'oats'
|
9
|
+
end
|
10
|
+
require 'oats'
|
11
|
+
Oats.run
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Levent Atasoy
|
@@ -45,40 +45,11 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: json
|
50
|
-
prerelease: false
|
51
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
|
-
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
hash: 3
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
60
|
-
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: em-http-request
|
64
|
-
prerelease: false
|
65
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
hash: 3
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
version: "0"
|
74
|
-
type: :runtime
|
75
|
-
version_requirements: *id004
|
76
48
|
description: A flexible automated system integration regression test framework.
|
77
49
|
email:
|
78
50
|
- levent.atasoy@gmail.com
|
79
51
|
executables:
|
80
52
|
- oats
|
81
|
-
- occ
|
82
53
|
extensions: []
|
83
54
|
|
84
55
|
extra_rdoc_files: []
|
@@ -89,10 +60,7 @@ files:
|
|
89
60
|
- Gemfile
|
90
61
|
- README.txt
|
91
62
|
- Rakefile
|
92
|
-
- bin/agent
|
93
63
|
- bin/oats
|
94
|
-
- bin/occ
|
95
|
-
- bin/results_cleanup
|
96
64
|
- doc/COPYING
|
97
65
|
- doc/LICENSE
|
98
66
|
- doc/OATS_Framework.doc
|
@@ -119,9 +87,6 @@ files:
|
|
119
87
|
- lib/oats/oats_selenium_api.rb
|
120
88
|
- lib/oats/oselenium.rb
|
121
89
|
- lib/oats/ossh.rb
|
122
|
-
- lib/oats/patches_for_eventmachine_12.10.rb
|
123
|
-
- lib/oats/ragent.rb
|
124
|
-
- lib/oats/rclient.rb
|
125
90
|
- lib/oats/report.rb
|
126
91
|
- lib/oats/roptions.rb
|
127
92
|
- lib/oats/test_case.rb
|
@@ -141,6 +106,7 @@ files:
|
|
141
106
|
- oats_tests/Gemfile
|
142
107
|
- oats_tests/aut_ini.yml
|
143
108
|
- oats_tests/bin/oats
|
109
|
+
- oats_tests/bin/oats.rb
|
144
110
|
- oats_tests/environments/qa.yml
|
145
111
|
- oats_tests/environments/qa_chrome.yml
|
146
112
|
- oats_tests/examples/core/coreExamples.yml
|
data/bin/agent
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
# This script is used to start OATS in agent mode and communicate with OCC.
|
3
|
-
|
4
|
-
[ "$OS" ] || export OS=$(uname)
|
5
|
-
if [ "$OS" == "Windows_NT" ]; then
|
6
|
-
export PATH="$PATH:/cygdrive/c/apps/cygwin/bin"
|
7
|
-
[ "$HOSTNAME" ] || HOSTNAME="$COMPUTERNAME"
|
8
|
-
else
|
9
|
-
[ "$HOSTNAME" ] || HOSTNAME=`hostname`
|
10
|
-
fi
|
11
|
-
export HOSTNAME
|
12
|
-
[ "$OATS_AGENT_NICKNAME" ] || OATS_AGENT_NICKNAME=${HOSTNAME/.*}
|
13
|
-
doc="
|
14
|
-
Starts OATS agent to be used with OCC
|
15
|
-
|
16
|
-
USAGE: agent [-k[ill]] [-n[ickname] OATS_AGENT_NICKNAME] [ -p[ort] OATS_AGENT_PORT ]
|
17
|
-
[ -r[epo] OATS_TESTS_REPOSITORY_VERSION ] [ -u OATS_USER]
|
18
|
-
|
19
|
-
Parameters: (also can be passed in via environment variables
|
20
|
-
-n OATS_AGENT_NICKNAME OCC ID of the agent.
|
21
|
-
-p OATS_AGENT_PORT Agent port to communicate with OCC. Default is port previously
|
22
|
-
used for OATS_AGENT_NICKNAME.
|
23
|
-
-u OATS_USER who started the agent. Used for logging purposes only.
|
24
|
-
-r OATS_TESTS_REPOSITORY_VERSION Required to update the agent.
|
25
|
-
-k kill the agent, or set OATS_KILL_AGENT
|
26
|
-
|
27
|
-
Example:
|
28
|
-
/home/occadmin/oats/bin/agent -p 3011 -n occ_1 -r 403cc620c265db84dbd3fb7d7cce4d57416bff09
|
29
|
-
|
30
|
-
The agent script should be in the path so that ssh from occ can pick it up.
|
31
|
-
Git requires definition of OATS_TESTS_GIT_REPOSITORY environment variable.
|
32
|
-
"
|
33
|
-
input_pars="$@"
|
34
|
-
while [ "$1" ]; do
|
35
|
-
case $1 in
|
36
|
-
-p*) shift; OATS_AGENT_PORT="$1" ;;
|
37
|
-
-n*) shift; OATS_AGENT_NICKNAME="$1" ;;
|
38
|
-
-u*) shift; OATS_USER="$1" ;;
|
39
|
-
-k*) OATS_KILL_AGENT='OATS_KILL_AGENT' ;;
|
40
|
-
-r*) shift; OATS_TESTS_REPOSITORY_VERSION="$1" ;;
|
41
|
-
-d*) shift; DISPLAY_NUM="$1" ;;
|
42
|
-
*) echo "Unrecognized parameter: $1" ;
|
43
|
-
echo "$doc"
|
44
|
-
exit ;;
|
45
|
-
esac
|
46
|
-
shift
|
47
|
-
done
|
48
|
-
|
49
|
-
function agent_echo {
|
50
|
-
echo "$(date +'%m/%d/%H:%M:%S') $*"
|
51
|
-
}
|
52
|
-
function fkill {
|
53
|
-
agent_echo "Killing PID: $each_pid"
|
54
|
-
if [ "$OS" == "Windows_NT" ]; then
|
55
|
-
pskill $1
|
56
|
-
else
|
57
|
-
kill -9 $1
|
58
|
-
fi
|
59
|
-
}
|
60
|
-
|
61
|
-
{
|
62
|
-
agent_echo "Invoking $0 $input_pars"
|
63
|
-
|
64
|
-
# Need these off when called by OCC, otherwise they OCC values are inherited
|
65
|
-
unset RUBYOPT BUNDLE_BIN_PATH BUNDLE_GEMFILE # GEM_HOME GEM_PATH # RAILS_ENV
|
66
|
-
[ "$OATS_TESTS_GIT_REPOSITORY" ] && export OATS_TESTS="$HOME/results_archive/$OATS_AGENT_NICKNAME"/oats_tests
|
67
|
-
ruby_com="$(dirname $(type -p $0))/oats -n $OATS_AGENT_NICKNAME -p $OATS_AGENT_PORT"
|
68
|
-
if [ -e "$config_agent_file" ]; then
|
69
|
-
line=$(grep "^$OATS_AGENT_NICKNAME" "$config_agent_file")
|
70
|
-
read nickname PREV_OATS_AGENT_PORT pid display<<< $line
|
71
|
-
[ "$OATS_AGENT_PORT" ] || OATS_AGENT_PORT=$PREV_OATS_AGENT_PORT
|
72
|
-
[ "$PID" ] || PID=$pid
|
73
|
-
if [ -z "$DISPLAY_NUM" ]; then
|
74
|
-
if [ "$display" ]; then
|
75
|
-
DISPLAY_NUM=$(echo "$display" | sed -e 's/.*:\(.\).*/\1/')
|
76
|
-
[ "$DISPLAY_NUM" ] || DISPLAY_NUM="$display"
|
77
|
-
else
|
78
|
-
DISPLAY_NUM='0'
|
79
|
-
fi
|
80
|
-
fi
|
81
|
-
fi
|
82
|
-
if [ -z "$OATS_AGENT_PORT" ]; then
|
83
|
-
agent_echo "$0: Must specify a port, exiting..." >&2
|
84
|
-
exit 1
|
85
|
-
fi
|
86
|
-
|
87
|
-
[ "$OATS_AGENT_PORT" == "$PREV_OATS_AGENT_PORT" ] && PREV_OATS_AGENT_PORT=''
|
88
|
-
for OATS_AGENT_PORT_VAR in $PREV_OATS_AGENT_PORT $OATS_AGENT_PORT; do
|
89
|
-
skip_port=''
|
90
|
-
if [ "$PID" -a "$OATS_AGENT_PORT_VAR" == "$PREV_OATS_AGENT_PORT" ]; then
|
91
|
-
agent_echo "Attempting to kill agent $OATS_AGENT_NICKNAME with PID: $PID"
|
92
|
-
fkill $PID
|
93
|
-
[ $? == 0 ] && skip_port=skip_port
|
94
|
-
fi
|
95
|
-
if [ -z "$skip_port" ]; then
|
96
|
-
# agent_echo "Attempting to kill process holding on to port $OATS_AGENT_PORT_VAR"
|
97
|
-
if [ "$OS" == Darwin ]; then
|
98
|
-
lines=$(ps -ef|grep "$ruby_com"|grep -v grep)
|
99
|
-
PID=$(echo $(cut -c 6-11 <<< "$lines"))
|
100
|
-
else
|
101
|
-
if [ "$OS" == Windows_NT ]; then # Killing the top level bash process doesn't cut it
|
102
|
-
lines=$(netstat -a -o 2>/dev/null| grep "$OATS_AGENT_PORT_VAR .* LISTEN" )
|
103
|
-
else
|
104
|
-
lines=$(netstat -n -p -l 2>/dev/null| grep "$OATS_AGENT_PORT_VAR .* LISTEN" )
|
105
|
-
fi
|
106
|
-
PID=$(echo "$line" | sed 's/.* LISTEN[^ ]* *//;s/.ruby .*//')
|
107
|
-
[ "$PID" -a "$PID" != "$line" ] || PID=''
|
108
|
-
fi
|
109
|
-
if [ "$PID" ]; then
|
110
|
-
agent_echo "PS line(s): $lines"
|
111
|
-
for each_pid in $PID; do
|
112
|
-
fkill $each_pid
|
113
|
-
done
|
114
|
-
# else
|
115
|
-
# agent_echo "No agent is found on port $OATS_AGENT_PORT_VAR"
|
116
|
-
fi
|
117
|
-
fi
|
118
|
-
done
|
119
|
-
[ "$OATS_KILL_AGENT" ] && return
|
120
|
-
|
121
|
-
if [ -d $OATS_TESTS/.svn ]; then
|
122
|
-
COUNTER=0
|
123
|
-
[ "$OATS_TESTS_REPOSITORY_VERSION" ] && agent_echo "Requested OATS Version: $OATS_TESTS_REPOSITORY_VERSION"
|
124
|
-
while [ $COUNTER -lt 5 ]; do
|
125
|
-
let COUNTER=COUNTER+1
|
126
|
-
OATS_TESTS_CODE_VERSION=$(svn info $OATS_TESTS | sed -n 's/Last Changed Rev: *//p')
|
127
|
-
[ "$OATS_TESTS_REPOSITORY_VERSION" ] || break
|
128
|
-
[ "$OATS_TESTS_CODE_VERSION" -ge "$OATS_TESTS_REPOSITORY_VERSION" ] && break
|
129
|
-
[ $COUNTER -eq 1 ] || sleep 3
|
130
|
-
svn update $OATS_TESTS 2>&1
|
131
|
-
done
|
132
|
-
if [ $COUNTER -eq 5 ]; then
|
133
|
-
agent_echo "Could not update the code version $OATS_TESTS_CODE_VERSION to $OATS_TESTS_REPOSITORY_VERSION" >&2
|
134
|
-
return 2
|
135
|
-
fi
|
136
|
-
agent_echo "Current OATS code version: $OATS_TESTS_CODE_VERSION"
|
137
|
-
elif [ "$OATS_TESTS_GIT_REPOSITORY" ]; then
|
138
|
-
[ -d $OATS_TESTS ] || git clone $OATS_TESTS_GIT_REPOSITORY $OATS_TESTS
|
139
|
-
cd $OATS_TESTS
|
140
|
-
origin="$OATS_TESTS_GIT_REPOSITORY"
|
141
|
-
[ "$origin" ] || origin=origin
|
142
|
-
if [ "$OATS_TESTS_REPOSITORY_VERSION" ]; then
|
143
|
-
for i in 1 2; do
|
144
|
-
out=$(git checkout $OATS_TESTS_REPOSITORY_VERSION 2>&1) && break # may detach HEAD, but it is OK
|
145
|
-
if [ "$out" == "fatal: reference is not a tree: $OATS_TESTS_REPOSITORY_VERSION" ]; then
|
146
|
-
echo -n "Need to pull requested version: $OATS_TESTS_REPOSITORY_VERSION "
|
147
|
-
else
|
148
|
-
echo "$out"
|
149
|
-
fi
|
150
|
-
git pull $origin master # fast-forward master from origin
|
151
|
-
done
|
152
|
-
else
|
153
|
-
git pull $origin master # fast-forward master from origin
|
154
|
-
fi
|
155
|
-
OATS_TESTS_CODE_VERSION=$(git rev-list HEAD -1) # last commit in checked out version
|
156
|
-
if [ "${OATS_TESTS_CODE_VERSION##$OATS_TESTS_REPOSITORY_VERSION*}" ]; then
|
157
|
-
agent_echo "Could not update the code version $OATS_TESTS_CODE_VERSION to $OATS_TESTS_REPOSITORY_VERSION" >&2
|
158
|
-
return 2
|
159
|
-
fi
|
160
|
-
[ "$OATS_TESTS_REPOSITORY_VERSION" ] || agent_echo "Using OATS code version: $OATS_TESTS_CODE_VERSION"
|
161
|
-
else
|
162
|
-
OATS_TESTS_CODE_VERSION=$OATS_TESTS_REPOSITORY_VERSION
|
163
|
-
[ "$OATS_TESTS_CODE_VERSION" ] && agent_echo "Setting OATS code version to the requested version: $OATS_TESTS_CODE_VERSION]" # This is not set for development/debug
|
164
|
-
fi
|
165
|
-
export OATS_TESTS_CODE_VERSION
|
166
|
-
cd $OATS_HOME # Needed for bundler
|
167
|
-
agent_echo "Starting agent $OATS_AGENT_NICKNAME on port $OATS_AGENT_PORT"
|
168
|
-
$ruby_com
|
169
|
-
} >> $OATS_AGENT_LOGFILE 2>&1 &
|
170
|
-
|
171
|
-
PID=$(jobs -p)
|
172
|
-
echo "Initiated PID: $PID" >> $OATS_AGENT_LOGFILE
|
173
|
-
echo "$PID"
|
174
|
-
echo "$OATS_AGENT_NICKNAME $OATS_AGENT_PORT $PID $DISPLAY_NUM" >| $OATS_AGENT_CONFIG_FILE
|
data/bin/occ
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This script is used to start OCC
|
4
|
-
|
5
|
-
#[ "$RAILS_ENV" ] || export RAILS_ENV="production"
|
6
|
-
occ_home = ENV['OATS_OCC_HOME']
|
7
|
-
unless occ_home
|
8
|
-
pwd = Dir.pwd
|
9
|
-
occ_home = pwd if File.basename(pwd) == 'occ'
|
10
|
-
end
|
11
|
-
occ_home = ENV['HOME'] + '/occ' unless occ_home
|
12
|
-
occ_home = ENV['HOME'] + '/NetBeansProjects/occ' unless File.directory?(occ_home)
|
13
|
-
|
14
|
-
raise "Must define OCC_HOME or be in occ directory to run this command." unless occ_home
|
15
|
-
|
16
|
-
Dir.chdir(occ_home)
|
17
|
-
exec 'ruby script/rails server mongrel' # -p 4000
|
18
|
-
|
19
|
-
# By pass the following unless using distributed agents
|
20
|
-
# if [ "$OS" != "Windows_NT" ]; then
|
21
|
-
# if [ -z "$SSH_AGENT_PID" ] || ! ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null ; then
|
22
|
-
# echo "Should start_agent for SSH first"
|
23
|
-
# # exit 1
|
24
|
-
# fi
|
25
|
-
# ssh-add -l || echo "*** WARNING *** Please add your ssh keys ssh-add"
|
26
|
-
# fi
|
27
|
-
|
28
|
-
|
29
|
-
#mongrel_rails start -e production -p 3000 --log log\production.log
|
data/bin/results_cleanup
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module EventMachine
|
2
|
-
|
3
|
-
def self.event_callback conn_binding, opcode, data # :nodoc:
|
4
|
-
#
|
5
|
-
# Changed 27Dec07: Eliminated the hookable error handling.
|
6
|
-
# No one was using it, and it degraded performance significantly.
|
7
|
-
# It's in original_event_callback, which is dead code.
|
8
|
-
#
|
9
|
-
# Changed 25Jul08: Added a partial solution to the problem of exceptions
|
10
|
-
# raised in user-written event-handlers. If such exceptions are not caught,
|
11
|
-
# we must cause the reactor to stop, and then re-raise the exception.
|
12
|
-
# Otherwise, the reactor doesn't stop and it's left on the call stack.
|
13
|
-
# This is partial because we only added it to #unbind, where it's critical
|
14
|
-
# (to keep unbind handlers from being re-entered when a stopping reactor
|
15
|
-
# runs down open connections). It should go on the other calls to user
|
16
|
-
# code, but the performance impact may be too large.
|
17
|
-
#
|
18
|
-
if opcode == ConnectionUnbound
|
19
|
-
if c = @conns.delete( conn_binding )
|
20
|
-
begin
|
21
|
-
c.unbind
|
22
|
-
rescue
|
23
|
-
@wrapped_exception = $!
|
24
|
-
stop
|
25
|
-
end
|
26
|
-
elsif c = @acceptors.delete( conn_binding )
|
27
|
-
# no-op
|
28
|
-
else
|
29
|
-
# raise ConnectionNotBound, "recieved ConnectionUnbound for an unknown signature: #{conn_binding}"
|
30
|
-
end
|
31
|
-
elsif opcode == ConnectionAccepted
|
32
|
-
accep,args,blk = @acceptors[conn_binding]
|
33
|
-
raise NoHandlerForAcceptedConnection unless accep
|
34
|
-
c = accep.new data, *args
|
35
|
-
@conns[data] = c
|
36
|
-
blk and blk.call(c)
|
37
|
-
c # (needed?)
|
38
|
-
elsif opcode == ConnectionCompleted
|
39
|
-
c = @conns[conn_binding]
|
40
|
-
if c
|
41
|
-
c.connection_completed
|
42
|
-
# else
|
43
|
-
# raise ConnectionNotBound, "received ConnectionCompleted for unknown signature: #{conn_binding}"
|
44
|
-
end
|
45
|
-
##
|
46
|
-
# The remaining code is a fallback for the pure ruby and java reactors.
|
47
|
-
# In the C++ reactor, these events are handled in the C event_callback() in rubymain.cpp
|
48
|
-
elsif opcode == TimerFired
|
49
|
-
t = @timers.delete( data )
|
50
|
-
return if t == false # timer cancelled
|
51
|
-
t or raise UnknownTimerFired, "timer data: #{data}"
|
52
|
-
t.call
|
53
|
-
elsif opcode == ConnectionData
|
54
|
-
c = @conns[conn_binding] or raise ConnectionNotBound, "received data #{data} for unknown signature: #{conn_binding}"
|
55
|
-
c.receive_data data
|
56
|
-
elsif opcode == LoopbreakSignalled
|
57
|
-
run_deferred_callbacks
|
58
|
-
elsif opcode == ConnectionNotifyReadable
|
59
|
-
c = @conns[conn_binding] or raise ConnectionNotBound
|
60
|
-
c.notify_readable
|
61
|
-
elsif opcode == ConnectionNotifyWritable
|
62
|
-
c = @conns[conn_binding] or raise ConnectionNotBound
|
63
|
-
c.notify_writable
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/oats/ragent.rb
DELETED
@@ -1,321 +0,0 @@
|
|
1
|
-
#require 'eventmachine' # http://eventmachine.rubyforge.org/EventMachine.html#M000486
|
2
|
-
#require 'patches_for_eventmachine_12.10'
|
3
|
-
require 'em-http-request' # https://github.com/igrigorik/em-http-request/wiki/Issuing-Requests
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
module Oats
|
7
|
-
|
8
|
-
class Ragent < EventMachine::Connection
|
9
|
-
attr_accessor :job_count, :jid, :occ_reintroduction_wait_time
|
10
|
-
attr_reader :request
|
11
|
-
@@logger = nil
|
12
|
-
@@oats_info_snapshot = {}
|
13
|
-
@@job_count = 1
|
14
|
-
@@occ_default = nil
|
15
|
-
@@logger = Log4r::Logger.new('A')
|
16
|
-
include EM::P::ObjectProtocol
|
17
|
-
|
18
|
-
|
19
|
-
# Non-nil if in the state of requesting for the next job
|
20
|
-
def Ragent.in_next_job
|
21
|
-
@@in_next_job
|
22
|
-
end
|
23
|
-
def Ragent.in_next_job=(v)
|
24
|
-
@@in_next_job = v
|
25
|
-
end
|
26
|
-
def Ragent.is_busy=(jid)
|
27
|
-
@@is_busy = jid
|
28
|
-
end
|
29
|
-
# Current/Last jobid worked on, or false
|
30
|
-
def Ragent.is_busy
|
31
|
-
@@is_busy
|
32
|
-
end
|
33
|
-
|
34
|
-
# Contains YAML OCC entries if oats is started in agent mode
|
35
|
-
def Ragent.occ
|
36
|
-
@@occ_default
|
37
|
-
end
|
38
|
-
|
39
|
-
def Ragent.start(occ_def)
|
40
|
-
@@occ_default = occ_def # This should not change during agent execution
|
41
|
-
@@logger.add('console')
|
42
|
-
3.times do |count| # In case of unexpected exceptions
|
43
|
-
begin
|
44
|
-
@@occ_reintroduction_wait_time = nil
|
45
|
-
@@is_busy = false # If agent is started from scratch assume previous one is gone
|
46
|
-
@@in_next_job = false
|
47
|
-
@@logger.info "====================================================================================="
|
48
|
-
mach_port = ENV['HOSTNAME'] + ':' + $oats['execution']['occ']['port'].to_s
|
49
|
-
@@logger.info "Started OATS Server execution-#{count} on #{mach_port} at #{Time.now} "
|
50
|
-
EventMachine::run do
|
51
|
-
EventMachine::start_server @@occ_default['agent_host'], @@occ_default['agent_port'].to_i, Ragent
|
52
|
-
EventMachine.next_tick do
|
53
|
-
Ragent.server_logger nil,'Initiating contact with OCC '
|
54
|
-
Ragent.start_next_job unless Ragent.is_busy
|
55
|
-
end
|
56
|
-
end
|
57
|
-
break # Shutdown requested
|
58
|
-
rescue Exception => exc
|
59
|
-
@@logger.error exc
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# def Ragent.force_close_connection
|
65
|
-
# end
|
66
|
-
def Ragent.job_count=(val)
|
67
|
-
@@job_count = val
|
68
|
-
end
|
69
|
-
def Ragent.job_count
|
70
|
-
@@job_count
|
71
|
-
end
|
72
|
-
|
73
|
-
def Ragent.snapshot_oats_info(oats_info)
|
74
|
-
@@oats_info_snapshot = oats_info
|
75
|
-
end
|
76
|
-
|
77
|
-
# Generates summary data into the input oats_info
|
78
|
-
def regen_results_summary!(oats_info)
|
79
|
-
return Report.results(oats_info['test_files'],true)
|
80
|
-
rescue
|
81
|
-
server_logger $!.inspect + "\n" + $!.backtrace.join("\n ")
|
82
|
-
false
|
83
|
-
end
|
84
|
-
|
85
|
-
# Results_status: Early, Partial, Current, Archived, Missing, Error
|
86
|
-
def get_oats_info
|
87
|
-
if @request[:jobid] == Ragent.is_busy # working on it now
|
88
|
-
if @request[:jobid] == @@oats_info_snapshot['jobid'] # first test started processing
|
89
|
-
if regen_results_summary!(@@oats_info_snapshot) # summary succeeded
|
90
|
-
oats_info = Marshal.load(Marshal.dump(@@oats_info_snapshot))
|
91
|
-
oats_info['results_status'] = 'Partial'
|
92
|
-
else
|
93
|
-
server_logger "[ERROR] Can not regen_results_summary from the snapshot"
|
94
|
-
oats_info = {'results_status' => 'Error'}
|
95
|
-
end
|
96
|
-
elsif @@oats_info_snapshot['jobid']
|
97
|
-
msg = "ERROR: Unexpected condition. Request jobid: #{@request[:jobid]} does not match stored job id: #{@@oats_info_snapshot['jobid']}"
|
98
|
-
server_logger msg
|
99
|
-
oats_info = { 'jobid' => @request[:jobid], 'results_status' => 'Error', 'error_message' => msg }
|
100
|
-
else
|
101
|
-
oats_info = Marshal.load(Marshal.dump(Oats.context))
|
102
|
-
oats_info['results_status'] = 'Early'
|
103
|
-
oats_info['jobid'] = Ragent.is_busy
|
104
|
-
end
|
105
|
-
else # Search for request on disk in archive or results
|
106
|
-
res_dir = File.join(Oats.result_archive_dir, @request[:jobid].to_s)
|
107
|
-
results_file = File.join( res_dir,'results.dump')
|
108
|
-
if File.readable?(results_file) # Archived ones should have summary
|
109
|
-
oats_info = Report.oats_info_retrieve(results_file)
|
110
|
-
oats_info['results_status'] = 'Archived'
|
111
|
-
else # May have to regenerate the summary, in case test had died
|
112
|
-
results_file = File.join( $oats['execution']['dir_results'], 'results.dump')
|
113
|
-
if File.readable?(results_file)
|
114
|
-
oats_info = Report.oats_info_retrieve(results_file)
|
115
|
-
if regen_results_summary!(oats_info) and @request[:jobid] == oats_info['jobid']
|
116
|
-
oats_info['results_status'] = 'Current'
|
117
|
-
else
|
118
|
-
oats_info = {} unless oats_info.instance_of?(Hash)
|
119
|
-
oats_info['debug_message'] = "request_jobid: #{@request[:jobid]}, current oats_info jobid: #{oats_info['jobid']}"
|
120
|
-
oats_info['results_status'] = 'Missing'
|
121
|
-
end
|
122
|
-
else
|
123
|
-
oats_info = { 'results_status' => 'Missing' ,
|
124
|
-
'debug_message' => "No readable: #{results_file}" }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
# Convert object to hash
|
129
|
-
oats_info['test_files'] = oats_info['test_files'].testlist_hash if oats_info['test_files']
|
130
|
-
return oats_info
|
131
|
-
rescue
|
132
|
-
server_logger $!.inspect + "\n" + $!.backtrace.join("\n ")
|
133
|
-
end
|
134
|
-
|
135
|
-
def receive_object(request)
|
136
|
-
@request = request
|
137
|
-
password = @request.delete(:password)
|
138
|
-
server_logger "Received " + @request.inspect
|
139
|
-
@request[:password] = password
|
140
|
-
response = {}
|
141
|
-
case @request[:command]
|
142
|
-
|
143
|
-
when 'status'
|
144
|
-
EventMachine.next_tick { run_next_job } unless Ragent.is_busy
|
145
|
-
|
146
|
-
when 'start'
|
147
|
-
if Ragent.is_busy
|
148
|
-
server_logger "Not getting next job again because Ragent.is_busy: #{Ragent.is_busy}"
|
149
|
-
else
|
150
|
-
EventMachine.next_tick { run_next_job }
|
151
|
-
end
|
152
|
-
|
153
|
-
when 'results'
|
154
|
-
begin
|
155
|
-
response[:oats_info] = get_oats_info
|
156
|
-
rescue
|
157
|
-
server_logger $!.inspect + "\n" + $!.backtrace.join("\n ")
|
158
|
-
end
|
159
|
-
|
160
|
-
when 'run' # only called from oats client, not from OCC
|
161
|
-
EventMachine.defer( proc {
|
162
|
-
Driver.start(@request[:jobid], @request[:args])
|
163
|
-
} ) unless Ragent.is_busy
|
164
|
-
|
165
|
-
when 'stop' # any further test execution for this jobid
|
166
|
-
Oats.context['stop_oats'] = @request[:id] if @request[:stop_jobs].include?(Oats.context['jobid'])
|
167
|
-
|
168
|
-
when 'shutdown'
|
169
|
-
else
|
170
|
-
response[:unknown_command] = true
|
171
|
-
server_logger "Unknown command #{@request[:command]}"
|
172
|
-
end
|
173
|
-
response[:is_busy] = Ragent.is_busy
|
174
|
-
stop_oats = Oats.context && Oats.context['stop_oats']
|
175
|
-
response[:is_signal_oats_to_stop] = stop_oats if stop_oats
|
176
|
-
server_logger "Sending " + response.inspect
|
177
|
-
response[:password] = password
|
178
|
-
send_object(response)
|
179
|
-
close_connection_after_writing
|
180
|
-
rescue
|
181
|
-
server_logger $!.inspect + "\n" + $!.backtrace.join("\n ")
|
182
|
-
end
|
183
|
-
|
184
|
-
def unbind
|
185
|
-
if @request[:command] == 'shutdown'
|
186
|
-
server_logger "Shutting down the server."
|
187
|
-
EventMachine::stop_event_loop
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def run_next_job(prev_jobid = nil)
|
192
|
-
return unless @request[:occ_host] # Bad input or invoked via client, not occ
|
193
|
-
occ = @@occ_default.clone
|
194
|
-
occ['server_host'] = @request[:occ_host]
|
195
|
-
occ['server_port'] = @request[:occ_port]
|
196
|
-
Ragent.start_next_job(occ, self, prev_jobid)
|
197
|
-
end
|
198
|
-
|
199
|
-
def self.start_next_job(occ = @@occ_default, ra = nil, prev_jobid = nil)
|
200
|
-
if Ragent.in_next_job or Ragent.is_busy
|
201
|
-
msg = if Ragent.in_next_job
|
202
|
-
if Ragent.in_next_job == nil.object_id
|
203
|
-
"already getting the initial job."
|
204
|
-
else
|
205
|
-
"already getting job for #{Ragent.in_next_job}]"
|
206
|
-
end
|
207
|
-
else
|
208
|
-
"became busy with #{Ragent.is_busy}"
|
209
|
-
end
|
210
|
-
Ragent.server_logger ra, "Not requesting new job since #{msg}"
|
211
|
-
return false
|
212
|
-
end
|
213
|
-
Ragent.in_next_job = ra.object_id
|
214
|
-
# Double check that this agent has the busy lock
|
215
|
-
if not Ragent.in_next_job or Ragent.in_next_job != ra.object_id
|
216
|
-
Ragent.server_logger(ra, "Not requesting new job since " +
|
217
|
-
"now another Ragent #{ra.object_id} is requesting next job besides current #{Ragent.in_next_job}")
|
218
|
-
return false
|
219
|
-
end
|
220
|
-
query = {
|
221
|
-
'nickname' => occ['agent_nickname'],
|
222
|
-
'machine' => occ['agent_host'],
|
223
|
-
'port' => occ['agent_port'] }
|
224
|
-
query['jobid'] = prev_jobid if prev_jobid
|
225
|
-
query['repo'] = ENV['OATS_TESTS_CODE_VERSION'].to_s if ENV['OATS_TESTS_CODE_VERSION'] and ENV['OATS_TESTS_CODE_VERSION'] != ''
|
226
|
-
query['logfile'] = File.basename(ENV['OATS_AGENT_LOGFILE']||'agent.log')
|
227
|
-
Ragent.server_logger ra, "Getting next OCC job: " + query.inspect
|
228
|
-
query['password='] = ra.request[:password] if ra and ra.request[:password]
|
229
|
-
# Default inactivity_timeout of 10 is not enough when OCC is restarting too
|
230
|
-
# many agents. Agent gives up in 10secs but OCC hands over the job in 20secs.
|
231
|
-
# As a result OCC thinks job is received but agent has never seen the job.
|
232
|
-
connection_options = { :connect_timeout => 60,:inactivity_timeout => 60}
|
233
|
-
http_req = EventMachine::HttpRequest.new('http://' + occ['server_host'] + ":#{occ['server_port']}",connection_options)
|
234
|
-
http = http_req.get :path => '/jobs/nxt', :query => query
|
235
|
-
http.errback { self.no_response(occ,ra, prev_jobid) }
|
236
|
-
http.callback do
|
237
|
-
status = http.response_header.status
|
238
|
-
if status == 200
|
239
|
-
data =http.response
|
240
|
-
nxt_job = JSON.parse(data) if data
|
241
|
-
if nxt_job['jid']
|
242
|
-
Ragent.is_busy = nxt_job['jid']
|
243
|
-
Ragent.in_next_job = false
|
244
|
-
if ra
|
245
|
-
ra.jid = nxt_job['jid']
|
246
|
-
ra.occ_reintroduction_wait_time = nil # Reset wait time to default if heard from OCC
|
247
|
-
end
|
248
|
-
Ragent.server_logger ra, "Job-#{Ragent.job_count} #{nxt_job.inspect}"
|
249
|
-
EventMachine.defer do
|
250
|
-
begin
|
251
|
-
opts= {'execution:environments' => [nxt_job['env']],
|
252
|
-
'execution:test_files' => [nxt_job['list']] }
|
253
|
-
opts['_:options'] = nxt_job['options'].split(',') if nxt_job['options'] and nxt_job['options'] != ''
|
254
|
-
Ragent.snapshot_oats_info({})
|
255
|
-
Driver.start(nxt_job['jid'],opts)
|
256
|
-
ensure
|
257
|
-
Ragent.is_busy = false
|
258
|
-
end
|
259
|
-
Ragent.job_count += 1
|
260
|
-
if ra
|
261
|
-
ra.run_next_job(nxt_job['jid'] )
|
262
|
-
else
|
263
|
-
Ragent.start_next_job(occ,ra,nxt_job['jid'])
|
264
|
-
end
|
265
|
-
end
|
266
|
-
else
|
267
|
-
Ragent.in_next_job = false
|
268
|
-
Ragent.server_logger ra, "No more pending jobs at OCC. Pausing processing.\n"
|
269
|
-
Ragent.job_count = 1
|
270
|
-
Ragent.server_logger ra, "***********************************************************\n"
|
271
|
-
end
|
272
|
-
else
|
273
|
-
self.no_response(occ,ra, prev_jobid)
|
274
|
-
end
|
275
|
-
end
|
276
|
-
rescue RuntimeError => e.message
|
277
|
-
Ragent.in_next_job = false
|
278
|
-
if e.message == 'eventmachine not initialized: evma_connect_to_server'
|
279
|
-
Ragent.server_logger ra, "Shutting down..."
|
280
|
-
else
|
281
|
-
Ragent.server_logger ra, $!.inspect + "\n" + $!.backtrace.join("\n ")
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
def self.no_response(occv,ra, prev_jobid)
|
286
|
-
Ragent.in_next_job = false
|
287
|
-
Ragent.server_logger ra, "OCC did not respond."
|
288
|
-
wait = ra ? ra.occ_reintroduction_wait_time : @@occ_reintroduction_wait_time
|
289
|
-
wait ||= $oats['execution']['occ']['timeout_waiting_for_occ']
|
290
|
-
# Keep retrying to introduce, doubling the intervals
|
291
|
-
self.server_logger ra, "Will retry in #{wait} seconds."
|
292
|
-
EM.add_timer(wait) do
|
293
|
-
Ragent.start_next_job(occv,ra, prev_jobid) unless Ragent.is_busy # by now
|
294
|
-
end
|
295
|
-
wait *= (1.5 + rand(101)/100.0)
|
296
|
-
wait = wait.round
|
297
|
-
if ra
|
298
|
-
ra.occ_reintroduction_wait_time = wait
|
299
|
-
else
|
300
|
-
@@occ_reintroduction_wait_time = wait
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
def server_logger(arg)
|
305
|
-
Ragent.server_logger self, arg
|
306
|
-
end
|
307
|
-
|
308
|
-
def Ragent.server_logger(ra, arg)
|
309
|
-
if ra
|
310
|
-
req = ra.request
|
311
|
-
jid = ra.jid
|
312
|
-
rt = ":R#{(req and req[:id]) ? req[:id] : ra.object_id}"
|
313
|
-
rt += "#{" J:#{jid}" if jid }"
|
314
|
-
end
|
315
|
-
@@logger.info "[RS#{rt}] #{arg}"
|
316
|
-
rescue
|
317
|
-
@@logger.error $!.inspect + "\n" + $!.backtrace.join("\n ")
|
318
|
-
end
|
319
|
-
|
320
|
-
end
|
321
|
-
end
|
data/lib/oats/rclient.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module Oats
|
2
|
-
|
3
|
-
class Rclient < EventMachine::Connection
|
4
|
-
attr_reader :response
|
5
|
-
include EM::P::ObjectProtocol
|
6
|
-
# def serializer
|
7
|
-
# YAML
|
8
|
-
# end
|
9
|
-
#
|
10
|
-
def initialize(host, request)
|
11
|
-
@host = host
|
12
|
-
@request = request
|
13
|
-
end
|
14
|
-
|
15
|
-
def receive_object(response)
|
16
|
-
@response = response
|
17
|
-
password = response.delete(:password)
|
18
|
-
length = 500
|
19
|
-
resp = response.inspect
|
20
|
-
resp = resp[0..length] + ' ..... ' + resp[-length..-1] if resp.size > 2*length
|
21
|
-
client_logger "Received " + resp + " from"
|
22
|
-
response[:password] = password
|
23
|
-
client_logger "Command was not recognized" if response[:unknown_command]
|
24
|
-
end
|
25
|
-
|
26
|
-
def client_logger(arg)
|
27
|
-
$log.info arg + " #{@request[:id]}@#{@host} at " + Time.now.strftime("%y-%m-%d %H:%M:%S")
|
28
|
-
end
|
29
|
-
|
30
|
-
def post_init
|
31
|
-
password = @request.delete(:password)
|
32
|
-
client_logger "Sending " + @request.inspect + " to"
|
33
|
-
@request[:password] = password
|
34
|
-
send_object(@request)
|
35
|
-
end
|
36
|
-
def unbind
|
37
|
-
client_logger "Did not hear from " unless @response
|
38
|
-
EventMachine::stop_event_loop
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|