Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance acceptance tests / dont quote web.external-url param #245

Merged
merged 2 commits into from
Aug 2, 2018
Merged
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
8 changes: 6 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@
} else {
# helper variable indicating prometheus version, so we can use on this information in the template
$prometheus_v2 = true
$daemon_flags = [
$daemon_flags_basic = [
"--config.file=${prometheus::server::config_dir}/${prometheus::server::configname}",
"--storage.tsdb.path=${prometheus::server::localstorage}",
"--storage.tsdb.retention=${prometheus::server::storage_retention}",
"--web.console.templates=${prometheus::server::shared_dir}/consoles",
"--web.console.libraries=${prometheus::server::shared_dir}/console_libraries",
"--web.external-url='${prometheus::server::external_url}'",
]
if $prometheus::server::external_url {
$daemon_flags = $daemon_flags_basic + "--web.external-url=${prometheus::server::external_url}"
} else {
$daemon_flags = $daemon_flags_basic
}
}

# the vast majority of files here are init-files
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
Hash $config_hash = {},
Hash $config_defaults = {},
String $os = downcase($facts['kernel']),
Variant[Stdlib::HTTPUrl, Stdlib::Unixpath, String[0]] $external_url = '',
Optional[Variant[Stdlib::HTTPUrl, Stdlib::Unixpath, String[1]]] $external_url = undef,
) {

case $arch {
Expand Down
84 changes: 42 additions & 42 deletions manifests/server.pp
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
# class to manage the actual prometheus server
# this is a private class that gets called from the init.pp
class prometheus::server (
String $configname = $prometheus::configname,
String $user = $prometheus::user,
String $group = $prometheus::group,
Array $extra_groups = $prometheus::extra_groups,
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
Stdlib::Absolutepath $shared_dir = $prometheus::shared_dir,
String $version = $prometheus::version,
String $install_method = $prometheus::install_method,
Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl] $download_url_base = $prometheus::download_url_base,
String $download_extension = $prometheus::download_extension,
String $package_name = $prometheus::package_name,
String $package_ensure = $prometheus::package_ensure,
String $config_dir = $prometheus::config_dir,
Stdlib::Absolutepath $localstorage = $prometheus::localstorage,
String $config_template = $prometheus::config_template,
String $config_mode = $prometheus::config_mode,
Hash $global_config = $prometheus::global_config,
Array $rule_files = $prometheus::rule_files,
Array $scrape_configs = $prometheus::scrape_configs,
Array $remote_read_configs = $prometheus::remote_read_configs,
Array $remote_write_configs = $prometheus::remote_write_configs,
Variant[Array,Hash] $alerts = $prometheus::alerts,
Array $alert_relabel_config = $prometheus::alert_relabel_config,
Array $alertmanagers_config = $prometheus::alertmanagers_config,
String $storage_retention = $prometheus::storage_retention,
Stdlib::Absolutepath $env_file_path = $prometheus::env_file_path,
Hash $extra_alerts = $prometheus::extra_alerts,
Boolean $service_enable = $prometheus::service_enable,
String $service_ensure = $prometheus::service_ensure,
Boolean $manage_service = $prometheus::manage_service,
Boolean $restart_on_change = $prometheus::restart_on_change,
String $init_style = $prometheus::init_style,
String $extra_options = $prometheus::extra_options,
Hash $config_hash = $prometheus::config_hash,
Hash $config_defaults = $prometheus::config_defaults,
String $os = $prometheus::os,
Optional[String] $download_url = $prometheus::download_url,
String $arch = $prometheus::real_arch,
Boolean $manage_group = $prometheus::manage_group,
Boolean $purge_config_dir = $prometheus::purge_config_dir,
Boolean $manage_user = $prometheus::manage_user,
Variant[Stdlib::HTTPurl, Stdlib::Unixpath, String[0]] $external_url = $prometheus::external_url,
String $configname = $prometheus::configname,
String $user = $prometheus::user,
String $group = $prometheus::group,
Array $extra_groups = $prometheus::extra_groups,
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
Stdlib::Absolutepath $shared_dir = $prometheus::shared_dir,
String $version = $prometheus::version,
String $install_method = $prometheus::install_method,
Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl] $download_url_base = $prometheus::download_url_base,
String $download_extension = $prometheus::download_extension,
String $package_name = $prometheus::package_name,
String $package_ensure = $prometheus::package_ensure,
String $config_dir = $prometheus::config_dir,
Stdlib::Absolutepath $localstorage = $prometheus::localstorage,
String $config_template = $prometheus::config_template,
String $config_mode = $prometheus::config_mode,
Hash $global_config = $prometheus::global_config,
Array $rule_files = $prometheus::rule_files,
Array $scrape_configs = $prometheus::scrape_configs,
Array $remote_read_configs = $prometheus::remote_read_configs,
Array $remote_write_configs = $prometheus::remote_write_configs,
Variant[Array,Hash] $alerts = $prometheus::alerts,
Array $alert_relabel_config = $prometheus::alert_relabel_config,
Array $alertmanagers_config = $prometheus::alertmanagers_config,
String $storage_retention = $prometheus::storage_retention,
Stdlib::Absolutepath $env_file_path = $prometheus::env_file_path,
Hash $extra_alerts = $prometheus::extra_alerts,
Boolean $service_enable = $prometheus::service_enable,
String $service_ensure = $prometheus::service_ensure,
Boolean $manage_service = $prometheus::manage_service,
Boolean $restart_on_change = $prometheus::restart_on_change,
String $init_style = $prometheus::init_style,
String $extra_options = $prometheus::extra_options,
Hash $config_hash = $prometheus::config_hash,
Hash $config_defaults = $prometheus::config_defaults,
String $os = $prometheus::os,
Optional[String] $download_url = $prometheus::download_url,
String $arch = $prometheus::real_arch,
Boolean $manage_group = $prometheus::manage_group,
Boolean $purge_config_dir = $prometheus::purge_config_dir,
Boolean $manage_user = $prometheus::manage_user,
Optional[Variant[Stdlib::HTTPurl, Stdlib::Unixpath, String[1]]] $external_url = $prometheus::external_url,
) inherits prometheus {

if( versioncmp($version, '1.0.0') == -1 ){
Expand Down
20 changes: 19 additions & 1 deletion spec/acceptance/prometheus_server_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper_acceptance'

describe 'prometheus server' do
describe 'prometheus server basics' do
it 'prometheus server via main class works idempotently with no errors' do
pp = "class{'prometheus': manage_prometheus_server => true }"

Expand Down Expand Up @@ -31,4 +31,22 @@
describe port(9090) do
it { is_expected.to be_listening.with('tcp6') }
end

describe 'prometheus server with options' do
it 'is idempotent' do
pp = "class{'prometheus::server': version => '2.3.2', external_url => '/test'}"
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe service('prometheus') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe port(9090) do
it { is_expected.to be_listening.with('tcp6') }
end
end
end
1 change: 0 additions & 1 deletion spec/fixtures/files/prometheus2.debian
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ DAEMON_ARGS="--config.file=/etc/prometheus/prometheus.yaml
--storage.tsdb.retention=360h
--web.console.templates=/usr/local/share/prometheus/consoles
--web.console.libraries=/usr/local/share/prometheus/console_libraries
--web.external-url=''
"
USER=prometheus
SCRIPTNAME=/etc/init.d/$NAME
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/files/prometheus2.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ExecStart=/usr/local/bin/prometheus \
--storage.tsdb.retention=360h \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \
--web.external-url='' \

ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/files/prometheus2.sysv
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ start() {
--storage.tsdb.retention=360h \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \
--web.external-url='' \
>> "$LOG_FILE" &
retcode=$?
mkpidfile
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/files/prometheus2.upstart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ script
--storage.tsdb.retention=360h \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \
--web.external-url='' \

end script

Expand Down