summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-08-29 21:13:42 -0700
committerelijah <elijah@riseup.net>2016-09-01 10:13:31 -0700
commit1d56c0a7795ef87e34bd06c93a6525f3068aa536 (patch)
tree129687fe524355f74d1a4264e3a4c313baff50f6 /tests
parente6544ecc5a51ad6502a64bd08df71aa7ff75a3ee (diff)
move platform ci tests to tests/platform-ci
Diffstat (limited to 'tests')
-rw-r--r--tests/README.md9
-rw-r--r--tests/example-provider/README.md2
-rw-r--r--tests/platform-ci/Gemfile15
-rw-r--r--tests/platform-ci/README.md11
-rw-r--r--tests/platform-ci/Rakefile121
-rw-r--r--tests/platform-ci/hiera.yaml (renamed from tests/puppet/hiera.yaml)3
-rw-r--r--tests/platform-ci/provider/.platform-test.conf (renamed from tests/puppet/provider/.platform-test.conf)0
-rw-r--r--tests/platform-ci/provider/Leapfile1
-rw-r--r--tests/platform-ci/provider/common.json (renamed from tests/puppet/provider/common.json)0
-rw-r--r--tests/platform-ci/provider/facts.json (renamed from tests/puppet/provider/facts.json)0
-rw-r--r--tests/platform-ci/provider/files/ca/ca.crt (renamed from tests/puppet/provider/files/ca/ca.crt)0
-rw-r--r--tests/platform-ci/provider/files/ca/ca.key (renamed from tests/puppet/provider/files/ca/ca.key)0
-rw-r--r--tests/platform-ci/provider/files/ca/client_ca.crt (renamed from tests/puppet/provider/files/ca/client_ca.crt)0
-rw-r--r--tests/platform-ci/provider/files/ca/client_ca.key (renamed from tests/puppet/provider/files/ca/client_ca.key)0
-rw-r--r--tests/platform-ci/provider/files/ca/dh.pem (renamed from tests/puppet/provider/files/ca/dh.pem)0
-rw-r--r--tests/platform-ci/provider/files/cert/commercial_ca.crt (renamed from tests/puppet/provider/files/cert/commercial_ca.crt)0
-rw-r--r--tests/platform-ci/provider/files/cert/example.org.crt (renamed from tests/puppet/provider/files/cert/example.org.crt)0
-rw-r--r--tests/platform-ci/provider/files/cert/example.org.csr (renamed from tests/puppet/provider/files/cert/example.org.csr)0
-rw-r--r--tests/platform-ci/provider/files/cert/example.org.key (renamed from tests/puppet/provider/files/cert/example.org.key)0
-rw-r--r--tests/platform-ci/provider/files/mx/dkim.key (renamed from tests/puppet/provider/files/mx/dkim.key)0
-rw-r--r--tests/platform-ci/provider/files/mx/dkim.pub (renamed from tests/puppet/provider/files/mx/dkim.pub)0
-rw-r--r--tests/platform-ci/provider/files/ssh/known_hosts (renamed from tests/puppet/provider/files/ssh/known_hosts)0
-rw-r--r--tests/platform-ci/provider/files/ssh/monitor_ssh (renamed from tests/puppet/provider/files/ssh/monitor_ssh)0
-rw-r--r--tests/platform-ci/provider/files/ssh/monitor_ssh.pub (renamed from tests/puppet/provider/files/ssh/monitor_ssh.pub)0
-rw-r--r--tests/platform-ci/provider/nodes/catalogtest.json (renamed from tests/puppet/provider/nodes/catalogtest.json)0
-rw-r--r--tests/platform-ci/provider/provider.json (renamed from tests/puppet/provider/provider.json)0
-rw-r--r--tests/platform-ci/provider/tags/catalogtest.json (renamed from tests/puppet/provider/tags/catalogtest.json)0
-rw-r--r--tests/platform-ci/provider/users/gitlab-runner/gitlab-runner_ssh.pub (renamed from tests/puppet/provider/users/gitlab-runner/gitlab-runner_ssh.pub)0
-rwxr-xr-xtests/platform-ci/setup.sh4
-rw-r--r--tests/puppet/provider/Leapfile2
30 files changed, 157 insertions, 11 deletions
diff --git a/tests/README.md b/tests/README.md
index a3628495..ea6bcaa9 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -14,13 +14,8 @@ These tests are to confirm that a provider's infrasture is working and to troubl
**example-provider/**
-Files to support the command:
-
- cd leap_platform/tests/example-provider
- vagrant up
-
-For quick booting a pre-configured sample provider, running in a single virtual
-machine.
+Allows you to generate a pre-configured provider using Vagrant virtual
+machines.
**platform-ci/**
diff --git a/tests/example-provider/README.md b/tests/example-provider/README.md
index 62cdc01a..80cb3ae9 100644
--- a/tests/example-provider/README.md
+++ b/tests/example-provider/README.md
@@ -1,5 +1,5 @@
Here lies a script to generate a pre-configured provider using Vagrant virtual
-machines.
+machines. This virtual provider includes only a single node.
All you have to do is this:
diff --git a/tests/platform-ci/Gemfile b/tests/platform-ci/Gemfile
new file mode 100644
index 00000000..aea88237
--- /dev/null
+++ b/tests/platform-ci/Gemfile
@@ -0,0 +1,15 @@
+source "https://rubygems.org"
+
+group :test do
+ gem "rake"
+ gem "rspec", '< 3.2.0'
+ gem "puppet", ENV['PUPPET_VERSION'] || ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION'] || '~> 3.8'
+ gem "facter", ENV['FACTER_VERSION'] || ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION'] || '~> 2.2.0'
+ gem "rspec-puppet"
+ gem "puppetlabs_spec_helper"
+ gem "metadata-json-lint"
+ gem "rspec-puppet-facts"
+ gem "mocha"
+ gem "puppet-catalog-test"
+ gem "leap_cli", :git => 'https://leap.se/git/leap_cli.git', :branch => 'develop'
+end
diff --git a/tests/platform-ci/README.md b/tests/platform-ci/README.md
new file mode 100644
index 00000000..bc48b21f
--- /dev/null
+++ b/tests/platform-ci/README.md
@@ -0,0 +1,11 @@
+Continuous integration tests for the leap_platform code.
+
+Usage:
+
+ ./setup.sh
+ bin/rake test:syntax
+ bin/rake test:catalog
+
+For a list of all tasks:
+
+ bin/rake -T
diff --git a/tests/platform-ci/Rakefile b/tests/platform-ci/Rakefile
new file mode 100644
index 00000000..5443be36
--- /dev/null
+++ b/tests/platform-ci/Rakefile
@@ -0,0 +1,121 @@
+require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
+require 'puppet-syntax/tasks/puppet-syntax'
+require 'puppet-catalog-test'
+
+CI_DIR = File.dirname(__FILE__)
+PLATFORM_DIR = File.expand_path('../..', CI_DIR)
+PROVIDER_DIR = File.join(CI_DIR, 'provider')
+
+#
+# return list of modules, either "external" (submodules or subrepos), "custom"
+# (no submodules nor subrepos) or all modules so we can check each array
+# seperately
+#
+def modules_pattern (type)
+ external = Array.new
+ internal = Array.new
+ all = Array.new
+
+ Dir.chdir(PLATFORM_DIR) do
+ Dir['puppet/modules/*'].sort.each do |m|
+
+ # submodule or subrepo ?
+ system("grep -q #{m} .gitmodules 2>/dev/null || test -f #{m}/.gitrepo")
+ if $?.exitstatus == 0
+ external << m + '/**/*.pp'
+ else
+ internal << m + '/**/*.pp'
+ end
+ all << m + '/**/*.pp'
+ end
+
+ case type
+ when 'external'
+ external
+ when 'internal'
+ internal
+ when 'all'
+ all
+ end
+ end
+end
+
+exclude_paths = ["**/vendor/**/*", "spec/fixtures/**/*", "pkg/**/*" ]
+
+#
+# redefine lint task so we don't lint submoudules for now
+#
+Rake::Task[:lint].clear
+PuppetLint::RakeTask.new :lint do |config|
+ # only check for custom manifests, not submodules for now
+ config.pattern = modules_pattern('internal')
+ config.ignore_paths = exclude_paths
+ config.disable_checks = ['documentation', '140chars', 'arrow_alignment']
+ config.fail_on_warnings = false
+end
+
+# rake syntax::* tasks
+PuppetSyntax.exclude_paths = exclude_paths
+PuppetSyntax.future_parser = true
+
+desc "Validate erb templates"
+task :templates do
+ Dir.chdir(PLATFORM_DIR) do
+ Dir['**/templates/**/*.erb'].each do |template|
+ sh "erb -P -x -T '-' #{template} | ruby -c" unless template =~ /.*vendor.*/
+ end
+ end
+end
+
+namespace :platform do
+ desc "Compile hiera config for test_provider"
+ task :provider_compile do
+ Dir.chdir(PROVIDER_DIR) do
+ sh "bundle exec leap compile"
+ end
+ end
+end
+
+PuppetCatalogTest::RakeTask.new('catalog') do |t|
+ Rake::Task["platform:provider_compile"].invoke
+ t.module_paths = [File.join(PLATFORM_DIR, "puppet", "modules")]
+ t.manifest_path = File.join(PLATFORM_DIR, "puppet","manifests", "site.pp")
+ t.facts = {
+ "operatingsystem" => "Debian",
+ "osfamily" => "Debian",
+ "operatingsystemmajrelease" => "8",
+ "debian_release" => "stable",
+ "debian_codename" => "jessie",
+ "lsbdistcodename" => "jessie",
+ "concat_basedir" => "/var/lib/puppet/concat",
+ "interfaces" => "eth0"
+ }
+
+ # crucial option for hiera integration
+ t.config_dir = CI_DIR # expects hiera.yaml to be included in directory
+
+ # t.parser = "future"
+ #t.verbose = true
+end
+
+
+namespace :test do
+ # :syntax:templates fails on squirrel, see https://jenkins.leap.se/view/Platform%20Builds/job/platform_citest/115/console
+ # but we have our own synax test
+ desc "Run all puppet syntax checks required for CI (syntax , validate, templates, spec, lint)"
+ task :syntax => [:"syntax:hiera", :"syntax:manifests", :validate, :templates, :spec, :lint]
+
+ desc "Tries to compile the catalog"
+ task :catalog => [:catalog]
+
+ #task :all => [:syntax, :catalog]
+end
+
+# unfortunatly, we cannot have one taks to rule them all
+# because :catalog would conflict with :syntax or :validate:
+# rake aborted!
+# Puppet::DevError: Attempting to initialize global default settings more than once!
+# /home/varac/dev/projects/leap/git/leap_platform/vendor/bundle/ruby/2.3.0/gems/puppet-3.8.7/lib/puppet/settings.rb:261:in `initialize_global_settings'
+#desc "Run all platform tests"
+#task :test => 'test:all'
diff --git a/tests/puppet/hiera.yaml b/tests/platform-ci/hiera.yaml
index d4d0f670..a23d8b92 100644
--- a/tests/puppet/hiera.yaml
+++ b/tests/platform-ci/hiera.yaml
@@ -6,10 +6,11 @@
:logger: console
:yaml:
- :datadir: tests/puppet/provider/hiera
+ :datadir: provider/hiera
:hierarchy:
- catalogtest
:puppet:
:datasource: data
+
diff --git a/tests/puppet/provider/.platform-test.conf b/tests/platform-ci/provider/.platform-test.conf
index 621fb7b7..621fb7b7 100644
--- a/tests/puppet/provider/.platform-test.conf
+++ b/tests/platform-ci/provider/.platform-test.conf
diff --git a/tests/platform-ci/provider/Leapfile b/tests/platform-ci/provider/Leapfile
new file mode 100644
index 00000000..f54c9293
--- /dev/null
+++ b/tests/platform-ci/provider/Leapfile
@@ -0,0 +1 @@
+@platform_directory_path = "../../.."
diff --git a/tests/puppet/provider/common.json b/tests/platform-ci/provider/common.json
index a13f8f75..a13f8f75 100644
--- a/tests/puppet/provider/common.json
+++ b/tests/platform-ci/provider/common.json
diff --git a/tests/puppet/provider/facts.json b/tests/platform-ci/provider/facts.json
index 0967ef42..0967ef42 100644
--- a/tests/puppet/provider/facts.json
+++ b/tests/platform-ci/provider/facts.json
diff --git a/tests/puppet/provider/files/ca/ca.crt b/tests/platform-ci/provider/files/ca/ca.crt
index 01df56a7..01df56a7 100644
--- a/tests/puppet/provider/files/ca/ca.crt
+++ b/tests/platform-ci/provider/files/ca/ca.crt
diff --git a/tests/puppet/provider/files/ca/ca.key b/tests/platform-ci/provider/files/ca/ca.key
index c022b19a..c022b19a 100644
--- a/tests/puppet/provider/files/ca/ca.key
+++ b/tests/platform-ci/provider/files/ca/ca.key
diff --git a/tests/puppet/provider/files/ca/client_ca.crt b/tests/platform-ci/provider/files/ca/client_ca.crt
index c1214476..c1214476 100644
--- a/tests/puppet/provider/files/ca/client_ca.crt
+++ b/tests/platform-ci/provider/files/ca/client_ca.crt
diff --git a/tests/puppet/provider/files/ca/client_ca.key b/tests/platform-ci/provider/files/ca/client_ca.key
index 160cad43..160cad43 100644
--- a/tests/puppet/provider/files/ca/client_ca.key
+++ b/tests/platform-ci/provider/files/ca/client_ca.key
diff --git a/tests/puppet/provider/files/ca/dh.pem b/tests/platform-ci/provider/files/ca/dh.pem
index 3c86bf39..3c86bf39 100644
--- a/tests/puppet/provider/files/ca/dh.pem
+++ b/tests/platform-ci/provider/files/ca/dh.pem
diff --git a/tests/puppet/provider/files/cert/commercial_ca.crt b/tests/platform-ci/provider/files/cert/commercial_ca.crt
index 01df56a7..01df56a7 100644
--- a/tests/puppet/provider/files/cert/commercial_ca.crt
+++ b/tests/platform-ci/provider/files/cert/commercial_ca.crt
diff --git a/tests/puppet/provider/files/cert/example.org.crt b/tests/platform-ci/provider/files/cert/example.org.crt
index 7de2982d..7de2982d 100644
--- a/tests/puppet/provider/files/cert/example.org.crt
+++ b/tests/platform-ci/provider/files/cert/example.org.crt
diff --git a/tests/puppet/provider/files/cert/example.org.csr b/tests/platform-ci/provider/files/cert/example.org.csr
index 95e8b65d..95e8b65d 100644
--- a/tests/puppet/provider/files/cert/example.org.csr
+++ b/tests/platform-ci/provider/files/cert/example.org.csr
diff --git a/tests/puppet/provider/files/cert/example.org.key b/tests/platform-ci/provider/files/cert/example.org.key
index 7ca1c512..7ca1c512 100644
--- a/tests/puppet/provider/files/cert/example.org.key
+++ b/tests/platform-ci/provider/files/cert/example.org.key
diff --git a/tests/puppet/provider/files/mx/dkim.key b/tests/platform-ci/provider/files/mx/dkim.key
index 0dc069c6..0dc069c6 100644
--- a/tests/puppet/provider/files/mx/dkim.key
+++ b/tests/platform-ci/provider/files/mx/dkim.key
diff --git a/tests/puppet/provider/files/mx/dkim.pub b/tests/platform-ci/provider/files/mx/dkim.pub
index bbd32086..bbd32086 100644
--- a/tests/puppet/provider/files/mx/dkim.pub
+++ b/tests/platform-ci/provider/files/mx/dkim.pub
diff --git a/tests/puppet/provider/files/ssh/known_hosts b/tests/platform-ci/provider/files/ssh/known_hosts
index 50bc01fd..50bc01fd 100644
--- a/tests/puppet/provider/files/ssh/known_hosts
+++ b/tests/platform-ci/provider/files/ssh/known_hosts
diff --git a/tests/puppet/provider/files/ssh/monitor_ssh b/tests/platform-ci/provider/files/ssh/monitor_ssh
index 81ff75e4..81ff75e4 100644
--- a/tests/puppet/provider/files/ssh/monitor_ssh
+++ b/tests/platform-ci/provider/files/ssh/monitor_ssh
diff --git a/tests/puppet/provider/files/ssh/monitor_ssh.pub b/tests/platform-ci/provider/files/ssh/monitor_ssh.pub
index 8be32927..8be32927 100644
--- a/tests/puppet/provider/files/ssh/monitor_ssh.pub
+++ b/tests/platform-ci/provider/files/ssh/monitor_ssh.pub
diff --git a/tests/puppet/provider/nodes/catalogtest.json b/tests/platform-ci/provider/nodes/catalogtest.json
index 05703666..05703666 100644
--- a/tests/puppet/provider/nodes/catalogtest.json
+++ b/tests/platform-ci/provider/nodes/catalogtest.json
diff --git a/tests/puppet/provider/provider.json b/tests/platform-ci/provider/provider.json
index 218ff529..218ff529 100644
--- a/tests/puppet/provider/provider.json
+++ b/tests/platform-ci/provider/provider.json
diff --git a/tests/puppet/provider/tags/catalogtest.json b/tests/platform-ci/provider/tags/catalogtest.json
index 0967ef42..0967ef42 100644
--- a/tests/puppet/provider/tags/catalogtest.json
+++ b/tests/platform-ci/provider/tags/catalogtest.json
diff --git a/tests/puppet/provider/users/gitlab-runner/gitlab-runner_ssh.pub b/tests/platform-ci/provider/users/gitlab-runner/gitlab-runner_ssh.pub
index 1a3c370d..1a3c370d 100644
--- a/tests/puppet/provider/users/gitlab-runner/gitlab-runner_ssh.pub
+++ b/tests/platform-ci/provider/users/gitlab-runner/gitlab-runner_ssh.pub
diff --git a/tests/platform-ci/setup.sh b/tests/platform-ci/setup.sh
new file mode 100755
index 00000000..69a348b8
--- /dev/null
+++ b/tests/platform-ci/setup.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+which bundle || apt install bundle
+bundle install --binstubs --path=vendor --with=test \ No newline at end of file
diff --git a/tests/puppet/provider/Leapfile b/tests/puppet/provider/Leapfile
deleted file mode 100644
index c4c25b4d..00000000
--- a/tests/puppet/provider/Leapfile
+++ /dev/null
@@ -1,2 +0,0 @@
-@platform_directory_path = "../../.."
-# see https://leap.se/en/docs/platform/config for more options \ No newline at end of file