Merge "Add Kitchen tests"
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..8fd1b87
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,69 @@
+---
+driver:
+ name: docker
+ hostname: gerrit.ci.local
+ use_sudo: false
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: info
+ formula: gerrit
+ grains:
+ noservices: True
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://gerrit.mcp.mirantis.com/salt-formulas/linux.git
+ state_top:
+ base:
+ "*":
+ - linux.system.repo
+ - gerrit
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - mcp_extra_repo
+ - gerrit
+ pillars-from-files:
+ mcp_extra_repo.sls: tests/pillar/mcp_extra_repo.sls
+
+verifier:
+ name: inspec
+ sudo: true
+
+docker_images:
+ - &xenial-20163 <%=ENV['IMAGE_XENIAL_20163'] || 'docker-dev-local.docker.mirantis.net/epcim/salt/saltstack-ubuntu-xenial-salt-2016.3/salt:2018_11_19'%>
+ - &xenial-20177 <%=ENV['IMAGE_XENIAL_20177'] || 'docker-dev-local.docker.mirantis.net/epcim/salt/saltstack-ubuntu-xenial-salt-2017.7/salt:2018_11_19'%>
+ - &xenial-stable <%=ENV['IMAGE_XENIAL_STABLE'] || 'docker-dev-local.docker.mirantis.net/epcim/salt/saltstack-ubuntu-xenial-salt-stable/salt:2018_11_19'%>
+
+platforms:
+ - name: xenial-2016.3
+ driver_config:
+ image: *xenial-20163
+ platform: ubuntu
+
+ - name: xenial-2017.7
+ driver_config:
+ image: *xenial-20177
+ platform: ubuntu
+
+ - name: xenial-stable
+ driver_config:
+ image: *xenial-stable
+ platform: ubuntu
+
+suites:
+ - name: server
+ provisioner:
+ pillars-from-files:
+ gerrit.sls: tests/pillar/server.sls
+
+ - name: client
+ provisioner:
+ pillars-from-files:
+ gerrit.sls: tests/pillar/client.sls
diff --git a/gerrit/client/project.sls b/gerrit/client/project.sls
index b7c6506..432e3f1 100644
--- a/gerrit/client/project.sls
+++ b/gerrit/client/project.sls
@@ -5,15 +5,19 @@
file.managed:
- source: salt://gerrit/files/projects.ini
- template: jinja
+ {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
- require_in:
- cmd: gerrit_client_enforce_projects
+ {%- endif %}
{%- if client.dir.project_config == "/srv/jeepyb" %}
/srv/jeepyb/projects.yaml:
file.managed:
- source: salt://gerrit/files/projects.yaml
- template: jinja
+ {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
- require_in:
- cmd: gerrit_client_enforce_projects
+ {%- endif %}
{%- for project_name, project in client.project.iteritems() %}
@@ -24,8 +28,10 @@
- makedirs: true
- defaults:
project_name: {{ project.get('name', project_name) }}
+ {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
- require_in:
- cmd: gerrit_client_enforce_projects
+ {%- endif %}
{#
gerrit_client_project_{{ project_name }}:
@@ -42,6 +48,8 @@
{%- set manage_projects_bin = "manage-projects" %}
{%- endif %}
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
+
gerrit_client_enforce_projects:
cmd.run:
- shell: /bin/bash
@@ -62,5 +70,6 @@
- NO_PROXY: "{{ client.proxy.no_proxy }}"
{%- endif %}
+{%- endif %}
{%- endif %}
diff --git a/gerrit/client/service.sls b/gerrit/client/service.sls
index 45d1855..f1395f6 100644
--- a/gerrit/client/service.sls
+++ b/gerrit/client/service.sls
@@ -61,5 +61,6 @@
file.managed:
- mode: 400
- contents_pillar: gerrit:client:server:key
+ - makedirs: true
{%- endif %}
diff --git a/gerrit/files/secure.config b/gerrit/files/secure.config
index afff595..c79f8b9 100644
--- a/gerrit/files/secure.config
+++ b/gerrit/files/secure.config
@@ -8,12 +8,12 @@
[auth]
registerEmailPrivateKey = {{ server.email_private_key }}
restTokenPrivateKey = {{ server.token_private_key }}
- {%- if server.mail.privatekey is defined %}
+ {%- if server.mail is defined and server.mail.privatekey is defined %}
registerEmailPrivateKey = {{ server.mail.privatekey }}
{%- endif %}
[sendemail]
- {%- if server.mail.password is defined %}
+ {%- if server.mail is defined and server.mail.password is defined %}
smtpPass = {{ server.mail.password }}
{%- endif %}
diff --git a/gerrit/server/service.sls b/gerrit/server/service.sls
index 1d614a3..2d4f8ef 100644
--- a/gerrit/server/service.sls
+++ b/gerrit/server/service.sls
@@ -189,11 +189,15 @@
- group: gerrit2
- require:
- file: gerrit_home
+ {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
- require_in:
- cmd: gerrit_server_initial_init
+ {%- endif %}
{%- endif %}
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
+
gerrit_server_initial_init:
cmd.run:
- name: /usr/bin/java -jar {{ server.dir.home }}/gerrit.war init -d {{ server.dir.site }} --batch --no-auto-start{% for plugin_name, plugin in server.get('plugin', {}).iteritems() %}{% if plugin.engine == "gerrit" %} --install-plugin {{ plugin_name }}{% endif %}{% endfor %}
@@ -211,6 +215,8 @@
- require:
- cmd: gerrit_server_initial_init
+{%- endif %}
+
/etc/default/gerritcodereview:
file.managed:
- source: salt://gerrit/files/gerritcodereview
@@ -234,6 +240,8 @@
- name: /etc/init.d/{{ server.service }}
- target: {{ server.dir.site }}/bin/gerrit.sh
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
+
gerrit_server_service:
service.running:
- name: {{ server.service }}
@@ -271,13 +279,18 @@
{%- endfor %}
{%- endif %}
+{%- endif %}
gerrit_server_configured:
file.touch:
- name: {{ server.dir.home }}/.gerrit-configured
- unless: /usr/bin/test -f {{ server.dir.home }}/.gerrit-configured
+ {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
- require:
- service: gerrit_server_service
+ {%- endif %}
+
+{%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
gerrit_server_service_available:
cmd.run:
@@ -297,3 +310,4 @@
- cmd: gerrit_server_service_available
{%- endif %}
+{%- endif %}
diff --git a/tests/pillar/client.sls b/tests/pillar/client.sls
index 69d77c5..444ef78 100644
--- a/tests/pillar/client.sls
+++ b/tests/pillar/client.sls
@@ -35,4 +35,5 @@
host: 0.0.0.0
protocol: "http"
http_port: 80
- ssh_port: 22
\ No newline at end of file
+ ssh_port: 22
+ key: "key"
\ No newline at end of file
diff --git a/tests/pillar/mcp_extra_repo.sls b/tests/pillar/mcp_extra_repo.sls
new file mode 100644
index 0000000..259c552
--- /dev/null
+++ b/tests/pillar/mcp_extra_repo.sls
@@ -0,0 +1,58 @@
+linux:
+ system:
+ enabled: true
+ repo:
+ mcp_extra_repo:
+ source: "deb http://mirror.mirantis.com/nightly/extra/{{ grains.get('oscodename') }} {{ grains.get('oscodename') }} main"
+ architectures: amd64
+ clean_file: true
+ key: |
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
+ Version: GnuPG v1
+
+ mQENBFWt8ogBCACtT/j4WMGuhEI486Vv9zVV0GWGefHE5hBlgJSjSgrExLFqQ2Fo
+ ScaABCfvzUeuXHNoh/c2eLjx3YE6oFrdiw5tam0NFlZMM+PSufciTxQz8vrXHGx7
+ VB5rg2TXKoqOv9cW690FsRAeOtKTtBxZvYVTLEPn2GJW09Xy9CBa+n23XBHTBvKs
+ j3hxkn25Oy70Wgxk/BJqpynXGno+NzuAnIbb+f+X7i6fiXwrvtp5zOYOJeUwS+fU
+ IM/mXbetOd/sHtJqc9NUYpTip4nElEqAYRCsXDTbuMNdzSr8VlSMM8b61mBGelLH
+ XJe+EPP+Logc5KXO8adoGgWhqlbD6n7w+ynHABEBAAG0LmZ1ZWwtaW5mcmEgKEV4
+ YW1wbGUga2V5KSA8ZGV2b3BzQG1pcmFudGlzLmNvbT6JATgEEwECACIFAlWt8ogC
+ GwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJELzlzEYfoisIkuQIAJl0cFJ5
+ BSKMXHhRYf0BeDzhdh3pmcOXs/jSznTIxB4OE5OdwrMgK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git a/tests/pillar/server.sls b/tests/pillar/server.sls
index 07a76f5..49af9dd 100644
--- a/tests/pillar/server.sls
+++ b/tests/pillar/server.sls
@@ -2,8 +2,10 @@
server:
enabled: true
canonical_web_url: http://10.10.10.148:8082/
- email_private_key: ""
- token_private_key: ""
+ bind:
+ address: 127.0.0.1
+ email_private_key: "email_private_key"
+ token_private_key: "token_private_key"
initial_user:
full_name: John Doe
email: 'mail@jdoe.com'
@@ -45,16 +47,6 @@
port: 5432
name: gerrit
user: gerrit
- password: ${_param:postgresql_gerrit_password}
+ password: passw0rd
pool_limit: 250
pool_max_idle: 16
- client:
- enabled: true
- server:
- user: "jdoe"
- password: "passw0rd"
- email: "jdoe@email.com"
- host: 0.0.0.0
- protocol: "http"
- http_port: 80
- ssh_port: 22