Skip to content

Commit 5afc6e2

Browse files
committed
[agent6][spec] adding RHEL and Ubuntu repo tests
1 parent 883f762 commit 5afc6e2

2 files changed

Lines changed: 107 additions & 6 deletions

File tree

spec/classes/datadog_agent_redhat_spec.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
context 'with manage_repo => true' do
1414
let(:params){ {:manage_repo => true} }
1515
it do
16+
should contain_yumrepo('datadog-beta')
17+
.with_ensure('absent')
1618
should contain_yumrepo('datadog')
1719
.with_enabled(1)\
1820
.with_gpgcheck(1)\
@@ -28,6 +30,55 @@
2830
end
2931

3032

33+
# it should install the packages
34+
it do
35+
should contain_package('datadog-agent-base')\
36+
.with_ensure('absent')\
37+
.that_comes_before('Package[datadog-agent]')
38+
end
39+
it do
40+
should contain_package('datadog-agent')\
41+
.with_ensure('latest')
42+
end
43+
44+
# it should be able to start the service and enable the service by default
45+
it do
46+
should contain_service('datadog-agent')\
47+
.that_requires('Package[datadog-agent]')
48+
end
49+
end
50+
51+
describe 'datadog_agent::redhat::agent6' do
52+
let(:facts) do
53+
{
54+
osfamily: 'redhat',
55+
operatingsystem: 'Fedora',
56+
architecture: 'x86_64'
57+
}
58+
end
59+
60+
# it should install the mirror
61+
context 'with manage_repo => true' do
62+
let(:params){ {:manage_repo => true} }
63+
it do
64+
should contain_yumrepo('datadog')
65+
.with_ensure('absent')
66+
should contain_yumrepo('datadog-beta')
67+
.with_enabled(1)\
68+
.with_gpgcheck(1)\
69+
.with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\
70+
.with_baseurl('https://yum.datadoghq.com/beta/x86_64/')
71+
end
72+
end
73+
context 'with manage_repo => false' do
74+
let(:params){ {:manage_repo => false} }
75+
it do
76+
should_not contain_yumrepo('datadog-beta')
77+
should_not contain_yumrepo('datadog-beta')
78+
end
79+
end
80+
81+
3182
# it should install the packages
3283
it do
3384
should contain_package('datadog-agent-base')\

spec/classes/datadog_agent_ubuntu_spec.rb

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
end
1010

1111
it do
12+
contain_file('/etc/apt/sources.list.d/datadog-beta.list')
13+
.with_ensure('absent')
1214
contain_file('/etc/apt/sources.list.d/datadog.list')\
1315
.with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+main})
1416
end
@@ -18,29 +20,77 @@
1820
it { should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') }
1921
it do
2022
should contain_file('/etc/apt/sources.list.d/datadog.list')\
21-
.that_notifies('Exec[datadog_apt-get_update]')
23+
.that_notifies('exec[datadog_apt-get_update]')
2224
end
2325
it { should contain_exec('datadog_apt-get_update') }
2426

2527
# it should install the packages
2628
it do
2729
should contain_package('apt-transport-https')\
28-
.that_comes_before('File[/etc/apt/sources.list.d/datadog.list]')
30+
.that_comes_before('file[/etc/apt/sources.list.d/datadog.list]')
2931
end
3032
it do
3133
should contain_package('datadog-agent-base')\
3234
.with_ensure('absent')\
33-
.that_comes_before('Package[datadog-agent]')
35+
.that_comes_before('package[datadog-agent]')
3436
end
3537
it do
3638
should contain_package('datadog-agent')\
37-
.that_requires('File[/etc/apt/sources.list.d/datadog.list]')\
38-
.that_requires('Exec[datadog_apt-get_update]')
39+
.that_requires('file[/etc/apt/sources.list.d/datadog.list]')\
40+
.that_requires('exec[datadog_apt-get_update]')
3941
end
4042

4143
# it should be able to start the service and enable the service by default
4244
it do
4345
should contain_service('datadog-agent')\
44-
.that_requires('Package[datadog-agent]')
46+
.that_requires('package[datadog-agent]')
47+
end
48+
end
49+
50+
describe 'datadog_agent::ubuntu::agent6' do
51+
let(:facts) do
52+
{
53+
osfamily: 'debian',
54+
operatingsystem: 'Ubuntu'
55+
}
56+
end
57+
58+
it do
59+
contain_file('/etc/apt/sources.list.d/datadog.list')
60+
.with_ensure('absent')
61+
contain_file('/etc/apt/sources.list.d/datadog-beta.list')\
62+
.with_content(%r{deb\s+https://apt.datadoghq.com/\s+beta\s+main})
63+
end
64+
65+
# it should install the mirror
66+
it { should contain_datadog_agent__ubuntu__install_key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') }
67+
it { should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') }
68+
69+
it do
70+
should contain_file('/etc/apt/sources.list.d/datadog-beta.list')\
71+
.that_notifies('exec[datadog_apt-get_update]')
72+
end
73+
it { should contain_exec('datadog_apt-get_update') }
74+
75+
# it should install the packages
76+
it do
77+
should contain_package('apt-transport-https')\
78+
.that_comes_before('file[/etc/apt/sources.list.d/datadog-beta.list]')
79+
end
80+
it do
81+
should contain_package('datadog-agent-base')\
82+
.with_ensure('absent')\
83+
.that_comes_before('package[datadog-agent]')
84+
end
85+
it do
86+
should contain_package('datadog-agent')\
87+
.that_requires('file[/etc/apt/sources.list.d/datadog-beta.list]')\
88+
.that_requires('exec[datadog_apt-get_update]')
89+
end
90+
91+
# it should be able to start the service and enable the service by default
92+
it do
93+
should contain_service('datadog-agent')\
94+
.that_requires('package[datadog-agent]')
4595
end
4696
end

0 commit comments

Comments
 (0)