leafy-health 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +34 -4
- data/.travis.yml +19 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -5
- data/README.md +10 -116
- data/examples/datadog/.gitignore +2 -0
- data/examples/datadog/Gemfile +12 -0
- data/examples/datadog/Mavenfile +22 -0
- data/examples/datadog/README.md +16 -0
- data/examples/datadog/lib/java_gauge.rb +20 -0
- data/examples/datadog/lib/metrics.rb +18 -0
- data/examples/datadog/lib/ruby_gauge.rb +19 -0
- data/examples/hellowarld/.gitignore +3 -0
- data/examples/hellowarld/Gemfile +15 -0
- data/examples/hellowarld/Mavenfile +162 -0
- data/examples/hellowarld/README.md +44 -0
- data/examples/hellowarld/Rakefile +13 -0
- data/examples/hellowarld/WEB-INF/web.xml +31 -0
- data/examples/hellowarld/app/hellowarld.rb +55 -0
- data/examples/hellowarld/app/views/person.erb +52 -0
- data/examples/hellowarld/config.ru +12 -0
- data/leafy-complete.gemspec +22 -0
- data/leafy-health/.gitignore +4 -0
- data/leafy-health/Gemfile +7 -0
- data/leafy-health/LICENSE +22 -0
- data/leafy-health/README.md +123 -0
- data/{Rakefile → leafy-health/Rakefile} +0 -0
- data/{leafy-health.gemspec → leafy-health/leafy-health.gemspec} +0 -0
- data/{lib → leafy-health/lib}/leafy-health.rb +0 -0
- data/{lib → leafy-health/lib}/leafy-health_jars.rb +0 -0
- data/{lib → leafy-health/lib}/leafy/health.rb +0 -0
- data/{lib → leafy-health/lib}/leafy/health/health_check.rb +0 -0
- data/{lib → leafy-health/lib}/leafy/health/registry.rb +0 -0
- data/{lib → leafy-health/lib}/leafy/health/version.rb +1 -1
- data/{spec → leafy-health/spec}/registry_spec.rb +0 -0
- data/{spec → leafy-health/spec}/setup.rb +0 -0
- data/leafy-logger/.gitignore +5 -0
- data/leafy-logger/Gemfile +9 -0
- data/leafy-logger/LICENSE +22 -0
- data/leafy-logger/README.md +174 -0
- data/leafy-logger/Rakefile +14 -0
- data/leafy-logger/leafy-logger.gemspec +32 -0
- data/leafy-logger/lib/leafy-logger.rb +1 -0
- data/leafy-logger/lib/leafy-logger_jars.rb +33 -0
- data/leafy-logger/lib/leafy/logger.rb +1 -0
- data/leafy-logger/lib/leafy/logger/appender_factories.rb +89 -0
- data/leafy-logger/lib/leafy/logger/factory.rb +141 -0
- data/leafy-logger/lib/leafy/logger/version.rb +6 -0
- data/leafy-logger/spec/appender_factories_spec.rb +147 -0
- data/leafy-logger/spec/factory_spec.rb +176 -0
- data/leafy-logger/spec/logging.yml +16 -0
- data/leafy-logger/spec/setup.rb +2 -0
- data/leafy-metrics/.gitignore +5 -0
- data/leafy-metrics/Gemfile +7 -0
- data/leafy-metrics/LICENSE +22 -0
- data/leafy-metrics/README.md +221 -0
- data/leafy-metrics/Rakefile +14 -0
- data/leafy-metrics/leafy-metrics.gemspec +29 -0
- data/leafy-metrics/lib/leafy-metrics.rb +2 -0
- data/leafy-metrics/lib/leafy-metrics_jars.rb +5 -0
- data/leafy-metrics/lib/leafy/metrics.rb +2 -0
- data/leafy-metrics/lib/leafy/metrics/console_reporter.rb +32 -0
- data/leafy-metrics/lib/leafy/metrics/csv_reporter.rb +26 -0
- data/leafy-metrics/lib/leafy/metrics/graphite/graphite.rb +28 -0
- data/leafy-metrics/lib/leafy/metrics/graphite/graphite_reporter.rb +43 -0
- data/leafy-metrics/lib/leafy/metrics/registry.rb +108 -0
- data/leafy-metrics/lib/leafy/metrics/reporter.rb +51 -0
- data/leafy-metrics/lib/leafy/metrics/version.rb +6 -0
- data/leafy-metrics/spec/console_reporter_spec.rb +72 -0
- data/leafy-metrics/spec/csv_reporter_spec.rb +75 -0
- data/leafy-metrics/spec/graphite_reporter_spec.rb +72 -0
- data/leafy-metrics/spec/graphite_spec.rb +23 -0
- data/leafy-metrics/spec/registry_spec.rb +106 -0
- data/leafy-metrics/spec/setup.rb +10 -0
- data/leafy-rack/.gitignore +4 -0
- data/leafy-rack/Gemfile +10 -0
- data/leafy-rack/LICENSE +22 -0
- data/leafy-rack/README.md +155 -0
- data/leafy-rack/Rakefile +14 -0
- data/leafy-rack/leafy-rack.gemspec +29 -0
- data/leafy-rack/lib/leafy-rack.rb +1 -0
- data/leafy-rack/lib/leafy-rack_jars.rb +10 -0
- data/leafy-rack/lib/leafy/instrumented/basic_instrumented.rb +38 -0
- data/leafy-rack/lib/leafy/instrumented/instrumented.rb +27 -0
- data/leafy-rack/lib/leafy/json/health_writer.rb +15 -0
- data/leafy-rack/lib/leafy/json/json_writer.rb +33 -0
- data/leafy-rack/lib/leafy/json/metrics_writer.rb +22 -0
- data/leafy-rack/lib/leafy/rack.rb +1 -0
- data/leafy-rack/lib/leafy/rack/admin.rb +73 -0
- data/leafy-rack/lib/leafy/rack/health.rb +43 -0
- data/leafy-rack/lib/leafy/rack/instrumented.rb +20 -0
- data/leafy-rack/lib/leafy/rack/metrics.rb +35 -0
- data/leafy-rack/lib/leafy/rack/ping.rb +29 -0
- data/leafy-rack/lib/leafy/rack/thread_dump.rb +56 -0
- data/leafy-rack/lib/leafy/rack/version.rb +6 -0
- data/leafy-rack/spec/admin_rack_spec.rb +141 -0
- data/leafy-rack/spec/basic_instrumented_spec.rb +31 -0
- data/leafy-rack/spec/health_rack_spec.rb +136 -0
- data/leafy-rack/spec/health_writer_spec.rb +47 -0
- data/leafy-rack/spec/instrumented_rack_spec.rb +37 -0
- data/leafy-rack/spec/instrumented_spec.rb +36 -0
- data/leafy-rack/spec/metrics_rack_spec.rb +110 -0
- data/leafy-rack/spec/metrics_writer_spec.rb +55 -0
- data/leafy-rack/spec/ping_rack_spec.rb +63 -0
- data/leafy-rack/spec/setup.rb +3 -0
- data/leafy-rack/spec/thread_dump_spec.rb +59 -0
- metadata +106 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dcd1798270792639a107c6ccf5869135d9022f2
|
4
|
+
data.tar.gz: 1f7e29163f2adf8cfa07cd37fd2ecaa07104155f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0e6c24f21a780d96c5b08ea8e7fa14779844b53c9c002a4e90c0a0ebb769cee58dd8e902c606b26ceaf3082e0534662c6b60eebfcbd13dcc7733d35f73e219
|
7
|
+
data.tar.gz: fd552f9fa3ca5d89e58598824e18836115e14773e5b7da29fdc26a6dbc81bc113c80aa345906eae73ff2b993f151fc59212b4363c8ca969c424a4ace0e40386b
|
data/.gitignore
CHANGED
@@ -1,4 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- jruby
|
4
|
+
- jruby-9.0.0.0-pre1
|
5
|
+
env:
|
6
|
+
- DIR=leafy-health
|
7
|
+
- DIR=leafy-metrics
|
8
|
+
- DIR=leafy-rack
|
9
|
+
- DIR=examples/hellowarld
|
10
|
+
|
11
|
+
gemfile: $DIR/Gemfile
|
12
|
+
install: cd $DIR; gem install jar-dependencies --development -v '~> 0.1.8'; bundle install --jobs=1 --retry=3 --gemfile Gemfile
|
13
|
+
|
14
|
+
script: bundle exec rake
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- env: DIR=examples/hellowarld
|
19
|
+
rvm: jruby-9.0.0.0-pre1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.3.0
|
4
|
+
|
5
|
+
* [#30](https://github.com/lookout/leafy/pull/30) allow to reconfigure the loggers via yaml or options during runtime
|
6
|
+
* [#26](https://github.com/lookout/leafy/issues/26) Admin endpoint URLs are not relative to where the app is being served
|
7
|
+
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,123 +1,17 @@
|
|
1
|
-
# Leafy
|
1
|
+
# Leafy
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/lookout/leafy.svg?branch=master)](https://travis-ci.org/lookout/leafy)
|
4
4
|
|
5
|
-
|
6
|
-
```
|
7
|
-
gem install leafy-health
|
8
|
-
```
|
9
|
-
or add to your Gemfile
|
10
|
-
```
|
11
|
-
gem 'leafy-health'
|
12
|
-
```
|
5
|
+
The green way to build Ruby-based web services
|
13
6
|
|
14
|
-
installing the gem also takes care of the jar dependencies with jruby-1.7.16+
|
15
7
|
|
16
|
-
##
|
8
|
+
## Goals
|
17
9
|
|
18
|
-
|
10
|
+
The goal of Leafy is to provide an out-of-the-box set of best practices and tools for building [JRuby](http://jruby.org)-based web services. In its initial form, it is based largely on [Dropwizard](http://dropwizard.io) underneath but this is not a long-term guarantee and may change in the future. As such the APIs exposed by Leafy should be stable regardless of what is "under the hood."
|
19
11
|
|
20
|
-
|
12
|
+
Leafy should provide standard means of:
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
### simple health check
|
27
|
-
|
28
|
-
simple in the sense that either call returns ```nil``` which means healthy or a message which is the unhealthy state. the message can be any ```String```.
|
29
|
-
|
30
|
-
registry.register( 'simple.block') do
|
31
|
-
if app.crashed
|
32
|
-
'application crashed'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
or with a health-check object
|
37
|
-
|
38
|
-
class AppCheck < Leafy::Health::HealthCheck
|
39
|
-
def call
|
40
|
-
if app.crashed
|
41
|
-
'application crashed'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
registry.register( 'simple.class', AppCheck.new )
|
46
|
-
|
47
|
-
### health checks with message on healthy state
|
48
|
-
|
49
|
-
here the call method gets an argument which allows to create both
|
50
|
-
healthy and unhealthy states with message.
|
51
|
-
|
52
|
-
registry.register( 'app.block') do
|
53
|
-
if app.crashed
|
54
|
-
unhealthy( 'application crashed' )
|
55
|
-
else
|
56
|
-
healthy( 'application ok' )
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
or with a health-check object
|
61
|
-
|
62
|
-
class AppCheck < Leafy::Health::HealthCheck
|
63
|
-
def call
|
64
|
-
if app.crashed
|
65
|
-
unhealthy( 'application crashed' )
|
66
|
-
else
|
67
|
-
healthy( 'application ok' )
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
registry.register( 'app.class', AppCheck.new )
|
72
|
-
|
73
|
-
### health checks with structural data as message
|
74
|
-
|
75
|
-
registry.register( 'app.block') do
|
76
|
-
if app.crashed
|
77
|
-
unhealthy( :host => 'localhost', :msg => 'not good' )
|
78
|
-
else
|
79
|
-
healthy( :host => 'localhost', :msg => 'application ok' )
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
or as health-check object
|
84
|
-
|
85
|
-
class AppCheck < Leafy::Health::HealthCheck
|
86
|
-
def call
|
87
|
-
if app.crashed
|
88
|
-
unhealthy( :host => 'localhost', :msg => 'application crashed' )
|
89
|
-
else
|
90
|
-
healthy( :host => 'localhost', :msg => 'application ok' )
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
registry.register( 'app.class', AppCheck.new )
|
95
|
-
|
96
|
-
### unregister health checks
|
97
|
-
|
98
|
-
registry.unregister( 'app.class' )
|
99
|
-
|
100
|
-
### builtin ThreadDeadlockHeathCheck
|
101
|
-
|
102
|
-
registry.register( 'app.deadlock', Leafy::Health::ThreadDeadlockHeathCheck.new )
|
103
|
-
|
104
|
-
### note
|
105
|
-
|
106
|
-
currently there is not further introspection on the registry and its health-check. with the ```Leafy::Json::HealthWriter``` (from leafy-rack) you can get a json representation of the current **health report**
|
107
|
-
|
108
|
-
Leafy::Json::HealthWriter.to_json( registry.health )
|
109
|
-
|
110
|
-
## developement
|
111
|
-
|
112
|
-
get all the gems and jars in place
|
113
|
-
|
114
|
-
gem install jar-dependencies --development
|
115
|
-
bundle install
|
116
|
-
|
117
|
-
for running all specs
|
118
|
-
|
119
|
-
rake
|
120
|
-
|
121
|
-
or
|
122
|
-
|
123
|
-
rspec spec/reporter_spec.rb
|
14
|
+
* Tracking metrics
|
15
|
+
* Logging
|
16
|
+
* Health checks
|
17
|
+
* Exposing operations-friendly interfaces
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
3
|
+
repository :id => 'bintray', :url => 'http://dl.bintray.com/lookout/systems'
|
4
|
+
|
5
|
+
jar 'com.github.lookout:metrics-datadog:0.1.4'
|
6
|
+
|
7
|
+
# dump Jars.lock
|
8
|
+
################
|
9
|
+
|
10
|
+
plugin_repository :id => 'sonatype-snapshots', :url => 'https://oss.sonatype.org/content/repositories/snapshots'
|
11
|
+
|
12
|
+
repository :id => 'rubygems-releases', :url => 'http://rubygems-proxy.torquebox.org/releases'
|
13
|
+
|
14
|
+
#properties 'jruby.plugins.version' =>
|
15
|
+
jruby_plugin! :gem, '1.0.9-SNAPSHOT' do
|
16
|
+
|
17
|
+
# duplicate dependency here and assume the local gem has the same
|
18
|
+
# dependencies as this one here
|
19
|
+
execute_goal 'jars-lock', :gems => ['leafy-metrics:0.3.0']
|
20
|
+
end
|
21
|
+
|
22
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# datadog gauge with tags example
|
2
|
+
|
3
|
+
## setup
|
4
|
+
|
5
|
+
execute with jruby
|
6
|
+
|
7
|
+
# installs all the gems
|
8
|
+
bundle install
|
9
|
+
# install all the jars and creates Jars.lock for the runtime
|
10
|
+
rmvn initialize
|
11
|
+
|
12
|
+
## run example
|
13
|
+
|
14
|
+
needs the datadog agent running and then
|
15
|
+
|
16
|
+
bundle exec ruby lib/metrics.rb
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class JavaGauge
|
2
|
+
include Java::OrgCourseraMetricsDatadog::Tagged
|
3
|
+
include com.codahale.metrics.Gauge
|
4
|
+
|
5
|
+
def value
|
6
|
+
r = Time.now.usec
|
7
|
+
p r
|
8
|
+
r
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
'leafy.demo.usec.java'
|
13
|
+
end
|
14
|
+
|
15
|
+
def tags
|
16
|
+
t = [Date::DAYNAMES[Time.now.wday]]
|
17
|
+
p t
|
18
|
+
t
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'leafy/metrics'
|
2
|
+
require 'leafy/metrics/reporter'
|
3
|
+
require_relative 'java_gauge'
|
4
|
+
require_relative 'ruby_gauge'
|
5
|
+
|
6
|
+
metrics = Leafy::Metrics::Registry.new
|
7
|
+
my = metrics.register_gauge( 'leafy.demo.java.usec', JavaGauge.new )
|
8
|
+
my = metrics.register_gauge( 'leafy.demo.ruby.usec', RubyGauge.new )
|
9
|
+
|
10
|
+
transport = Java::OrgCourseraMetricsDatadogTransport::UdpTransport::Builder.new.build
|
11
|
+
|
12
|
+
reporter = metrics.reporter_builder( Java::OrgCourseraMetricsDatadog::DatadogReporter ).withTransport(transport).build
|
13
|
+
|
14
|
+
reporter.start(1, Leafy::Metrics::Reporter::SECONDS)
|
15
|
+
|
16
|
+
sleep 3
|
17
|
+
|
18
|
+
reporter.stop
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class RubyGauge < Leafy::Metrics::Gauge
|
2
|
+
include Java::OrgCourseraMetricsDatadog::Tagged
|
3
|
+
|
4
|
+
def value
|
5
|
+
r = Time.now.usec
|
6
|
+
p r
|
7
|
+
r
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
'leafy.demo.usec.ruby'
|
12
|
+
end
|
13
|
+
|
14
|
+
def tags
|
15
|
+
t = [Date::DAYNAMES[Time.now.wday]]
|
16
|
+
p t
|
17
|
+
t
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gem 'leafy-metrics', :path => '../../leafy-metrics'
|
6
|
+
gem 'leafy-health', :path => '../../leafy-health'
|
7
|
+
gem 'leafy-rack', :path => '../../leafy-rack'
|
8
|
+
|
9
|
+
gem 'sinatra'
|
10
|
+
|
11
|
+
group 'development' do
|
12
|
+
gem 'ruby-maven'
|
13
|
+
gem 'rake', '~> 10.2'
|
14
|
+
end
|
15
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,162 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
3
|
+
gemfile
|
4
|
+
|
5
|
+
packaging :war
|
6
|
+
|
7
|
+
jar( 'org.jruby.rack:jruby-rack', '1.1.18',
|
8
|
+
:exclusions => [ 'org.jruby:jruby-complete' ] )
|
9
|
+
|
10
|
+
gem! 'bundler', '1.7.7'
|
11
|
+
# bug in getting all the gems in place via :path
|
12
|
+
gem! 'jar-dependencies', '0.1.8'
|
13
|
+
|
14
|
+
pom 'org.jruby:jruby', '${jruby.version}'
|
15
|
+
|
16
|
+
properties( 'project.build.sourceEncoding' => 'utf-8',
|
17
|
+
'jruby.version' => '1.7.19')
|
18
|
+
|
19
|
+
resource do
|
20
|
+
directory '${basedir}'
|
21
|
+
includes [ 'app/**', 'config.ru' ]
|
22
|
+
end
|
23
|
+
|
24
|
+
resource do
|
25
|
+
directory '${basedir}'
|
26
|
+
includes [ 'config.ru' ]
|
27
|
+
target_path 'WEB-INF'
|
28
|
+
end
|
29
|
+
|
30
|
+
build do
|
31
|
+
final_name File.basename( File.expand_path( '.' ) )
|
32
|
+
directory 'pkg'
|
33
|
+
end
|
34
|
+
|
35
|
+
# read the Jarfile.lock and embed those jars in WEB-INF/classes
|
36
|
+
if File.exists?( 'Jarfile.lock' )
|
37
|
+
phase 'generate-resources' do
|
38
|
+
plugin :dependency do
|
39
|
+
items = []
|
40
|
+
File.read( 'Jarfile.lock' ).each_line do |l|
|
41
|
+
data = l.sub(/-\ /, '').strip.split(':')
|
42
|
+
if data.size > 3
|
43
|
+
data = Hash[ [:groupId, :artifactId, :type, :version, :classifier].zip( data ) ]
|
44
|
+
data[ :outputDirectory ] = File.join( '${project.build.outputDirectory}',
|
45
|
+
data[:groupId].gsub(/[.]/, '/'),
|
46
|
+
data[:artifactId],
|
47
|
+
data[:version] )
|
48
|
+
items << data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
execute_goal( :copy,
|
52
|
+
:id => 'copy jar dependencies',
|
53
|
+
:artifactItems => items )
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Gemfile with references to local gems which again reference local gems
|
59
|
+
# does not work with this plugin. so we use our own setup
|
60
|
+
plugins.remove plugins.detect { |d| d.artifact_id == 'gem-maven-plugin' }
|
61
|
+
|
62
|
+
jruby_plugin!( :gem,
|
63
|
+
:includeRubygemsInResources => true ) do
|
64
|
+
execute_goal :initialize
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
plugin( :war, '2.2',
|
69
|
+
:webAppSourceDirectory => "${basedir}",
|
70
|
+
:webXml => 'WEB-INF/web.xml',
|
71
|
+
:webResources => [ { :directory => '${basedir}',
|
72
|
+
:targetPath => 'WEB-INF',
|
73
|
+
:includes => [ 'config.ru' ] } ] )
|
74
|
+
|
75
|
+
# integration tests
|
76
|
+
###################
|
77
|
+
|
78
|
+
require 'open-uri'
|
79
|
+
results = []
|
80
|
+
execute 'download', :phase => 'integration-test' do
|
81
|
+
results << open( 'http://localhost:8080/hellowarld/app' ).string
|
82
|
+
results << open( 'http://localhost:8080/hellowarld/admin' ).string
|
83
|
+
results << open( 'http://localhost:8080/hellowarld/admin/ping' ).string
|
84
|
+
results << open( 'http://localhost:8080/hellowarld/admin/health' ).string
|
85
|
+
results << open( 'http://localhost:8080/hellowarld/admin/metrics' ).string
|
86
|
+
results << open( 'http://localhost:8080/hellowarld/admin/threads' ).read
|
87
|
+
results << open( 'http://localhost:8080/hellowarld/ping' ).string
|
88
|
+
results << open( 'http://localhost:8080/hellowarld/health' ).string
|
89
|
+
results << open( 'http://localhost:8080/hellowarld/metrics' ).string
|
90
|
+
results << open( 'http://localhost:8080/hellowarld/threads' ).read
|
91
|
+
results.each { |r| puts r[0..20] }
|
92
|
+
end
|
93
|
+
|
94
|
+
# verify the downloads
|
95
|
+
require 'json'
|
96
|
+
execute 'verify downloads', :phase => :verify do
|
97
|
+
sleep 1 #let jetty shut down in peace
|
98
|
+
expected = 'christian'
|
99
|
+
unless results[0].match( /#{expected}/ )
|
100
|
+
raise "missed expected string in download: #{expected}"
|
101
|
+
end
|
102
|
+
expected = 'menu'
|
103
|
+
unless results[1].match( /#{expected}/ )
|
104
|
+
raise "missed expected string in download: #{expected}"
|
105
|
+
end
|
106
|
+
expected = 'pong'
|
107
|
+
unless results[2].match( /#{expected}/ )
|
108
|
+
raise "missed expected string in download: #{expected}"
|
109
|
+
end
|
110
|
+
json = JSON.parse( results[3] )
|
111
|
+
unless json["app.health"]["healthy"]
|
112
|
+
raise "healthy expected"
|
113
|
+
end
|
114
|
+
json = JSON.parse( results[4] )
|
115
|
+
unless json["meters"]["webapp.responseCodes.ok"]["count"] == 1
|
116
|
+
raise "one OK request expected"
|
117
|
+
end
|
118
|
+
unless results[5].length > 10000
|
119
|
+
puts result[5]
|
120
|
+
raise "expected thread dump to be big"
|
121
|
+
end
|
122
|
+
expected = 'pong'
|
123
|
+
unless results[6].match( /#{expected}/ )
|
124
|
+
raise "missed expected string in download: #{expected}"
|
125
|
+
end
|
126
|
+
json = JSON.parse( results[7] )
|
127
|
+
unless json["app.health"]["healthy"]
|
128
|
+
raise "healthy expected"
|
129
|
+
end
|
130
|
+
json = JSON.parse( results[8] )
|
131
|
+
unless json["meters"]["webapp.responseCodes.ok"]["count"] == 1
|
132
|
+
raise "one OK request expected"
|
133
|
+
end
|
134
|
+
unless results[9].length > 10000
|
135
|
+
puts result[9]
|
136
|
+
raise "expected thread dump to be big"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# jetty runner
|
141
|
+
##############
|
142
|
+
|
143
|
+
#plugin( 'org.mortbay.jetty:jetty-maven-plugin', '8.1.14.v20131031',
|
144
|
+
# :webAppSourceDirectory => "${basedir}" )
|
145
|
+
plugin( 'org.eclipse.jetty:jetty-maven-plugin', '9.3.0.M1',
|
146
|
+
:webAppSourceDirectory => "${basedir}",
|
147
|
+
:webApp => { :contextPath => '/hellowarld' },
|
148
|
+
:stopPort => 9999,
|
149
|
+
:stopKey => 'foo' ) do
|
150
|
+
execute_goal( 'start', :id => 'start jetty', :phase => 'pre-integration-test', :daemon => true )
|
151
|
+
execute_goal( 'stop', :id => 'stop jetty', :phase => 'post-integration-test' )
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
# tomcat runner
|
156
|
+
###############
|
157
|
+
plugin( 'org.codehaus.mojo:tomcat-maven-plugin', '1.1',
|
158
|
+
:warSourceDirectory => '${basedir}' )
|
159
|
+
|
160
|
+
# wildfly runner
|
161
|
+
################
|
162
|
+
plugin( 'org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final' )
|