leafy-rack 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 -8
- data/README.md +10 -148
- 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/leafy-health/Rakefile +14 -0
- data/leafy-health/leafy-health.gemspec +27 -0
- data/leafy-health/lib/leafy-health.rb +2 -0
- data/leafy-health/lib/leafy-health_jars.rb +7 -0
- data/leafy-health/lib/leafy/health.rb +2 -0
- data/leafy-health/lib/leafy/health/health_check.rb +72 -0
- data/leafy-health/lib/leafy/health/registry.rb +55 -0
- data/leafy-health/lib/leafy/health/version.rb +6 -0
- data/leafy-health/spec/registry_spec.rb +164 -0
- data/leafy-health/spec/setup.rb +1 -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/{Rakefile → leafy-logger/Rakefile} +0 -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.gemspec → leafy-rack/leafy-rack.gemspec} +2 -2
- data/{lib → leafy-rack/lib}/leafy-rack.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy-rack_jars.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/instrumented/basic_instrumented.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/instrumented/instrumented.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/json/health_writer.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/json/json_writer.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/json/metrics_writer.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/admin.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/health.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/instrumented.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/metrics.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/ping.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/thread_dump.rb +0 -0
- data/{lib → leafy-rack/lib}/leafy/rack/version.rb +1 -1
- data/{spec → leafy-rack/spec}/admin_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/basic_instrumented_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/health_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/health_writer_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/instrumented_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/instrumented_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/metrics_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/metrics_writer_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/ping_rack_spec.rb +0 -0
- data/{spec → leafy-rack/spec}/setup.rb +0 -0
- data/{spec → leafy-rack/spec}/thread_dump_spec.rb +0 -0
- metadata +110 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45a059202e7dce86e4bd2906a0cae00ba661a8d1
|
4
|
+
data.tar.gz: 1f7e29163f2adf8cfa07cd37fd2ecaa07104155f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb48a0c9b1b90a79c4e1ec965a6229d6caf91cf011d35e9f57e646483a490ae8c397ea33cbb72dabf6625b53ee61fd849316564b78970ed067380a4e8bab5b1
|
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,155 +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-rack
|
8
|
-
```
|
9
|
-
or add to your Gemfile
|
10
|
-
```
|
11
|
-
gem 'leafy-rack
|
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
|
-
## serializers for health and metrics data
|
27
|
-
|
28
|
-
are using the internal API of ```Leafy::Health::Registry``` or ```Leafy::Metrics::Registry``` to ```run_health_checks``` or retrieve the collect metrics and produces the json representation of these data.
|
29
|
-
|
30
|
-
registry = Leafy::Health::Registry.new
|
31
|
-
json_writer = Leafy::Json::HealthWriter.new
|
32
|
-
json_writer.to_json( registry.health.run_health_checks )
|
33
|
-
|
34
|
-
or
|
35
|
-
|
36
|
-
registry = Leafy::Metrics::Registry.new
|
37
|
-
json_writer = Leafy::Json::MetricsWriter.new
|
38
|
-
json_writer.to_json( registry.metrics )
|
39
|
-
|
40
|
-
both json writers can take a second argument to generate pretty prints:
|
41
|
-
|
42
|
-
json_writer.to_json( registry.health.run_health_checks, true )
|
43
|
-
json_writer.to_json( registry.metrics, true )
|
44
|
-
|
45
|
-
## instrumented http response
|
46
|
-
|
47
|
-
the class ```Leafy::Instrumented::Instrumented``` has a call method which expect a block. the block needs to return the usual rack middleware result ```[status, headers, body]```.
|
48
|
-
|
49
|
-
typical usage of this inside a rack-middleware
|
50
|
-
|
51
|
-
metrics = Leafy::Metrics::Registry.new
|
52
|
-
instrumented = Leafy::Instrumented::Instrumented.new( metrics, 'myapp' )
|
53
|
-
instrumented.call do
|
54
|
-
@app.call( env )
|
55
|
-
end
|
56
|
-
|
57
|
-
see the ```Leafy::Rack::Instrumented``` for an example.
|
58
|
-
|
59
|
-
## rack middleware
|
60
|
-
|
61
|
-
* instrumented middleware collecting metrics on response status, response time, and active requests
|
62
|
-
* json data of metrics snapshot
|
63
|
-
* json data of current health
|
64
|
-
* ping
|
65
|
-
* java thread-dump
|
66
|
-
* admin page with links to metrics, health, ping and thread-dump data
|
67
|
-
|
68
|
-
### instrumented middleware
|
69
|
-
|
70
|
-
metrics = Leafy::Metrics::Registry.new
|
71
|
-
use Leafy::Rack::Instrumented, Leafy::Instrumented::Instrumented.new( metrics, 'webapp' )
|
72
|
-
|
73
|
-
note: when this instrumented middleware gets configured **after** any of the admin middleware (see below) then those admin requests are not going into the instrumented metrics.
|
74
|
-
|
75
|
-
### metrics middleware
|
76
|
-
|
77
|
-
json data of a snapshot of metrics are under the path **/metrics**
|
78
|
-
|
79
|
-
metrics = Leafy::Metrics::Registry.new
|
80
|
-
use Leafy::Rack::Metrics, metrics
|
81
|
-
|
82
|
-
or with custom path
|
83
|
-
|
84
|
-
metrics = Leafy::Metrics::Registry.new
|
85
|
-
use Leafy::Rack::Metrics, metrics, '/admin/metrics'
|
86
|
-
|
87
|
-
### health-checks middleware
|
88
|
-
|
89
|
-
json data of current health are under the path **/health**
|
90
|
-
|
91
|
-
health = Leafy::Health::Registry.new
|
92
|
-
use Leafy::Rack::Health, health
|
93
|
-
|
94
|
-
or with custom path
|
95
|
-
|
96
|
-
health = Leafy::Health::Registry.new
|
97
|
-
use Leafy::Rack::Health, health, '/admin/health'
|
98
|
-
|
99
|
-
### ping middleware
|
100
|
-
|
101
|
-
under the path **/ping**
|
102
|
-
|
103
|
-
use Leafy::Rack::Ping
|
104
|
-
|
105
|
-
or with custom path
|
106
|
-
|
107
|
-
use Leafy::Rack::Ping, '/admin/ping'
|
108
|
-
|
109
|
-
### java thread-dump middleware
|
110
|
-
|
111
|
-
under the path **/threads**
|
112
|
-
|
113
|
-
use Leafy::Rack::ThreadDump
|
114
|
-
|
115
|
-
or with custom path
|
116
|
-
|
117
|
-
use Leafy::Rack::ThreadDump, '/admin/threads'
|
118
|
-
|
119
|
-
|
120
|
-
### admin page middleware
|
121
|
-
|
122
|
-
a simple page with links to metrics, health, ping and thread-dump data under the path **/admin**
|
123
|
-
|
124
|
-
metrics = Leafy::Metrics::Registry.new
|
125
|
-
health = Leafy::Health::Registry.new
|
126
|
-
|
127
|
-
use Leafy::Rack::Admin, metrics, health
|
128
|
-
|
129
|
-
or with custom path
|
130
|
-
|
131
|
-
metrics = Leafy::Metrics::Registry.new
|
132
|
-
health = Leafy::Health::Registry.new
|
133
|
-
|
134
|
-
use Leafy::Rack::Admin, metrics, health, '/hidden/admin'
|
135
|
-
|
136
|
-
## example sinatra app
|
137
|
-
|
138
|
-
there is an [example sinatra application](https://github.com/lookout/leafy/tree/master/examples/hellowarld) which uses admin and instrumented middleware and adds some extra metrics inside the application.
|
139
|
-
|
140
|
-
## developement
|
141
|
-
|
142
|
-
get all the gems and jars in place
|
143
|
-
|
144
|
-
gem install jar-dependencies --development
|
145
|
-
bundle install
|
146
|
-
|
147
|
-
please make sure you are using jar-dependencies > 0.1.8 !
|
148
|
-
|
149
|
-
for running all specs
|
150
|
-
|
151
|
-
rake
|
152
|
-
|
153
|
-
or
|
154
|
-
|
155
|
-
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' )
|