Fix non http promtail config add spec tests#26
Fix non http promtail config add spec tests#26jorbaum wants to merge 2 commits intocloudfoundry-community:mainfrom
Conversation
Start with promtail config file for now. Based on https://github.com/cloudfoundry/otel-collector-release
| - uses: actions/checkout@v4 | ||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' |
There was a problem hiding this comment.
Not sure if its OK to use newer version here?
|
@ZPascal can you take a look at it? |
There was a problem hiding this comment.
Pull request overview
Fixes the promtail Loki client URL scheme selection (http vs https) in the BOSH template and adds an RSpec-based spec test + CI workflow to validate the rendered config.
Changes:
- Correct the promtail Loki client URL to use
http://when TLS/mTLS is disabled. - Add an RSpec test verifying the rendered Loki client URL scheme.
- Add Ruby/Bundler setup (Gemfile/lock), a spec-test script, and a GitHub Actions workflow to run the specs.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
jobs/promtail/templates/config/config.yml.erb |
Fixes URL scheme logic for the Loki client endpoint. |
spec/jobs/promtail_spec.rb |
Adds spec coverage for http vs https Loki client URL rendering. |
scripts/subtests/spec-test |
Adds a script entrypoint for running the spec suite via bundler. |
Gemfile |
Introduces Ruby dependencies needed for spec testing. |
Gemfile.lock |
Locks Ruby dependency versions for reproducible CI runs. |
.github/workflows/scripts.yml |
Runs the spec-test script on PRs/pushes to main. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| require 'bosh/template/test' | ||
|
|
||
| describe 'promtail config/config.yml.erb' do | ||
| let(:release_dir) { File.join(File.dirname(__FILE__), '../..') } |
There was a problem hiding this comment.
release_dir currently resolves to <repo>/spec, but Bosh::Template::Test::ReleaseDir expects the BOSH release root (where jobs/, packages/, etc live). With the current path, release.job('promtail') will fail to find the job. Consider using File.expand_path('../../..', __dir__) (or equivalent) to point to the repository root.
| let(:release_dir) { File.join(File.dirname(__FILE__), '../..') } | |
| let(:release_dir) { File.expand_path('../../..', __dir__) } |
| @@ -0,0 +1,43 @@ | |||
| # frozen_string_literal: true | |||
|
|
|||
| require 'rspec' | |||
There was a problem hiding this comment.
This spec uses YAML.safe_load but does not require 'yaml'. Depending on load order, YAML may not be defined, causing the spec to fail in CI. Add an explicit require 'yaml' near the other requires.
| require 'rspec' | |
| require 'rspec' | |
| require 'yaml' |
| #!/bin/bash | ||
|
|
||
| set -eux | ||
| set -o pipefail |
There was a problem hiding this comment.
Can be handled in one line :)
| semi_semantic (1.2.0) | ||
|
|
||
| PLATFORMS | ||
| arm64-darwin-24 |
There was a problem hiding this comment.
It would be better to use the Linux platform instead.
| - uses: actions/checkout@v4 | ||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' |
There was a problem hiding this comment.
Please use a newer version.
This mainly fixes a minor typo.
While I was at it I also added some tests and GitHub workflow for it based on
https://github.com/cloudfoundry/otel-collector-release
Only the two properties of the promtail config file are being tested for now.