test_bench-telemetry 2.0.0.1 → 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_bench/telemetry/controls/event/event_data.rb +15 -0
  3. data/lib/test_bench/telemetry/controls/event/metadata.rb +70 -0
  4. data/lib/test_bench/telemetry/controls/event.rb +112 -51
  5. data/lib/test_bench/telemetry/controls/event_data.rb +129 -0
  6. data/lib/test_bench/telemetry/controls/file.rb +84 -0
  7. data/lib/test_bench/telemetry/controls/handler.rb +48 -43
  8. data/lib/test_bench/telemetry/controls/{detail_level.rb → process_id.rb} +7 -3
  9. data/lib/test_bench/telemetry/controls/projection/receiver.rb +31 -0
  10. data/lib/test_bench/telemetry/controls/projection.rb +84 -0
  11. data/lib/test_bench/telemetry/controls/random.rb +1 -1
  12. data/lib/test_bench/telemetry/controls/sink.rb +23 -1
  13. data/lib/test_bench/telemetry/controls/time.rb +49 -2
  14. data/lib/test_bench/telemetry/controls.rb +10 -33
  15. data/lib/test_bench/telemetry/event.rb +74 -13
  16. data/lib/test_bench/telemetry/{event → event_data}/serialization.rb +78 -53
  17. data/lib/test_bench/telemetry/event_data.rb +13 -0
  18. data/lib/test_bench/telemetry/sink/file.rb +3 -3
  19. data/lib/test_bench/telemetry/sink/handler/event_registry.rb +42 -0
  20. data/lib/test_bench/telemetry/sink/handler.rb +54 -30
  21. data/lib/test_bench/telemetry/sink/projection.rb +132 -0
  22. data/lib/test_bench/telemetry/sink.rb +11 -0
  23. data/lib/test_bench/telemetry/substitute/sink.rb +83 -0
  24. data/lib/test_bench/telemetry/substitute.rb +13 -54
  25. data/lib/test_bench/telemetry/telemetry.rb +60 -19
  26. data/lib/test_bench/telemetry.rb +8 -10
  27. metadata +17 -40
  28. data/lib/test_bench/telemetry/controls/capture_sink/path.rb +0 -30
  29. data/lib/test_bench/telemetry/controls/capture_sink/record.rb +0 -21
  30. data/lib/test_bench/telemetry/controls/comment.rb +0 -19
  31. data/lib/test_bench/telemetry/controls/error.rb +0 -36
  32. data/lib/test_bench/telemetry/controls/events/asserted.rb +0 -32
  33. data/lib/test_bench/telemetry/controls/events/commented.rb +0 -26
  34. data/lib/test_bench/telemetry/controls/events/context_entered.rb +0 -31
  35. data/lib/test_bench/telemetry/controls/events/context_exited.rb +0 -34
  36. data/lib/test_bench/telemetry/controls/events/context_skipped.rb +0 -31
  37. data/lib/test_bench/telemetry/controls/events/detail_decreased.rb +0 -23
  38. data/lib/test_bench/telemetry/controls/events/detail_increased.rb +0 -23
  39. data/lib/test_bench/telemetry/controls/events/error_raised.rb +0 -26
  40. data/lib/test_bench/telemetry/controls/events/file_entered.rb +0 -29
  41. data/lib/test_bench/telemetry/controls/events/file_exited.rb +0 -32
  42. data/lib/test_bench/telemetry/controls/events/fixture_finished.rb +0 -29
  43. data/lib/test_bench/telemetry/controls/events/fixture_started.rb +0 -26
  44. data/lib/test_bench/telemetry/controls/events/run_aborted.rb +0 -29
  45. data/lib/test_bench/telemetry/controls/events/run_finished.rb +0 -32
  46. data/lib/test_bench/telemetry/controls/events/run_started.rb +0 -29
  47. data/lib/test_bench/telemetry/controls/events/test_finished.rb +0 -34
  48. data/lib/test_bench/telemetry/controls/events/test_skipped.rb +0 -31
  49. data/lib/test_bench/telemetry/controls/events/test_started.rb +0 -31
  50. data/lib/test_bench/telemetry/controls/events.rb +0 -27
  51. data/lib/test_bench/telemetry/controls/fixture_name.rb +0 -19
  52. data/lib/test_bench/telemetry/controls/line_number.rb +0 -10
  53. data/lib/test_bench/telemetry/controls/path.rb +0 -87
  54. data/lib/test_bench/telemetry/controls/result.rb +0 -12
  55. data/lib/test_bench/telemetry/controls/title.rb +0 -43
  56. data/lib/test_bench/telemetry/event/events.rb +0 -35
  57. data/lib/test_bench/telemetry/event/type.rb +0 -27
  58. data/lib/test_bench/telemetry/sink/capture/path.rb +0 -69
  59. data/lib/test_bench/telemetry/sink/capture/record/generate.rb +0 -49
  60. data/lib/test_bench/telemetry/sink/capture/record.rb +0 -73
  61. data/lib/test_bench/telemetry/sink/capture.rb +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc9eba5d7d92a1f3103d807e39010ab95c5d332d9f11189c6ee1001ff76eb1e6
4
- data.tar.gz: 5cfe64718b363c2b054e93273097185ecce46ee1f0e03282213993aedc0293a0
3
+ metadata.gz: 72c55974ef010c548b9527049d02155e13a077de5b0029b54a87ce562613ab9f
4
+ data.tar.gz: a003ad9fec17e7ac5900ebdd146679232c68489acdf98b37d767427ca8b86ee5
5
5
  SHA512:
6
- metadata.gz: 9393cef19bf91ad537f917056ec971159347604ff4a4e794a2320f53036b0610610ee976b0a6b0d084c692b0d375effe5370ef88f2a6e901b7316ba5e2321d98
7
- data.tar.gz: 6018103538a85fca142e4034b3f10a3f4ed8a9b4ce403fb5262d7d514488223d538a7cb9b8c557b587bd341cae44095c80d8031bfdf304c22629e5a81e316b8e
6
+ metadata.gz: b37377fc81d039affad9fc2b9b2b2b6c95f530186b3c05c4d876255cb3fce5cf7b3891dbdae22bf7a3421be40494710106ac3143994c3e24d9ded2d8815dfc2f
7
+ data.tar.gz: 14dc73d0d4dea00ed153eb6d950dfef9d66275401fe55b39e64946d5e71870ab978668a504f517adae0496f8d10e1926c336c2e41cab49d9f9fdda638e765ab9
@@ -0,0 +1,15 @@
1
+ module TestBench
2
+ class Telemetry
3
+ module Controls
4
+ module Event
5
+ module EventData
6
+ def event_data
7
+ event = self.example
8
+
9
+ Telemetry::Event::Export.(event)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,70 @@
1
+ module TestBench
2
+ class Telemetry
3
+ module Controls
4
+ module Event
5
+ module Metadata
6
+ def self.example(process_id: nil, time: nil)
7
+ if process_id == :none
8
+ process_id = nil
9
+ else
10
+ process_id ||= self.process_id
11
+ end
12
+
13
+ if time == :none
14
+ time = nil
15
+ else
16
+ time ||= self.time
17
+ end
18
+
19
+ metadata = Telemetry::Event::Metadata.new
20
+ metadata.process_id = process_id
21
+ metadata.time = time
22
+ metadata
23
+ end
24
+
25
+ def self.other_example
26
+ Other.example
27
+ end
28
+
29
+ def self.random
30
+ Random.example
31
+ end
32
+
33
+ def self.process_id
34
+ Controls::ProcessID.example
35
+ end
36
+
37
+ def self.time
38
+ Controls::Time.example
39
+ end
40
+
41
+ module Other
42
+ def self.example(process_id: nil, time: nil)
43
+ process_id ||= self.process_id
44
+ time ||= self.time
45
+
46
+ Metadata.example(process_id:, time:)
47
+ end
48
+
49
+ def self.process_id
50
+ Controls::ProcessID.other_example
51
+ end
52
+
53
+ def self.time
54
+ Controls::Time.other_example
55
+ end
56
+ end
57
+
58
+ module Random
59
+ def self.example(process_id: nil, time: nil)
60
+ process_id ||= Controls::ProcessID.random
61
+ time ||= Controls::Time.random
62
+
63
+ Metadata.example(process_id:, time:)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -2,72 +2,133 @@ module TestBench
2
2
  class Telemetry
3
3
  module Controls
4
4
  module Event
5
- def self.example(some_string=nil)
6
- some_string ||= self.some_string
7
-
8
- event = Example.new
9
- event.some_string = some_string
10
- event.some_integer = some_integer
11
- event.some_boolean = some_boolean
12
- event.some_other_boolean = some_other_boolean
13
- event.time = time
5
+ extend EventData
6
+
7
+ def self.example(some_attribute: nil, some_other_attribute: nil, event_class: nil, metadata: nil, process_id: nil, time: nil)
8
+ some_attribute ||= self.some_attribute
9
+ some_other_attribute ||= self.some_other_attribute
10
+
11
+ metadata ||= Metadata.example(process_id:, time:)
12
+ event_class ||= SomeEvent
13
+
14
+ event = event_class.new
15
+ event.some_attribute = some_attribute
16
+ event.some_other_attribute = some_other_attribute
17
+ event.metadata = metadata
14
18
  event
15
19
  end
16
20
 
17
- def self.some_string = 'some-string'
18
- def self.some_integer = 11
19
- def self.some_boolean = true
20
- def self.some_other_boolean = false
21
- def self.time = Time.example
22
-
23
- SomeEvent = TestBench::Telemetry::Event.define(
24
- :some_string,
25
- :some_integer,
26
- :some_boolean,
27
- :some_other_boolean,
28
- :some_optional
29
- )
30
- Example = SomeEvent
31
-
32
- SomeOtherEvent = TestBench::Telemetry::Event.define
33
- OtherExample = SomeOtherEvent
34
-
35
- module Type
36
- def self.example = SomeEvent.event_type
37
- def self.other_example = SomeOtherEvent.event_type
38
- def self.random = :"#{example}#{Random.string}"
21
+ def self.other_example
22
+ Other.example
39
23
  end
40
24
 
41
- module Data
42
- def self.example(event_type: nil)
43
- event_type ||= SomeEvent.event_type
25
+ def self.random
26
+ Random.example(event_class:)
27
+ end
44
28
 
45
- time_iso8601 = Time::ISO8601.example
29
+ def self.event_class
30
+ SomeEvent
31
+ end
46
32
 
47
- %{#{event_type}\t"some-string"\t11\ttrue\tfalse\t\t#{time_iso8601}\r\n}
33
+ def self.some_attribute
34
+ 'some-value'
35
+ end
36
+
37
+ def self.some_other_attribute
38
+ 'some-alternate-value'
39
+ end
40
+
41
+ def self.process_id
42
+ Controls::EventData.process_id
43
+ end
44
+
45
+ def self.time
46
+ Controls::EventData.time
47
+ end
48
+
49
+ SomeEvent = TestBench::Telemetry::Event.define(:some_attribute, :some_other_attribute)
50
+ SomeOtherEvent = TestBench::Telemetry::Event.define(:some_attribute, :some_other_attribute)
51
+
52
+ module Other
53
+ extend EventData
54
+
55
+ def self.example(some_attribute: nil, some_other_attribute: nil, metadata: nil, process_id: nil, time: nil)
56
+ some_attribute ||= self.some_attribute
57
+ some_other_attribute ||= self.some_other_attribute
58
+ metadata ||= Metadata::Other.example(process_id:, time:)
59
+
60
+ Event.example(some_attribute:, some_other_attribute:, event_class:, metadata:)
48
61
  end
49
62
 
50
- module Malformed
51
- module Empty
52
- def self.example = ''
53
- end
63
+ def self.event_class
64
+ SomeOtherEvent
65
+ end
66
+
67
+ def self.some_attribute
68
+ 'some-other-value'
69
+ end
54
70
 
55
- module NoData
56
- def self.example = "SomeEvent\r\n"
71
+ def self.some_other_attribute
72
+ 'some-other-alternate-value'
73
+ end
74
+ end
75
+
76
+ module Random
77
+ extend EventData
78
+
79
+ def self.example(some_attribute: nil, some_other_attribute: nil, event_class: nil, metadata: nil, process_id: nil, time: nil)
80
+ some_attribute ||= self.some_attribute
81
+ some_other_attribute ||= self.some_other_attribute
82
+ event_class ||= self.event_class
83
+ metadata ||= Metadata::Random.example(process_id:, time:)
84
+
85
+ Event.example(some_attribute:, some_other_attribute:, event_class:, metadata:)
86
+ end
87
+
88
+ def self.event_class
89
+ if Controls::Random.boolean
90
+ SomeEvent
91
+ else
92
+ SomeOtherEvent
57
93
  end
94
+ end
95
+
96
+ def self.some_attribute
97
+ suffix = Controls::Random.string
98
+
99
+ "#{Event.some_attribute}-#{suffix}"
100
+ end
58
101
 
59
- module IncorrectEventType
60
- def self.example
61
- Data.example(event_type:)
62
- end
102
+ def self.some_other_attribute
103
+ suffix = Controls::Random.string
63
104
 
64
- def self.event_type = :not_pascal_cased
105
+ "#{Event.some_other_attribute}-#{suffix}"
106
+ end
107
+ end
108
+
109
+ module Data
110
+ def self.example
111
+ some_attribute = Event.some_attribute
112
+ some_other_attribute = Event.some_other_attribute
113
+
114
+ [some_attribute, some_other_attribute]
115
+ end
116
+
117
+ module Other
118
+ def self.example
119
+ some_attribute = Event::Other.some_attribute
120
+ some_other_attribute = Event::Other.some_other_attribute
121
+
122
+ [some_attribute, some_other_attribute]
65
123
  end
124
+ end
125
+
126
+ module Random
127
+ def self.example
128
+ some_attribute = Event::Random.some_attribute
129
+ some_other_attribute = Event::Random.some_other_attribute
66
130
 
67
- module IncorrectNewlines
68
- def self.example
69
- %{SomeEvent\t\t\n}
70
- end
131
+ [some_attribute, some_other_attribute]
71
132
  end
72
133
  end
73
134
  end
@@ -0,0 +1,129 @@
1
+ module TestBench
2
+ class Telemetry
3
+ module Controls
4
+ module EventData
5
+ def self.example(type: nil, process_id: nil, time: nil, data: nil)
6
+ type ||= self.type
7
+ process_id ||= self.process_id
8
+ time ||= self.time
9
+ data ||= self.data
10
+
11
+ event_data = Telemetry::EventData.new
12
+ event_data.type = type
13
+ event_data.process_id = process_id
14
+ event_data.time = time
15
+ event_data.data = data
16
+ event_data
17
+ end
18
+
19
+ def self.random
20
+ Random.example
21
+ end
22
+
23
+ def self.type
24
+ Type.example
25
+ end
26
+
27
+ def self.process_id
28
+ ProcessID.example
29
+ end
30
+
31
+ def self.time
32
+ Time.example
33
+ end
34
+
35
+ def self.data
36
+ Data.example
37
+ end
38
+
39
+ module Random
40
+ def self.example(type: nil, process_id: nil, time: nil, data: nil)
41
+ type ||= Type.random
42
+ process_id ||= ProcessID.random
43
+ time ||= Time.random
44
+ data ||= Data.random
45
+
46
+ EventData.example(type:, process_id:, time:, data:)
47
+ end
48
+ end
49
+
50
+ module Type
51
+ def self.example
52
+ :SomeEvent
53
+ end
54
+
55
+ def self.other_example
56
+ :SomeOtherEvent
57
+ end
58
+
59
+ def self.random
60
+ :"#{example}#{Controls::Random.string}"
61
+ end
62
+ end
63
+
64
+ module Data
65
+ def self.example
66
+ [
67
+ nil,
68
+ true,
69
+ false,
70
+ 11,
71
+ 'some-string',
72
+ Time.example
73
+ ]
74
+ end
75
+
76
+ def self.random
77
+ [
78
+ nil,
79
+ Controls::Random.boolean,
80
+ Controls::Random.boolean,
81
+ Controls::Random.integer,
82
+ Controls::Random.string,
83
+ Time.random
84
+ ]
85
+ end
86
+ end
87
+
88
+ module Text
89
+ def self.example(type: nil, process_id: nil, time: nil)
90
+ type ||= EventData.type
91
+ process_id ||= EventData.process_id
92
+ time ||= EventData.time
93
+
94
+ time_iso8601 = Time::ISO8601.example(time)
95
+
96
+ "#{type}\t#{process_id}\t#{time_iso8601}\t\ttrue\tfalse\t11\t\"some-string\"\t#{time_iso8601}\r\n"
97
+ end
98
+
99
+ module Malformed
100
+ module Empty
101
+ def self.example
102
+ ''
103
+ end
104
+ end
105
+
106
+ module IncorrectEventType
107
+ def self.example
108
+ Text.example(type:)
109
+ end
110
+
111
+ def self.type
112
+ :not_pascal_cased
113
+ end
114
+ end
115
+
116
+ module IncorrectNewlines
117
+ def self.example
118
+ text = Text.example
119
+ text.chomp!("\r\n")
120
+ text << "\n"
121
+ text
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,84 @@
1
+ module TestBench
2
+ class Telemetry
3
+ module Controls
4
+ module File
5
+ def self.example(...)
6
+ Temporary.example(...)
7
+ end
8
+
9
+ def self.random
10
+ Random.example
11
+ end
12
+
13
+ module Random
14
+ def self.example(...)
15
+ Temporary::Random.example(...)
16
+ end
17
+ end
18
+
19
+ module Name
20
+ def self.example(basename: nil, extension: nil)
21
+ basename ||= self.basename
22
+ extension ||= self.extension
23
+
24
+ "#{basename}#{extension}"
25
+ end
26
+
27
+ def self.random
28
+ Random.example
29
+ end
30
+
31
+ def self.basename
32
+ 'some-file'
33
+ end
34
+
35
+ def self.extension
36
+ '.some-ext'
37
+ end
38
+
39
+ module Random
40
+ def self.example(basename: nil, extension: nil)
41
+ extension ||= self.extension
42
+
43
+ basename = Basename.example(basename:)
44
+
45
+ Name.example(basename:, extension:)
46
+ end
47
+
48
+ def self.extension
49
+ suffix = Controls::Random.string[0..4]
50
+
51
+ "#{Name.extension}-#{suffix}"
52
+ end
53
+
54
+ module Basename
55
+ def self.example(basename: nil)
56
+ basename ||= Name.basename
57
+
58
+ suffix = Controls::Random.string
59
+
60
+ "#{basename}-#{suffix}"
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ module Temporary
67
+ def self.example(...)
68
+ filename = Name.example(...)
69
+
70
+ ::File.join('tmp', filename)
71
+ end
72
+
73
+ module Random
74
+ def self.example(...)
75
+ filename = Name::Random.example(...)
76
+
77
+ ::File.join('tmp', filename)
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -2,72 +2,77 @@ module TestBench
2
2
  class Telemetry
3
3
  module Controls
4
4
  module Handler
5
- def self.example(&block)
6
- if block.nil?
7
- cls = Example
8
- else
9
- cls = example_class(&block)
10
- end
11
-
12
- cls.new
5
+ def self.example
6
+ Example.new
13
7
  end
14
8
 
15
- def self.example_class(&block)
16
- Class.new do
17
- include TestBench::Telemetry::Sink::Handler
9
+ class Example
10
+ include Telemetry::Sink::Handler
18
11
 
19
- if not block.nil?
20
- class_exec(&block)
21
- end
22
- end
23
- end
12
+ attr_accessor :handled_event
13
+ attr_accessor :handled_event_data
24
14
 
25
- module Event
26
- def self.example(data=nil)
27
- data ||= self.data
15
+ handle Event::SomeEvent do |some_event|
16
+ self.handled_event = some_event
17
+ end
28
18
 
29
- Controls::Event.example(data)
19
+ def handle_event_data(event_data)
20
+ self.handled_event_data = event_data
30
21
  end
31
22
 
32
- def self.data = 'some-data'
23
+ def handled?(event=nil)
24
+ return false if handled_event.nil?
33
25
 
34
- def self.other_example
35
- Controls::Event::OtherExample.new
26
+ return true if event.nil?
27
+
28
+ event == handled_event
36
29
  end
37
30
 
38
- Example = Controls::Event::Example
39
- OtherExample = Controls::Event::OtherExample
31
+ def handled_event_data?(event_data)
32
+ self.handled_event_data == event_data
33
+ end
40
34
  end
41
35
 
42
- module Method
43
- def self.example(event_type=nil)
44
- event_type ||= Event::Example.event_type
36
+ module NoHandler
37
+ def self.example
38
+ Example.new
39
+ end
45
40
 
46
- event_type_method_cased = TestBench::Telemetry::Event::Type.method_cased(event_type)
41
+ class Example
42
+ include Telemetry::Sink::Handler
43
+ end
44
+ end
47
45
 
48
- :"handle_#{event_type_method_cased}"
46
+ module NoArgument
47
+ def self.example
48
+ Example.new
49
49
  end
50
50
 
51
- def self.other_example
52
- event_type = Event::OtherExample.event_type
51
+ class Example
52
+ include Telemetry::Sink::Handler
53
53
 
54
- example(event_type)
54
+ attr_accessor :handled_event
55
+ def handled? = !!handled_event
56
+
57
+ handle Event::SomeEvent do
58
+ self.handled_event = true
59
+ end
55
60
  end
56
61
  end
57
62
 
58
- Example = example_class do
59
- attr_accessor :data
63
+ module Method
64
+ def self.example(event_type=nil)
65
+ event_type ||= Event::SomeEvent.event_type
66
+
67
+ event_name = TestBench::Telemetry::Event::EventName.get(event_type)
60
68
 
61
- handle Event::Example do |data|
62
- self.data = data
69
+ :"handle_#{event_name}"
63
70
  end
64
71
 
65
- def handled?(data=nil)
66
- if data.nil?
67
- !self.data.nil?
68
- else
69
- data == self.data
70
- end
72
+ def self.other_example
73
+ event_type = Event::SomeOtherEvent.event_type
74
+
75
+ example(event_type)
71
76
  end
72
77
  end
73
78
  end
@@ -1,13 +1,17 @@
1
1
  module TestBench
2
2
  class Telemetry
3
3
  module Controls
4
- module DetailLevel
4
+ module ProcessID
5
5
  def self.example
6
- 1
6
+ 11111
7
+ end
8
+
9
+ def self.other_example
10
+ 22222
7
11
  end
8
12
 
9
13
  def self.random
10
- Random.integer % 11
14
+ Random.integer
11
15
  end
12
16
  end
13
17
  end
@@ -0,0 +1,31 @@
1
+ module TestBench
2
+ class Telemetry
3
+ module Controls
4
+ module Projection
5
+ module Receiver
6
+ def self.example
7
+ Example.new
8
+ end
9
+
10
+ class Example
11
+ def events
12
+ @events ||= []
13
+ end
14
+
15
+ def event(event)
16
+ events << event
17
+ end
18
+
19
+ def event?(event=nil)
20
+ if not event.nil?
21
+ events.include?(event)
22
+ else
23
+ events.any?
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end