This repository was archived by the owner on Feb 18, 2025. It is now read-only.
File tree 5 files changed +108
-9
lines changed
5 files changed +108
-9
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,13 @@ A simulated outage affect all systems below the broken one.
7
7
8
8
## Installation
9
9
10
- gem install sinatra
11
- git clone https://github.com/mariussturm/monitoring-mock.git
10
+ $ gem install sinatra
11
+ $ git clone https://github.com/mariussturm/monitoring-mock.git
12
12
13
13
## Configuration
14
14
Configure your nework.
15
15
16
- vi etc/mock.yaml
16
+ $ vi etc/mock.yaml
17
17
18
18
Define a ` type ` for every entry.
19
19
@@ -39,12 +39,12 @@ Define a `type` for every entry.
39
39
40
40
## Start the mock
41
41
42
- cd monitoring-mock
43
- ./ mm.rb
42
+ $ cd monitoring-mock
43
+ $ ruby mm.rb
44
44
45
45
Or use your rack server of choice
46
46
47
- thin start
47
+ $ ruby mm.rb -s thin
48
48
49
49
## Dashboard
50
50
You can get an overview of your simulated network under
@@ -57,9 +57,9 @@ Press the `Ok` or `Critical` button to toggle the state of an entry
57
57
Every mock entry can be checked via HTTP. The mock delivers a JSON string
58
58
as result.
59
59
60
- curl http://localhost:4567/green
60
+ $ curl http://localhost:4567/green
61
61
{"status":0,"output":"Service OK","options":{"type":"datacenter"}}
62
62
63
- curl http://localhost:4567/green/web1
63
+ $ curl http://localhost:4567/green/web1
64
64
{"status":2,"output":"Service is broken","options":{"type":"host"}}
65
65
Original file line number Diff line number Diff line change
1
+ require 'rake/testtask'
2
+
3
+ Rake ::TestTask . new do |t |
4
+ t . libs . push "./"
5
+ t . test_files = FileList [ 'test/*_test.rb' ]
6
+ # t.verbose = true
7
+ end
8
+
Original file line number Diff line number Diff line change @@ -11,4 +11,3 @@ require File.join( File.dirname(__FILE__), 'mm.rb' )
11
11
12
12
run Sinatra ::Application
13
13
14
-
Original file line number Diff line number Diff line change
1
+ require File . expand_path ( 'test_helper.rb' , 'test' )
2
+
3
+ class GET_baseurl < MiniTest ::Unit ::TestCase
4
+ include Rack ::Test ::Methods
5
+
6
+ def setup
7
+ get '/'
8
+ end
9
+
10
+ def test_succeeds
11
+ assert last_response . status , 200
12
+ end
13
+
14
+ def test_returns_valid_json
15
+ assert_equal json_response [ 'status' ] , 3
16
+ end
17
+ end
18
+
19
+ class GET_existing_entry < MiniTest ::Unit ::TestCase
20
+ include Rack ::Test ::Methods
21
+
22
+ def setup
23
+ get '/green'
24
+ end
25
+
26
+ def test_succeeds
27
+ assert_equal json_response [ 'status' ] , 0
28
+ end
29
+ end
30
+
31
+ class GET_nonexisting_entry < MiniTest ::Unit ::TestCase
32
+ include Rack ::Test ::Methods
33
+
34
+ def setup
35
+ get '/yellow'
36
+ end
37
+
38
+ def test_succeeds
39
+ assert_equal json_response [ 'status' ] , 3
40
+ end
41
+ end
42
+
43
+ class POST_toggle_entry < MiniTest ::Unit ::TestCase
44
+ include Rack ::Test ::Methods
45
+
46
+ @before , @after = ''
47
+ def setup
48
+ get '/green'
49
+ @before = json_response
50
+ post '/toggle/green'
51
+ get '/green'
52
+ @after = json_response
53
+ end
54
+
55
+ def test_succeeds
56
+ assert_equal @before [ 'status' ] , 0
57
+ assert_equal @after [ 'status' ] , 2
58
+ end
59
+ end
60
+
61
+ class GET_deep_entry_and_toggle_above < MiniTest ::Unit ::TestCase
62
+ include Rack ::Test ::Methods
63
+
64
+ @before , @after = ''
65
+ def setup
66
+ get '/blue/web2'
67
+ @before = json_response
68
+ post '/toggle/blue'
69
+ get '/blue/web2'
70
+ @after = json_response
71
+ end
72
+
73
+ def test_succeeds
74
+ assert_equal @before [ 'status' ] , 0
75
+ assert_equal @after [ 'status' ] , 2
76
+ end
77
+ end
78
+
Original file line number Diff line number Diff line change
1
+ ENV [ 'RACK_ENV' ] = 'test'
2
+ require 'minitest/autorun'
3
+ require 'rack/test'
4
+
5
+ require 'mm'
6
+
7
+ def app
8
+ Sinatra ::Application
9
+ end
10
+
11
+ def json_response
12
+ JSON . parse last_response . body
13
+ end
14
+
You can’t perform that action at this time.
0 commit comments