-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(map): verify
map.jinja
dump using _mapdata
state
- Loading branch information
sammy.smati
committed
Apr 24, 2022
1 parent
e0967fd
commit 0d49595
Showing
21 changed files
with
627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'yaml' | ||
|
||
control 'TEMPLATE._mapdata' do | ||
title '`map.jinja` should match the reference file' | ||
|
||
### Method | ||
# The steps below for each file appear convoluted but they are both required | ||
# and similar in nature: | ||
# 1. The earliest method was to simply compare the files textually but this often | ||
# led to false positives due to inconsistencies (e.g. spacing, ordering) | ||
# 2. The next method was to load the files back into YAML structures and then | ||
# compare but InSpec provided block diffs this way, unusable by end users | ||
# 3. The final step was to dump the YAML structures back into a string to use | ||
# for the comparison; this both worked and provided human-friendly diffs | ||
|
||
### Comparison file for the specific platform | ||
### Static, adjusted as part of code contributions, as map data is changed | ||
# Strip the `platform[:finger]` version number down to the "OS major release" | ||
platform_finger = system.platform[:finger].split('.').first.to_s | ||
# Use that to set the path to the file (relative to the InSpec suite directory) | ||
mapdata_file_path = "_mapdata/#{platform_finger}.yaml" | ||
# Load the mapdata from profile, into a YAML structure | ||
# https://docs.chef.io/inspec/profiles/#profile-files | ||
mapdata_file_yaml = YAML.load(inspec.profile.file(mapdata_file_path)) | ||
# Dump the YAML back into a string for comparison | ||
mapdata_file_dump = YAML.dump(mapdata_file_yaml) | ||
|
||
### Output file produced by running the `_mapdata` state | ||
### Dynamic, generated during Kitchen's `converge` phase | ||
# Derive the location of the dumped mapdata (differs for Windows) | ||
output_dir = platform[:family] == 'windows' ? '/temp' : '/tmp' | ||
# Use that to set the path to the file (absolute path, i.e. within the container) | ||
output_file_path = "#{output_dir}/salt_mapdata_dump.yaml" | ||
# Load the output into a YAML structure using InSpec's `yaml` resource | ||
# https://github.com/inspec/inspec/blob/49b7d10/lib/inspec/resources/yaml.rb#L29 | ||
output_file_yaml = yaml(output_file_path).params | ||
# Dump the YAML back into a string for comparison | ||
output_file_dump = YAML.dump(output_file_yaml) | ||
|
||
describe 'File content' do | ||
it 'should match profile map data exactly' do | ||
expect(output_file_dump).to eq(mapdata_file_dump) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# AlmaLinux-8 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
29 changes: 29 additions & 0 deletions
29
test/integration/default/files/_mapdata/amazonlinux-2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Arch | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
29 changes: 29 additions & 0 deletions
29
test/integration/default/files/_mapdata/arch-base-latest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Arch | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Arch | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# CentOS Stream-8 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Debian-10 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Debian-11 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Debian-9 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Fedora-34 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Fedora Linux-35 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# Fedora Linux-36 | ||
--- | ||
values: | ||
arch: amd64 | ||
config: | ||
bind_addr: 0.0.0.0 | ||
bootstrap_expect: 3 | ||
data_dir: /var/consul | ||
datacenter: eu | ||
enable_debug: true | ||
encrypt: RIxqpNlOXqtr/j4BgvIMEw== | ||
log_level: info | ||
retry_interval: 15s | ||
retry_join: | ||
- 1.1.1.1 | ||
- 2.2.2.2 | ||
server: true | ||
ui_config: | ||
enabled: true | ||
download_host: releases.hashicorp.com | ||
group: consul | ||
group_gid: '' | ||
register: [] | ||
scripts: [] | ||
service: true | ||
user: consul | ||
user_uid: '' | ||
version: 1.9.0 |
Oops, something went wrong.