litmus_paper 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Dockerfile +48 -16
- data/docker/litmus.conf +1 -1
- data/docker/litmus_unicorn.rb +0 -3
- data/lib/litmus_paper/metric/haproxy_backends_health.rb +7 -0
- data/lib/litmus_paper/version.rb +1 -1
- data/spec/litmus_paper/app_spec.rb +10 -0
- data/spec/litmus_paper/metric/haproxy_backends_health_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52459b0af44d8070aa4f9540928e6e4f119e16f
|
4
|
+
data.tar.gz: 94f289b53c8bc488cc4ffb49d3dac9ffd976a1fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ea42940af0dd06f8a4cbbe9506c7c65689073634a0d35aaa6980db8e37a99cdad516b623090c747b1e959fe7526248d84e076f8bc1e4e5ac9e1b7d5bd90a96b
|
7
|
+
data.tar.gz: a898999804de640f8527901f79fcb94661096406625f01964728bfec650e78df743a00dae9c687244b5516ed6f6644ee85ba713444eed08a1a031139b8b7ac12
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.6.5
|
data/Dockerfile
CHANGED
@@ -1,20 +1,52 @@
|
|
1
|
-
FROM debian:
|
1
|
+
FROM debian:buster-slim
|
2
|
+
|
2
3
|
EXPOSE 9293/TCP
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
|
5
|
+
ENV APP_USER litmus_paper
|
6
|
+
ENV LANG C.UTF-8
|
7
|
+
ENV LC_ALL C.UTF-8
|
8
|
+
|
9
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
10
|
+
ruby \
|
11
|
+
ruby-dev \
|
12
|
+
bundler \
|
13
|
+
git \
|
14
|
+
curl \
|
15
|
+
rsyslog \
|
16
|
+
procps \
|
17
|
+
build-essential \
|
18
|
+
&& rm -rf /var/lib/apt/lists/*
|
19
|
+
|
20
|
+
# Create non-root user
|
21
|
+
RUN addgroup --gid 1000 --system $APP_USER && \
|
22
|
+
adduser --uid 1000 --ingroup $APP_USER --system $APP_USER
|
23
|
+
|
24
|
+
ENV GEM_HOME /usr/local/bundle
|
25
|
+
ENV BUNDLE_APP_CONFIG $GEM_HOME
|
26
|
+
ENV PATH $GEM_HOME/bin:$PATH
|
27
|
+
|
28
|
+
ADD litmus_paper.gemspec /home/$APP_USER/
|
29
|
+
ADD lib/litmus_paper/version.rb /home/$APP_USER/lib/litmus_paper/version.rb
|
30
|
+
ADD Gemfile* /home/$APP_USER/
|
31
|
+
|
32
|
+
WORKDIR /home/$APP_USER
|
33
|
+
|
34
|
+
RUN bundle config --global frozen 1 && \
|
35
|
+
bundle install \
|
36
|
+
-j2 \
|
37
|
+
--retry 3 \
|
38
|
+
# Remove unneeded files (cached *.gem, *.o, *.c)
|
39
|
+
&& rm -rf /usr/local/bundle/cache/*.gem \
|
40
|
+
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
|
41
|
+
&& find /usr/local/bundle/gems/ -name "*.o" -delete
|
42
|
+
|
43
|
+
ADD . /home/$APP_USER
|
44
|
+
RUN ln -sf /home/$APP_USER/docker/litmus.conf /etc/litmus.conf \
|
45
|
+
&& ln -sf /home/$APP_USER/docker/litmus_unicorn.rb /etc/litmus_unicorn.rb
|
18
46
|
RUN gem build litmus_paper.gemspec && gem install litmus_paper*.gem
|
47
|
+
RUN chown -R $APP_USER:$APP_USER /home/$APP_USER
|
48
|
+
|
49
|
+
# Drop to app user
|
50
|
+
USER $APP_USER
|
19
51
|
|
20
52
|
CMD ["bin/litmus", "-p", "9293", "-c", "/etc/litmus_unicorn.rb"]
|
data/docker/litmus.conf
CHANGED
data/docker/litmus_unicorn.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# vim: set ft=ruby
|
2
2
|
require 'remote_syslog_logger'
|
3
3
|
|
4
|
-
APP_ROOT = '/var/lib/gems/2.3.0/gems/litmus_paper-1.1.1'
|
5
|
-
|
6
4
|
worker_processes 5
|
7
|
-
working_directory APP_ROOT
|
8
5
|
|
9
6
|
logger(RemoteSyslogLogger.new('127.0.0.1', 514, :program => 'litmus_paper', :facility => 'daemon'))
|
10
7
|
|
@@ -23,6 +23,13 @@ module LitmusPaper
|
|
23
23
|
.inject(0) { |sum, server| sum + server["weight"].to_f }
|
24
24
|
|
25
25
|
((up_weight / total_weight) * @weight).to_i
|
26
|
+
|
27
|
+
rescue Timeout::Error
|
28
|
+
LitmusPaper.logger.info("HAProxy available check timed out for #{@cluster}")
|
29
|
+
0
|
30
|
+
rescue => e
|
31
|
+
LitmusPaper.logger.info("HAProxy available check failed for #{@cluster} with #{e.message}")
|
32
|
+
0
|
26
33
|
end
|
27
34
|
|
28
35
|
def stats
|
data/lib/litmus_paper/version.rb
CHANGED
@@ -60,6 +60,16 @@ describe LitmusPaper::App do
|
|
60
60
|
last_response.body.should include('Forcing health')
|
61
61
|
last_response.body.should include('88')
|
62
62
|
end
|
63
|
+
|
64
|
+
it "returns successfully if a haproxy backend socket is unreachable" do
|
65
|
+
LitmusPaper.services['test'] = LitmusPaper::Service.new('test', [], [LitmusPaper::Metric::HaproxyBackendsHealth.new(100, "/tmp/non-existant-socketfile", "haproxy")])
|
66
|
+
|
67
|
+
get "/"
|
68
|
+
|
69
|
+
last_response.status.should == 200
|
70
|
+
last_response.body.should include('test')
|
71
|
+
last_response.body.should include('0')
|
72
|
+
end
|
63
73
|
end
|
64
74
|
|
65
75
|
describe "POST /up" do
|
@@ -28,6 +28,11 @@ describe LitmusPaper::Metric::HaproxyBackendsHealth do
|
|
28
28
|
health = LitmusPaper::Metric::HaproxyBackendsHealth.new(50, "/tmp/stub-haproxy-stats", "yellow_cluster")
|
29
29
|
health.current_health.should == 16
|
30
30
|
end
|
31
|
+
|
32
|
+
it "should return a health of 0 if haproxy is not running" do
|
33
|
+
health = LitmusPaper::Metric::HaproxyBackendsHealth.new(100, "/tmp/non-existant-socketfile", "red_cluster")
|
34
|
+
health.current_health.should == 0
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
describe "#to_s" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litmus_paper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintreeps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|