nfagent 0.9.28 → 0.9.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,5 +36,5 @@ require 'nfagent/cli'
36
36
  require 'nfagent/tests'
37
37
 
38
38
  module NFAgent
39
- VERSION = '0.9.28'
39
+ VERSION = '0.9.29'
40
40
  end
@@ -1,4 +1,7 @@
1
1
  module NFAgent
2
+ class LookUpError < StandardError; end
3
+ class IgnoreLine < StandardError; end
4
+
2
5
  class ChunkHandler
3
6
 
4
7
  attr_accessor :chunk_group
@@ -24,9 +27,13 @@ module NFAgent
24
27
  parsed = @parser.parse(line)
25
28
  return if parsed.invalid?
26
29
  if Config.mode == 'multi'
27
- key = MapperProxy.find_account_id(parsed.username, parsed.client_ip)
28
- # TODO: Still appending line as string until Server API has been updated
29
- return append2(line, key)
30
+ begin
31
+ key = MapperProxy.find_account_id(parsed.username, parsed.client_ip)
32
+ # TODO: Still appending line as string until Server API has been updated
33
+ return append2(line, key)
34
+ rescue LookUpError, IgnoreLine
35
+ return # Do nothing
36
+ end
30
37
  end
31
38
  end
32
39
  # TODO: rename append2
@@ -12,6 +12,7 @@ class MyMapper
12
12
  end
13
13
 
14
14
  def find_account_id(username, client_ip)
15
+ raise NFAgent::IgnoreLine if username == 'andrew'
15
16
  @hash[username]
16
17
  end
17
18
  end
@@ -9,6 +9,7 @@ class TestChunkHandler < ActiveSupport::TestCase
9
9
  NFAgent::Plugin.load_plugins
10
10
  @logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico dan NONE/- text/html"
11
11
  @logline2 = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico paul NONE/- text/html"
12
+ @ignored_logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico andrew NONE/- text/html"
12
13
  end
13
14
 
14
15
  test "append line" do
@@ -41,6 +42,18 @@ class TestChunkHandler < ActiveSupport::TestCase
41
42
  assert_equal 1, chunk_handler.chunk_group['jetson'].size
42
43
  end
43
44
 
45
+ test "mapper raises ignore line in multi mode" do
46
+ NFAgent::Config.parse = 'locally'
47
+ NFAgent::Config.mode = 'multi'
48
+ NFAgent::Config.mapper = 'MyMapper'
49
+ chunk_handler = NFAgent::ChunkHandler.new
50
+ chunk_handler.append(@ignored_logline)
51
+ assert !chunk_handler.chunk_group.has_key?('acme')
52
+ assert !chunk_handler.chunk_group.has_key?('jetson')
53
+ assert chunk_handler.chunk_group['acme'].blank?
54
+ assert chunk_handler.chunk_group['jetson'].blank?
55
+ end
56
+
44
57
  test "reset chunk after expiry in multi mode" do
45
58
  NFAgent::Config.parse = 'locally'
46
59
  NFAgent::Config.mode = 'multi'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 28
9
- version: 0.9.28
8
+ - 29
9
+ version: 0.9.29
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Draper
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-09 00:00:00 +10:30
17
+ date: 2011-02-10 00:00:00 +10:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency