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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90d66e516c05b1928cca5f319524f41b6578b885
4
- data.tar.gz: a6f9aed4e14be636749bfa4536bc295044481704
3
+ metadata.gz: a52459b0af44d8070aa4f9540928e6e4f119e16f
4
+ data.tar.gz: 94f289b53c8bc488cc4ffb49d3dac9ffd976a1fa
5
5
  SHA512:
6
- metadata.gz: 18c970635472e70bb906be5f2be7fa126dcb6c134ca0a5a606239da7f25a0ec24f4aa6f0f36acf9cbdbff07dcdf66c04397e85b947d723e4f1561f3577fe03ef
7
- data.tar.gz: 701a21b78fbd8b7e528e074bf1d18e8131b1f4d60a807d4c1fc781fc9afcab2efe3bcb3d9d4a1bf36c2aeeec77fae8d47c8e60bec6d12840b3ce307a180b778d
6
+ metadata.gz: 5ea42940af0dd06f8a4cbbe9506c7c65689073634a0d35aaa6980db8e37a99cdad516b623090c747b1e959fe7526248d84e076f8bc1e4e5ac9e1b7d5bd90a96b
7
+ data.tar.gz: a898999804de640f8527901f79fcb94661096406625f01964728bfec650e78df743a00dae9c687244b5516ed6f6644ee85ba713444eed08a1a031139b8b7ac12
@@ -1 +1 @@
1
- 1.9.3-p194
1
+ 2.6.5
data/Dockerfile CHANGED
@@ -1,20 +1,52 @@
1
- FROM debian:stretch
1
+ FROM debian:buster-slim
2
+
2
3
  EXPOSE 9293/TCP
3
- EXPOSE 9294/TCP
4
- WORKDIR /home/litmus_paper
5
- RUN apt-get update && apt-get install -y ruby ruby-dev git curl rsyslog build-essential
6
- RUN gem install --no-ri --no-rdoc bundler \
7
- && gem install sinatra --no-ri --no-rdoc --version "~> 1.3.2" \
8
- && gem install remote_syslog_logger --no-ri --no-rdoc --version "~> 1.0.3" \
9
- && gem install unicorn --no-ri --no-rdoc --version "~> 4.6.2" \
10
- && gem install colorize --no-ri --no-rdoc \
11
- && gem install rspec --no-ri --no-rdoc --version "~> 2.9.0" \
12
- && gem install rack-test --no-ri --no-rdoc --version "~> 0.6.1" \
13
- && gem install rake --no-ri --no-rdoc --version "~> 0.9.2.2" \
14
- && gem install rake_commit --no-ri --no-rdoc --version "~> 0.13"
15
- ADD . /home/litmus_paper
16
- RUN ln -sf /home/litmus_paper/docker/litmus.conf /etc/litmus.conf \
17
- && ln -sf /home/litmus_paper/docker/litmus_unicorn.rb /etc/litmus_unicorn.rb
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"]
@@ -1,4 +1,4 @@
1
- port 9292
1
+ port 9293
2
2
  data_directory '/tmp/litmus_paper'
3
3
  cache_location '/tmp/litmus_paper_cache'
4
4
  cache_ttl -1
@@ -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
@@ -1,3 +1,3 @@
1
1
  module LitmusPaper
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -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.0
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-06 00:00:00.000000000 Z
11
+ date: 2020-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra