Skip to content

Commit

Permalink
Remove namespace validation for agents
Browse files Browse the repository at this point in the history
Ensure entity config validator actually gets included
Update unit test fixtures to use HTTPS
Remove EOL OSes
Update default resources to match latest Sensu Go
Skip enterprise tests
Add test for agent working while backend is down
  • Loading branch information
treydock authored and Trey Dockendorf committed Oct 27, 2022
1 parent 9f6abce commit 8f224ab
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 134 deletions.
26 changes: 13 additions & 13 deletions .fixtures-latest.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
fixtures:
repositories:
apt:
repo: git://github.com/puppetlabs/puppetlabs-apt.git
repo: https://github.com/puppetlabs/puppetlabs-apt.git
stdlib:
repo: git://github.com/puppetlabs/puppetlabs-stdlib.git
repo: https://github.com/puppetlabs/puppetlabs-stdlib.git
datacat:
repo: git://github.com/richardc/puppet-datacat.git
repo: https://github.com/richardc/puppet-datacat.git
yumrepo_core:
repo: git://github.com/puppetlabs/puppetlabs-yumrepo_core
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core
puppet_version: ">= 6.0.0"
chocolatey:
repo: git://github.com/puppetlabs/puppetlabs-chocolatey.git
repo: https://github.com/puppetlabs/puppetlabs-chocolatey.git
# Needed by chocolatey
registry:
repo: git://github.com/puppetlabs/puppetlabs-registry.git
repo: https://github.com/puppetlabs/puppetlabs-registry.git
# Needed by chocolatey
powershell:
repo: git://github.com/puppetlabs/puppetlabs-powershell.git
repo: https://github.com/puppetlabs/puppetlabs-powershell.git
# Need by postgresql
augeas_core:
repo: git://github.com/puppetlabs/puppetlabs-augeas_core
repo: https://github.com/puppetlabs/puppetlabs-augeas_core
puppet_version: ">= 6.0.0"
# Need by postgresql
concat:
repo: git://github.com/puppetlabs/puppetlabs-concat.git
repo: https://github.com/puppetlabs/puppetlabs-concat.git
postgresql:
repo: git://github.com/puppetlabs/puppetlabs-postgresql.git
repo: https://github.com/puppetlabs/puppetlabs-postgresql.git
archive:
repo: git://github.com/voxpupuli/puppet-archive.git
repo: https://github.com/voxpupuli/puppet-archive.git
windows_env:
repo: git://github.com/voxpupuli/puppet-windows_env.git
repo: https://github.com/voxpupuli/puppet-windows_env.git
systemd:
repo: git://github.com/camptocamp/puppet-systemd.git
repo: https://github.com/camptocamp/puppet-systemd.git
symlinks:
sensu: "#{source_dir}"
26 changes: 13 additions & 13 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
fixtures:
repositories:
apt:
repo: git://github.com/puppetlabs/puppetlabs-apt.git
repo: https://github.com/puppetlabs/puppetlabs-apt.git
ref: 5.0.1
stdlib:
repo: git://github.com/puppetlabs/puppetlabs-stdlib.git
repo: https://github.com/puppetlabs/puppetlabs-stdlib.git
ref: 5.1.0
datacat:
repo: git://github.com/richardc/puppet-datacat.git
repo: https://github.com/richardc/puppet-datacat.git
ref: 0.6.2
yumrepo_core:
repo: git://github.com/puppetlabs/puppetlabs-yumrepo_core
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core
ref: 1.0.1
puppet_version: ">= 6.0.0"
chocolatey:
repo: git://github.com/puppetlabs/puppetlabs-chocolatey.git
repo: https://github.com/puppetlabs/puppetlabs-chocolatey.git
ref: 3.0.0
# Needed by chocolatey
registry:
repo: git://github.com/puppetlabs/puppetlabs-registry.git
repo: https://github.com/puppetlabs/puppetlabs-registry.git
ref: 1.0.0
# Needed by chocolatey
powershell:
repo: git://github.com/puppetlabs/puppetlabs-powershell.git
repo: https://github.com/puppetlabs/puppetlabs-powershell.git
ref: 1.0.1
# Need by postgresql
augeas_core:
repo: git://github.com/puppetlabs/puppetlabs-augeas_core
repo: https://github.com/puppetlabs/puppetlabs-augeas_core
ref: 1.0.4
puppet_version: ">= 6.0.0"
# Need by postgresql
concat:
repo: git://github.com/puppetlabs/puppetlabs-concat.git
repo: https://github.com/puppetlabs/puppetlabs-concat.git
ref: v6.0.0
postgresql:
repo: git://github.com/puppetlabs/puppetlabs-postgresql.git
repo: https://github.com/puppetlabs/puppetlabs-postgresql.git
ref: v6.4.0
archive:
repo: git://github.com/voxpupuli/puppet-archive.git
repo: https://github.com/voxpupuli/puppet-archive.git
ref: 'v3.0.0'
windows_env:
repo: git://github.com/voxpupuli/puppet-windows_env.git
repo: https://github.com/voxpupuli/puppet-windows_env.git
ref: 'v3.0.0'
systemd:
repo: git://github.com/camptocamp/puppet-systemd.git
repo: https://github.com/camptocamp/puppet-systemd.git
ref: '2.0.0'
symlinks:
sensu: "#{source_dir}"
4 changes: 1 addition & 3 deletions .github/workflows/acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ jobs:
matrix:
set:
- centos-7
- centos-8
- debian-9
- rocky-8
- debian-10
- ubuntu-1604
- ubuntu-1804
- ubuntu-2004
- amazonlinux-2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
puppet: 6
fixtures: .fixtures.yml
allow_failure: false
- ruby: 2.7.0
- ruby: 2.7.6
puppet: 7
fixtures: .fixtures.yml
allow_failure: false
- ruby: 2.5.7
puppet: 6
fixtures: .fixtures-latest.yml
allow_failure: true
- ruby: 2.7.0
- ruby: 2.7.6
puppet: 7
fixtures: .fixtures-latest.yml
allow_failure: true
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/type/sensu_agent_entity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,5 @@ def pre_run_check
if !config.is_a?(Hash) && self[:value].nil?
fail "You must provide a value for the value property"
end
PuppetX::Sensu::Type.validate_namespace(self)
end
end
1 change: 1 addition & 0 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
}

sensu_agent_entity_validator { $config['name']:
ensure => 'present',
namespace => $config['namespace'],
provider => 'sensu_api',
}
Expand Down
1 change: 1 addition & 0 deletions manifests/api.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}

sensu_api_validator { 'sensu':
ensure => 'present',
sensu_api_server => $sensu::api_host,
sensu_api_port => $sensu::api_port,
use_ssl => $sensu::use_ssl,
Expand Down
3 changes: 0 additions & 3 deletions manifests/backend/default_resources.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'assets',
'checks',
'entities',
'extensions',
'events',
'filters',
'handlers',
Expand Down Expand Up @@ -52,7 +51,6 @@
'assets',
'checks',
'entities',
'extensions',
'events',
'filters',
'handlers',
Expand Down Expand Up @@ -94,7 +92,6 @@
'assets',
'checks',
'entities',
'extensions',
'events',
'filters',
'handlers',
Expand Down
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,26 @@
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6",
"7",
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6",
"7",
"8"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"9",
"10"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"16.04",
"18.04",
"20.04"
]
Expand Down
43 changes: 43 additions & 0 deletions spec/acceptance/01_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,47 @@ class { 'sensu::agent':
end
end
end

context 'when backend is down' do
it 'should work with errors' do
pp = <<-EOS
class { '::sensu': }
class { 'sensu::agent':
backends => ['sensu-backend:8081'],
entity_name => 'sensu-agent',
subscriptions => ['base'],
labels => { 'foo' => 'bar' },
annotations => { 'contacts' => '[email protected]' },
service_env_vars => { 'SENSU_API_PORT' => '4041' },
config_hash => {
'log-level' => 'info',
'keepalive-interval' => 30,
}
}
sensu::agent::subscription { 'linux': }
sensu::agent::label { 'cpu.warning': value => '90' }
sensu::agent::label { 'cpu.critical': value => '95' }
sensu::agent::label { 'bar': value => 'baz2', redact => true }
sensu::agent::annotation { 'foobar': value => 'bar' }
sensu::agent::annotation { 'cpu.message': value => 'bar' }
sensu::agent::config_entry { 'keepalive-interval': value => 20 }
file { '/tmp/test': ensure => 'file' }
EOS

on backend, 'puppet resource service sensu-backend ensure=stopped'
if RSpec.configuration.sensu_use_agent
site_pp = "node 'sensu-agent' { #{pp} }"
puppetserver = hosts_as('puppetserver')[0]
create_remote_file(puppetserver, "/etc/puppetlabs/code/environments/production/manifests/site.pp", site_pp)
on node, puppet("agent -t --detailed-exitcodes"), acceptable_exit_codes: [1,4,6]
else
apply_manifest_on(node, pp, :catch_failures => false)
end
on backend, 'puppet resource service sensu-backend ensure=running'
end

describe file('/tmp/test'), :node => node do
it { is_expected.to be_file }
end
end
end
44 changes: 0 additions & 44 deletions spec/acceptance/nodesets/debian-9.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ HOSTS:
- sensu-agent
platform: el-8-x86_64
hypervisor: docker
image: centos:8
image: rockylinux:8
docker_preserve_image: true
docker_cmd:
- '/usr/sbin/init'
docker_image_commands:
- 'yum install -y dnf-utils'
- 'dnf config-manager --set-enabled powertools'
- 'dnf install -y wget which initscripts iproute langpacks-en glibc-all-langpacks'
- 'dnf install -y wget which initscripts iproute langpacks-en glibc-all-langpacks glibc-langpack-en'
docker_container_name: 'sensu-agent-el8'
sensu-backend:
roles:
Expand All @@ -22,14 +22,14 @@ HOSTS:
- default
platform: el-8-x86_64
hypervisor: docker
image: centos:8
image: rockylinux:8
docker_preserve_image: true
docker_cmd:
- '/usr/sbin/init'
docker_image_commands:
- 'yum install -y dnf-utils'
- 'dnf config-manager --set-enabled powertools'
- 'dnf install -y wget which initscripts iproute langpacks-en glibc-all-langpacks'
- 'dnf install -y wget which initscripts iproute langpacks-en glibc-all-langpacks glibc-langpack-en'
docker_container_name: 'sensu-backend-el8'
CONFIG:
log_level: debug
Expand Down
38 changes: 0 additions & 38 deletions spec/acceptance/nodesets/ubuntu-1604.yml

This file was deleted.

Loading

0 comments on commit 8f224ab

Please sign in to comment.