]> git.openstreetmap.org Git - chef.git/commitdiff
Add tests for planet cookbook
authorTom Hughes <tom@compton.nu>
Sat, 15 Feb 2020 14:52:12 +0000 (14:52 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 15 Feb 2020 17:32:12 +0000 (17:32 +0000)
14 files changed:
.kitchen.yml
.travis.yml
cookbooks/bind/recipes/default.rb
cookbooks/planet/attributes/default.rb
cookbooks/planet/metadata.rb
cookbooks/planet/recipes/default.rb
cookbooks/planet/recipes/dump.rb
cookbooks/planet/recipes/replication.rb
roles/planet.rb
test/data_bags/accounts/planet.json [new file with mode: 0644]
test/data_bags/db/passwords.json [new file with mode: 0644]
test/integration/planet-dump/serverspec/planetdump_spec.rb [new file with mode: 0644]
test/integration/planet-notes/serverspec/planetdump_spec.rb [new file with mode: 0644]
test/integration/planet/serverspec/apache_spec.rb [new file with mode: 0644]

index 792b4198b25e40eadec63db240f8bf58493fca7d..63e3503e2125577d920518e04158aa7a709c6691 100644 (file)
@@ -142,6 +142,24 @@ suites:
       - recipe[accounts::default]
       - recipe[chef::default]
       - role[otrs]
+  - name: planet
+    run_list:
+      - recipe[planet::default]
+  - name: planet-dump
+    run_list:
+      - recipe[planet::dump]
+  - name: planet-notes
+    run_list:
+      - recipe[planet::notes]
+    attributes:
+      web:
+        readonly_database_host: readonly
+  - name: planet-replication
+    run_list:
+      - recipe[planet::replication]
+    attributes:
+      web:
+        readonly_database_host: readonly
   - name: python
     run_list:
       - recipe[python::default]
index 26f95c00e9417395f16b190fef2c726b2821b4a6..9387d3348a7ca6d91bb47958abe2fd064b1f05e2 100644 (file)
@@ -86,6 +86,18 @@ jobs:
     - name: "Test Kitchen (otrs)"
       script:
         - bundle exec kitchen test otrs-ubuntu-1804
+    - name: "Test Kitchen (planet)"
+      script:
+        - bundle exec kitchen test planet-ubuntu-1804
+    - name: "Test Kitchen (planet::dump)"
+      script:
+        - bundle exec kitchen test planet-dump-ubuntu-1804
+    - name: "Test Kitchen (planet::notes)"
+      script:
+        - bundle exec kitchen test planet-notes-ubuntu-1804
+    - name: "Test Kitchen (planet::replication)"
+      script:
+        - bundle exec kitchen test planet-replication-ubuntu-1804
     - name: "Test Kitchen (python)"
       script:
         - bundle exec kitchen test python-ubuntu-1804
index 087ef5802f4db2ff5eaac454f40f41675adcde8d..aaba997815cf10e205e28d3e28e4590f1ccfe45f 100644 (file)
 
 include_recipe "networking"
 
-clients = search(:node, "roles:#{node[:bind][:clients]}")
-
-ipv4_clients = clients.collect do |client|
-  client.ipaddresses(:family => :inet)
-end.flatten
-
-ipv6_clients = clients.collect do |client|
-  client.ipaddresses(:family => :inet6)
-end.flatten
+ipv4_clients = []
+ipv6_clients = []
 
 package "bind9"
 
index e888b56771753b07ffe0181df39dde1c45cd06a4..f01d8acc4b11744b68c2d19e7ffef3d98fda4b5c 100644 (file)
@@ -1,3 +1,5 @@
+default[:accounts][:users][:planet][:status] = :role
+
 default[:planet][:dump][:xml_directory] = "/store/planet/planet"
 default[:planet][:dump][:xml_history_directory] = "/store/planet/planet/full-history"
 default[:planet][:dump][:pbf_directory] = "/store/planet/pbf"
index 97cd99ffb8044a2c3b1f77af8a2fb262a33c0344..425fe95f537a100d5eef2e5c6874c5ad61e89058 100644 (file)
@@ -6,8 +6,9 @@ description       "Installs and configures a planet server"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "accounts"
 depends           "apache"
 depends           "git"
-depends           "osmosis"
 depends           "incron"
 depends           "munin"
+depends           "osmosis"
index ba5bf0023011b29c8f114f69143079fb52828f44..d8ec3bd3c1110f2c5ac7723ef9f99d02873aea29 100644 (file)
@@ -17,6 +17,7 @@
 # limitations under the License.
 #
 
+include_recipe "accounts"
 include_recipe "apache"
 
 package %w[
index a5e9a5fff009256c639cb680ae719ce1a7ab54a9..aea66204d88e055a7bd038ef7697fcbf7952cbf1 100644 (file)
@@ -92,6 +92,7 @@ directory "/store/planetdump" do
   owner "www-data"
   group "www-data"
   mode 0o755
+  recursive true
 end
 
 %w[planetdump planet-mirror-redirect-update].each do |program|
index 548ae871bdf920d20b8c99d9db5814951b529090..b23c00f36bacacdc65ef03b4ec303e247ee56afc 100644 (file)
@@ -17,6 +17,7 @@
 # limitations under the License.
 #
 
+include_recipe "accounts"
 include_recipe "osmosis"
 
 db_passwords = data_bag_item("db", "passwords")
@@ -27,11 +28,11 @@ package "ruby"
 package "ruby-dev"
 package "ruby-libxml"
 
-package "libpq-dev"
-gem_package "pg"
-
 package "make"
 package "gcc"
+package "libpq-dev"
+
+gem_package "pg"
 
 remote_directory "/opt/flush" do
   source "flush"
index 6c765845bb7f4893bfba6f900383638c76e2cfbf..9055e1efd287ee3bc3778d3e8f7e489e6b72d536 100644 (file)
@@ -2,15 +2,6 @@ name "planet"
 description "Role applied to all planet servers"
 
 default_attributes(
-  :accounts => {
-    :users => {
-      :bretth => { :status => :user },
-      :planet => {
-        :status => :administrator,
-        :members => [:bretth]
-      }
-    }
-  },
   :rsyncd => {
     :modules => {
       :planet => {
diff --git a/test/data_bags/accounts/planet.json b/test/data_bags/accounts/planet.json
new file mode 100644 (file)
index 0000000..b69305f
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "id": "planet",
+  "uid": "502",
+  "comment": "planet.openstreetmap.org"
+}
diff --git a/test/data_bags/db/passwords.json b/test/data_bags/db/passwords.json
new file mode 100644 (file)
index 0000000..f509c5f
--- /dev/null
@@ -0,0 +1,12 @@
+{
+  "id": "passwords",
+  "openstreetmap": "openstreetmap-password",
+  "rails": "rails-password",
+  "cgimap": "cgimap-password",
+  "planetdump": "planetdump-password",
+  "planetdiff": "planetdiff-password",
+  "backup": "backup-password",
+  "gpximport": "gpximport-password",
+  "munin": "munin-password",
+  "replication": "replication-password"
+}
diff --git a/test/integration/planet-dump/serverspec/planetdump_spec.rb b/test/integration/planet-dump/serverspec/planetdump_spec.rb
new file mode 100644 (file)
index 0000000..ed082b9
--- /dev/null
@@ -0,0 +1,23 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe file("/opt/planet-dump-ng/planet-dump-ng") do
+  it { should be_file }
+  it { should be_executable }
+end
+
+describe file("/usr/local/bin/planetdump") do
+  it { should be_file }
+  it { should be_executable }
+end
+
+describe file("/usr/local/bin/planet-mirror-redirect-update") do
+  it { should be_file }
+  it { should be_executable }
+end
+
+describe file("/etc/cron.d/planet-dump-mirror") do
+  it { should be_file }
+end
diff --git a/test/integration/planet-notes/serverspec/planetdump_spec.rb b/test/integration/planet-notes/serverspec/planetdump_spec.rb
new file mode 100644 (file)
index 0000000..6d35a49
--- /dev/null
@@ -0,0 +1,13 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe file("/usr/local/bin/planet-notes-dump") do
+  it { should be_file }
+  it { should be_executable }
+end
+
+describe file("/etc/cron.d/planet-notes-dump") do
+  it { should be_file }
+end
diff --git a/test/integration/planet/serverspec/apache_spec.rb b/test/integration/planet/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+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.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end