Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: scripts

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
spec-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
Comment thread
jorbaum marked this conversation as resolved.
Comment thread
jorbaum marked this conversation as resolved.
bundler-cache: true
- run: ./scripts/subtests/spec-test
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'rspec'
gem 'bosh-template'
31 changes: 31 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
GEM
remote: https://rubygems.org/
specs:
bosh-template (2.4.0)
semi_semantic (~> 1.2.0)
diff-lcs (1.6.2)
rspec (3.13.1)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.4)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.4)
semi_semantic (1.2.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
bosh-template
rspec

BUNDLED WITH
2.6.9
2 changes: 1 addition & 1 deletion jobs/promtail/templates/config/config.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ positions:
filename: <%= p('promtail.positions.filename') %>
clients:
<% if_p("promtail.loki.tls", "promtail.loki.mtls") do |promtail_loki_tls,promtail_loki_mtls| %>
- url: <% if promtail_loki_tls == true || promtail_loki_mtls == true %>https://<% else %>https://<% end %><%= p('promtail.loki.server.http_listen_address') %>:<%= p('promtail.loki.server.http_listen_port') %>/loki/api/v1/push
- url: <% if promtail_loki_tls == true || promtail_loki_mtls == true %>https://<% else %>http://<% end %><%= p('promtail.loki.server.http_listen_address') %>:<%= p('promtail.loki.server.http_listen_port') %>/loki/api/v1/push
<% if promtail_loki_tls == true || promtail_loki_mtls == true %>
tls_config:
ca_file: /var/vcap/jobs/promtail/loki/certs/ca.pem
Expand Down
17 changes: 17 additions & 0 deletions scripts/subtests/spec-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -euxo pipefail

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

set +e
bundler_executable=$(which bundle)
set -e
if [ -z "${bundler_executable}" ] || [ ! -x "${bundler_executable}" ]; then
gem install bundler
fi

pushd "${SCRIPT_DIR}/../.." > /dev/null
bundle install
bundle exec rspec
popd > /dev/null
44 changes: 44 additions & 0 deletions spec/jobs/promtail_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

require 'rspec'
Comment thread
jorbaum marked this conversation as resolved.
require 'yaml'
require 'bosh/template/test'

describe 'promtail config/config.yml.erb' do
let(:release_dir) { File.expand_path('../..', __dir__) }
let(:release) { Bosh::Template::Test::ReleaseDir.new(release_dir) }
let(:job) { release.job('promtail') }
let(:template) { job.template('config/config.yml') }

let(:properties) do
{
'promtail' => {
'loki' => {
'server' => {
'http_listen_address' => 'loki.example.com',
'http_listen_port' => 3100
},
'external_labels' => {}
}
}
}
end

let(:rendered) { YAML.safe_load(template.render(properties)) }

context 'when promtail.loki.tls is true' do
before { properties['promtail']['loki']['tls'] = true }

it 'uses https in the loki client url' do
expect(rendered['clients'][0]['url']).to eq('https://loki.example.com:3100/loki/api/v1/push')
end
end

context 'when promtail.loki.tls is false' do
before { properties['promtail']['loki']['tls'] = false }

it 'uses http in the loki client url' do
expect(rendered['clients'][0]['url']).to eq('http://loki.example.com:3100/loki/api/v1/push')
end
end
end
Loading