Skip to content

Commit e40742c

Browse files
committed
Add kitchen test to validate logrotate configuration
Add kitchen tests that checks if the overall logrotate configuration is valid by triggering the `logrotate` command. Signed-off-by: Jacopo De Amicis <[email protected]>
1 parent 8eb077b commit e40742c

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

cookbooks/aws-parallelcluster-platform/kitchen.platform-config.yml

+41
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,47 @@ suites:
143143
attributes:
144144
cluster:
145145
node_type: HeadNode
146+
- name: log_rotation_head_node
147+
run_list:
148+
- recipe[aws-parallelcluster-platform::log_rotation]
149+
verifier:
150+
controls:
151+
- /tag:config_log_rotation_all_nodes/
152+
attributes:
153+
# Add attributes so that all possible logrotate configuration files are generated
154+
cluster:
155+
log_rotation_enabled: 'true'
156+
node_type: 'HeadNode'
157+
dcv_enabled: "head_node"
158+
directory_service:
159+
generate_ssh_keys_for_users: 'true'
160+
scheduler: 'slurm'
161+
- name: log_rotation_compute_fleet
162+
run_list:
163+
- recipe[aws-parallelcluster-platform::log_rotation]
164+
verifier:
165+
controls:
166+
- /tag:config_log_rotation_all_nodes/
167+
attributes:
168+
# Add attributes so that all possible logrotate configuration files are generated
169+
cluster:
170+
log_rotation_enabled: 'true'
171+
node_type: 'ComputeFleet'
172+
scheduler: 'slurm'
173+
- name: log_rotation_login_node
174+
run_list:
175+
- recipe[aws-parallelcluster-platform::log_rotation]
176+
verifier:
177+
controls:
178+
- /tag:config_log_rotation_all_nodes/
179+
attributes:
180+
# Add attributes so that all possible logrotate configuration files are generated
181+
cluster:
182+
log_rotation_enabled: 'true'
183+
node_type: 'LoginNode'
184+
directory_service:
185+
generate_ssh_keys_for_users: 'true'
186+
scheduler: 'slurm'
146187
- name: networking
147188
run_list:
148189
- recipe[aws-parallelcluster-platform::networking]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License").
4+
# You may not use this file except in compliance with the License. A copy of the License is located at
5+
#
6+
# http://aws.amazon.com/apache2.0/
7+
#
8+
# or in the "LICENSE.txt" file accompanying this file.
9+
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
10+
# See the License for the specific language governing permissions and limitations under the License.
11+
12+
# This control is generic enough to be applied to all types of nodes in ParallelCluster
13+
control 'tag:config_log_rotation_all_nodes' do
14+
title 'Check that log rotation has been properly configured'
15+
16+
# This should be enough at least to verify that the logrotate overall configuration is valid.
17+
# WARNING: do not use the `--force` option, because running multiple times the command with the
18+
# `--force` option will cause the command to fail (defeating the purpose of the test)
19+
describe "Log rotation command runs successfully" do
20+
subject { command("sudo logrotate /etc/logrotate.conf") }
21+
its('exit_status') { should eq 0 }
22+
end
23+
24+
end

0 commit comments

Comments
 (0)