Skip to content

Commit

Permalink
Continued cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
silug committed Jan 2, 2025
1 parent d47c4ec commit 346f90d
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 204 deletions.
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ Style/TrailingBodyOnMethodDefinition:
Style/TrailingBodyOnModule:
Enabled: false
Style/TrailingCommaInHashLiteral:
Enabled: false
Enabled: true
EnforcedStyleForMultiline: comma
Style/TrailingMethodEndStatement:
Enabled: false
Style/UnpackFirst:
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ gem_sources.each { |gem_source| source gem_source }
group :syntax do
gem 'metadata-json-lint'
gem 'puppet-lint-trailing_comma-check', require: false
gem 'rubocop', '~> 1.68.0'
gem 'rubocop', '~> 1.69.2'
gem 'rubocop-performance', '~> 1.23.0'
gem 'rubocop-rake', '~> 0.6.0'
gem 'rubocop-rspec', '~> 3.2.0'
gem 'rubocop-rspec', '~> 3.3.0'
end

group :test do
Expand Down Expand Up @@ -45,7 +45,7 @@ group :system_tests do
gem 'bcrypt_pbkdf'
gem 'beaker'
gem 'beaker-rspec'
gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', ['>= 1.32.1', '< 2'])
gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', ['>= 1.34.3', '< 2'])
end

# Evaluate extra gemfiles if they exist
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/rsyslogd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

response = {
'version' => nil,
'features' => {}
'features' => {},
}

version_line = rsyslogd_info.shift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
describe 'run inspec against the appropriate fixtures' do
profiles_to_validate = ['disa_stig']

# rubocop:disable RSpec/InstanceVariable, RSpec/RepeatedDescription
hosts.each do |host|
profiles_to_validate.each do |profile|
context "for profile #{profile}" do
Expand Down Expand Up @@ -61,4 +62,5 @@
end
end
end
# rubocop:enable RSpec/InstanceVariable, RSpec/RepeatedDescription
end
12 changes: 6 additions & 6 deletions spec/acceptance/suites/default/02_client_server_udp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
test_name 'client -> server using UDP'

describe 'rsyslog class' do
before(:all) do
let(:msg_uuid) do
# Ensure that our test doesn't match messages from other tests
sleep(1)
@msg_uuid = Time.now.to_f.to_s.tr('.', '_') + '_UDP'
Time.now.to_f.to_s.tr('.', '_') + '_UDP'
end

let(:client) { only_host_with_role(hosts, 'client') }
Expand All @@ -18,7 +18,7 @@
'rsyslog::log_servers' => ['server-1'],
'rsyslog::logrotate' => true,
'rsyslog::enable_tls_logging' => false,
'rsyslog::pki' => false
'rsyslog::pki' => false,
}
end
let(:client_manifest) do
Expand All @@ -43,7 +43,7 @@
'rsyslog::server::enable_selinux' => true,
# If you enable this, you need to make sure to add a tcpwrappers rule
# for sshd
'rsyslog::server::enable_tcpwrappers' => false
'rsyslog::server::enable_tcpwrappers' => false,
}
end
let(:server_manifest) do
Expand Down Expand Up @@ -93,10 +93,10 @@

it 'successfullies send log messages to the server over UDP' do
remote_log = "/var/log/hosts/#{client_fqdn}/everything.log"
on client, "logger -t FOO TEST-1-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-1-#{msg_uuid}-MSG"

on server, "test -f #{remote_log}"
on server, "grep TEST-1-#{@msg_uuid}-MSG #{remote_log}"
on server, "grep TEST-1-#{msg_uuid}-MSG #{remote_log}"
end
end
end
58 changes: 29 additions & 29 deletions spec/acceptance/suites/failover/04_failover_no_tls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
test_name 'client -> 2 server without TLS'

describe 'rsyslog class' do
before(:all) do
let(:msg_uuid) do
# Ensure that our test doesn't match messages from other tests
sleep(1)
@msg_uuid = Time.now.to_f.to_s.tr('.', '_') + '_NO_TLS'
Time.now.to_f.to_s.tr('.', '_') + '_NO_TLS'
end

let(:client) { only_host_with_role(hosts, 'client') }
Expand All @@ -19,7 +19,7 @@
'rsyslog::log_servers' => ['server-1', 'server-2'],
'rsyslog::logrotate' => true,
'rsyslog::enable_tls_logging' => false,
'rsyslog::pki' => false
'rsyslog::pki' => false,
}
end
let(:client_manifest) do
Expand All @@ -38,7 +38,7 @@
'rsyslog::failover_log_servers' => ['server-3'],
'rsyslog::logrotate' => true,
'rsyslog::enable_tls_logging' => false,
'rsyslog::pki' => false
'rsyslog::pki' => false,
}
end

Expand All @@ -50,7 +50,7 @@
'rsyslog::enable_tls_logging' => false,
'rsyslog::pki' => false,
'rsyslog::config::main_msg_queue_high_watermark' => 2,
'rsyslog::config::main_msg_queue_low_watermark' => 1
'rsyslog::config::main_msg_queue_low_watermark' => 1,
}
end

Expand Down Expand Up @@ -79,7 +79,7 @@
'rsyslog::server::enable_selinux' => true,
# If you enable this, you need to make sure to add a tcpwrappers rule
# for sshd
'rsyslog::server::enable_tcpwrappers' => false
'rsyslog::server::enable_tcpwrappers' => false,
}
end
let(:server_manifest) do
Expand Down Expand Up @@ -134,15 +134,15 @@
# Default scenario, everything goes to both primary servers
it 'successfullies send log messages to the primary servers but not the failover server' do
remote_log = "/var/log/hosts/#{client_fqdn}/everything.log"
on client, "logger -t FOO TEST-1-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-1-#{msg_uuid}-MSG"

servers.each do |server|
on server, "test -f #{remote_log}"
on server, "grep TEST-1-#{@msg_uuid}-MSG #{remote_log}"
on server, "grep TEST-1-#{msg_uuid}-MSG #{remote_log}"
end

failover_servers.each do |server|
on server, "! grep TEST-1-#{@msg_uuid}-MSG #{remote_log}"
on server, "! grep TEST-1-#{msg_uuid}-MSG #{remote_log}"
end
end

Expand All @@ -156,10 +156,10 @@
remote_log = "/var/log/hosts/#{client_fqdn}/everything.log"

# Make sure both primary servers are still working properly.
on client, "logger -t FOO TEST-10-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-10-#{msg_uuid}-MSG"

servers.each do |server|
on server, "grep TEST-10-#{@msg_uuid}-MSG #{remote_log}"
on server, "grep TEST-10-#{msg_uuid}-MSG #{remote_log}"
end

# Force Failover
Expand All @@ -172,17 +172,17 @@

# Log test messages
(11..20).each do |msg|
on client, "logger -t FOO TEST-#{msg}-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-#{msg}-#{msg_uuid}-MSG"
end

# Validate Failover
on failover_server, "grep TEST-11-#{@msg_uuid}-MSG #{remote_log}"
on failover_server, "grep TEST-19-#{@msg_uuid}-MSG #{remote_log}"
on failover_server, "grep TEST-11-#{msg_uuid}-MSG #{remote_log}"
on failover_server, "grep TEST-19-#{msg_uuid}-MSG #{remote_log}"

# Should not log to inactive servers
servers.each do |server|
on server, "grep TEST-11-#{@msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-19-#{@msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-11-#{msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-19-#{msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
end
end
end
Expand All @@ -197,12 +197,12 @@

# Make sure logs are still hitting the failover server
(21..30).each do |msg|
on client, "logger -t FOO TEST-#{msg}-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-#{msg}-#{msg_uuid}-MSG"
end

# Validate Failover
on failover_server, "grep TEST-21-#{@msg_uuid}-MSG #{remote_log}"
on failover_server, "grep TEST-29-#{@msg_uuid}-MSG #{remote_log}"
on failover_server, "grep TEST-21-#{msg_uuid}-MSG #{remote_log}"
on failover_server, "grep TEST-29-#{msg_uuid}-MSG #{remote_log}"

# Make sure that *all* remote logging is stopped
(failover_servers + servers).each do |server|
Expand All @@ -213,13 +213,13 @@

# Write some new logs and make sure that they don't hit the remote systems
(31..40).each do |msg|
on client, "logger -t FOO TEST-#{msg}-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-#{msg}-#{msg_uuid}-MSG"
end

# Should not log to inactive failover servers
(failover_servers + servers).each do |server|
on server, "grep TEST-31-#{@msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-39-#{@msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-31-#{msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-39-#{msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
end

# Check to see if we now have a queue on disk
Expand Down Expand Up @@ -249,8 +249,8 @@
# Messages should exist on the failover server
# Sometimes this can take quite a while...
# Between 20 and 30 Seconds seems to be about the norm for a full flush
wait_for_log_message(failover_server, remote_log, "TEST-31-#{@msg_uuid}-MSG")
wait_for_log_message(failover_server, remote_log, "TEST-39-#{@msg_uuid}-MSG")
wait_for_log_message(failover_server, remote_log, "TEST-31-#{msg_uuid}-MSG")
wait_for_log_message(failover_server, remote_log, "TEST-39-#{msg_uuid}-MSG")
end
end

Expand All @@ -265,19 +265,19 @@
sleep(2)

(41..50).each do |msg|
on client, "logger -t FOO TEST-#{msg}-#{@msg_uuid}-MSG"
on client, "logger -t FOO TEST-#{msg}-#{msg_uuid}-MSG"
end

# Sometimes this can take a while to flush
servers.each do |server|
wait_for_log_message(server, remote_log, "TEST-41-#{@msg_uuid}-MSG")
wait_for_log_message(server, remote_log, "TEST-50-#{@msg_uuid}-MSG")
wait_for_log_message(server, remote_log, "TEST-41-#{msg_uuid}-MSG")
wait_for_log_message(server, remote_log, "TEST-50-#{msg_uuid}-MSG")
end

# Should not log to inactive failover servers
failover_servers.each do |server|
on server, "grep TEST-41-#{@msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-49-#{@msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-41-#{msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
on server, "grep TEST-49-#{msg_uuid}-MSG #{remote_log}", acceptable_exit_codes: [1, 2]
end
end
end
Expand Down
Loading

0 comments on commit 346f90d

Please sign in to comment.