From e65977d4b5c2cca80c8a46563790b958d78fbfbe Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 4 Sep 2024 10:03:54 +0100 Subject: [PATCH 1/1] Add test for dev cookbook --- .github/workflows/test-kitchen.yml | 5 +++++ .kitchen.yml | 7 +++++++ test/integration/dev/inspec/apache_spec.rb | 18 ++++++++++++++++++ test/integration/dev/inspec/mysql_spec.rb | 19 +++++++++++++++++++ .../integration/dev/inspec/postgresql_spec.rb | 13 +++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 test/integration/dev/inspec/apache_spec.rb create mode 100644 test/integration/dev/inspec/mysql_spec.rb create mode 100644 test/integration/dev/inspec/postgresql_spec.rb diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index 3152db471..7e738b38b 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -34,6 +34,7 @@ jobs: - db-base - db-master - db-slave + - dev - devices - dhcpd - dmca @@ -124,6 +125,8 @@ jobs: suite: osqa - os: debian-12 suite: apt-repository + - os: debian-12 + suite: dev - os: debian-12 suite: dns - os: debian-12 @@ -149,6 +152,8 @@ jobs: exclude: - suite: apt-repository os: ubuntu-2204 + - suite: dev + os: ubuntu-2204 - suite: dns os: ubuntu-2204 - suite: git-server diff --git a/.kitchen.yml b/.kitchen.yml index db9664940..805d15b74 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -116,6 +116,13 @@ suites: - name: db-slave run_list: - recipe[db::slave] + - name: dev + run_list: + - recipe[dev::default] + attributes: + postgresql: + versions: + - 15 - name: devices run_list: - recipe[devices::default] diff --git a/test/integration/dev/inspec/apache_spec.rb b/test/integration/dev/inspec/apache_spec.rb new file mode 100644 index 000000000..8006330b4 --- /dev/null +++ b/test/integration/dev/inspec/apache_spec.rb @@ -0,0 +1,18 @@ +describe package("apache2") do + it { should be_installed } +end + +describe service("apache2") do + it { should be_enabled } + it { should be_running } +end + +describe port(80) do + it { should be_listening } + its("protocols") { should cmp "tcp" } +end + +describe port(443) do + it { should be_listening } + its("protocols") { should cmp "tcp" } +end diff --git a/test/integration/dev/inspec/mysql_spec.rb b/test/integration/dev/inspec/mysql_spec.rb new file mode 100644 index 000000000..549f33da9 --- /dev/null +++ b/test/integration/dev/inspec/mysql_spec.rb @@ -0,0 +1,19 @@ +mysql_variant = if os.name == "ubuntu" + "mysql" + else + "mariadb" + end + +describe package("#{mysql_variant}-server") do + it { should be_installed } +end + +describe service("#{mysql_variant}") do + it { should be_enabled } + it { should be_running } +end + +describe port(3306) do + it { should be_listening } + its("protocols") { should cmp "tcp" } +end diff --git a/test/integration/dev/inspec/postgresql_spec.rb b/test/integration/dev/inspec/postgresql_spec.rb new file mode 100644 index 000000000..4c5872e63 --- /dev/null +++ b/test/integration/dev/inspec/postgresql_spec.rb @@ -0,0 +1,13 @@ +describe package("postgresql-15") do + it { should be_installed } +end + +describe service("postgresql@15-main") do + it { should be_enabled } + it { should be_running } +end + +describe port(5432) do + it { should be_listening } + its("protocols") { should cmp %w[tcp tcp6] } +end -- 2.39.5