-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from sap-contributions/redis
Add Redis job
- Loading branch information
Showing
15 changed files
with
231 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<% | ||
cloud_controller_internal = link("cloud_controller_internal") | ||
if cloud_controller_internal.p("cc.experimental.use_puma_webserver") || cloud_controller_internal.p("cc.experimental.use_redis") | ||
%> | ||
|
||
check process redis | ||
with pidfile /var/vcap/sys/run/bpm/redis/redis.pid | ||
start program "/var/vcap/jobs/bpm/bin/bpm start redis" | ||
stop program "/var/vcap/jobs/bpm/bin/bpm stop redis" | ||
group vcap | ||
|
||
<% | ||
end | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
name: redis | ||
|
||
description: "Co-deployed Redis used for rate limiting and metrics" | ||
|
||
templates: | ||
bpm.yml.erb: config/bpm.yml | ||
pre-start.sh.erb: bin/pre-start.sh | ||
redis-cli.sh.erb: bin/redis-cli.sh | ||
|
||
packages: | ||
- redis | ||
|
||
consumes: | ||
- name: cloud_controller_internal | ||
type: cloud_controller_internal | ||
|
||
properties: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
processes: | ||
- name: redis | ||
executable: /var/vcap/packages/redis/redis-server | ||
args: | ||
- --port | ||
- 0 | ||
- --unixsocket | ||
- /var/vcap/data/redis/redis.sock | ||
- --save | ||
- "" | ||
ephemeral_disk: true | ||
limits: | ||
open_files: 10032 | ||
hooks: | ||
pre_start: /var/vcap/jobs/redis/bin/pre-start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
sysctl -w vm.overcommit_memory=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
/var/vcap/packages/redis/redis-cli -s /var/vcap/data/redis/redis.sock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
redis | ||
============ | ||
Redis in-memory data store. | ||
|
||
This file can be downloaded from the following locations: | ||
|
||
| Filename | Download URL | | ||
| -------- | ------------ | | ||
| 7.0.11.tar.gz | https://github.com/redis/redis/archive/7.0.11.tar.gz | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash -eu | ||
|
||
function main() { | ||
local redis_version | ||
redis_version="7.0.11" | ||
|
||
tar xzf "redis/${redis_version}.tar.gz" | ||
|
||
pushd "redis-${redis_version}" > /dev/null | ||
make | ||
|
||
cp src/redis-server src/redis-cli "${BOSH_INSTALL_TARGET}" | ||
popd > /dev/null | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
name: redis | ||
files: | ||
- redis/7.0.11.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec' | ||
require 'bosh/template/test' | ||
|
||
module Bosh | ||
module Template | ||
module Test | ||
describe 'redis job template rendering' do | ||
let(:release_path) { File.join(File.dirname(__FILE__), '../..') } | ||
let(:release) { ReleaseDir.new(release_path) } | ||
let(:job) { release.job('redis') } | ||
let(:spec) { job.instance_variable_get(:@spec) } | ||
let(:job_path) { job.instance_variable_get(:@job_path) } | ||
let(:cc_internal_properties) { { 'cc' => { 'experimental' => { 'use_puma_webserver' => false, 'use_redis' => false } } } } | ||
let(:link) { Link.new(name: 'cloud_controller_internal', properties: cc_internal_properties) } | ||
|
||
describe 'monit' do | ||
let(:template) { Template.new(spec, File.join(job_path, 'monit')) } | ||
|
||
context 'when the puma webserver is used' do | ||
it 'renders the monit directives' do | ||
cc_internal_properties['cc']['experimental']['use_puma_webserver'] = true | ||
result = template.render({}, consumes: [link]) | ||
expect(result).to include('check process redis') | ||
end | ||
end | ||
|
||
context "when 'cc.experimental.use_redis' is set to 'true'" do | ||
it 'renders the monit directives' do | ||
cc_internal_properties['cc']['experimental']['use_redis'] = true | ||
result = template.render({}, consumes: [link]) | ||
expect(result).to include('check process redis') | ||
end | ||
end | ||
|
||
context "when neither the puma webserver is used nor 'cc.experimental.use_redis' is set to 'true'" do | ||
it 'does not render the monit directives' do | ||
result = template.render({}, consumes: [link]) | ||
expect(result.strip).to eq('') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |