ITOPSENG-101 initial molecule tests commit

This commit is contained in:
Brett Meehan
2019-11-08 15:13:34 +11:00
parent 48904ca084
commit 9d7626a14a
6 changed files with 126 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ atl_download_format_suffix_map:
atl_download_suffix: "{{ atl_download_format_suffix_map[atl_download_format] }}" atl_download_suffix: "{{ atl_download_format_suffix_map[atl_download_format] }}"
atl_release_base_url: "https://product-downloads.atlassian.com/software" atl_release_base_url: "https://product-downloads.atlassian.com/software"
atl_product_base_url: "{{ atl_release_base_url }}/{{ atl_product_family }}/downloads" atl_product_base_url: "{{ atl_release_base_url }}/{{ atl_product_family }}/downloads/binary"
atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}{{ atl_download_suffix }}" atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_download_edition | default(atl_product_edition) }}-{{ atl_product_version }}{{ atl_download_suffix }}"
atl_product_download_filename: "{{ atl_download_edition | default(atl_product_edition) }}.{{ atl_product_version }}{{ atl_download_suffix }}" atl_product_download_filename: "{{ atl_download_edition | default(atl_product_edition) }}.{{ atl_product_version }}{{ atl_download_suffix }}"

View File

@@ -0,0 +1,14 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

View File

@@ -0,0 +1,32 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: amazon_linux2
image: amazonlinux:2
groups:
- aws_node_local
- name: ubuntu_lts
image: ubuntu:bionic
groups:
- aws_node_local
provisioner:
name: ansible
options:
skip-tags: runtime_pkg
lint:
name: ansible-lint
inventory:
links:
group_vars: ../../../../group_vars/
verifier:
name: testinfra
additional_files_or_dirs:
- ../../resources/tests/test_*.py
lint:
name: flake8
enabled: false

View File

@@ -0,0 +1,28 @@
---
- name: Converge
hosts: all
vars:
atl_product_family: "jira"
atl_product_edition: "jira-{{ lookup('env', 'ATL_PRODUCT_EDITION') | lower }}"
atl_product_user: "jira"
atl_product_version: "7.13.1"
atl_install_jsd_as_obr: true
atl_systemd_service_name: "jira.service"
atl_jdbc_encoding: 'UNICODE'
atl_jdbc_collation: 'C'
atl_jdbc_ctype: 'C'
atl_jdbc_template: 'template0'
pre_tasks:
- name: Create cache dir
file:
path: '/media/atl/jira/shared/'
state: directory
- name: Seed version
copy:
dest: '/media/atl/jira/shared/jira-core.version'
content: "7.13.1"
force: false # For idempotency check
roles:
- role: linux_common
- role: product_common
- role: product_install

View File

@@ -0,0 +1,49 @@
import os
from six.moves import urllib
import testinfra.utils.ansible_runner
import json
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_version_is_correct(host):
verfile = host.file('/media/atl/jira/shared/jira-core.version')
assert verfile.exists
assert verfile.content.decode("UTF-8").strip() == "7.13.1"
def test_is_downloaded(host):
installer = host.file('/media/atl/downloads/jira-core.7.13.1-x64.bin')
assert installer.exists
assert installer.user == 'root'
def test_completed_lockfile(host):
lockfile = host.file('/media/atl/downloads/jira-core.7.13.1-x64.bin_completed')
assert lockfile.exists
assert lockfile.user == 'root'
def test_is_unpacked(host):
installer = host.file('/opt/atlassian/jira-core/7.13.1/atlassian-jira/')
assert installer.exists
assert installer.is_directory
assert installer.user == 'jira'
assert installer.mode == 0o0755
def test_obr_is_downloaded(host):
installer = host.file('/media/atl/downloads/jira-servicedesk-application-3.16.1.obr')
assert installer.exists
assert installer.user == 'root'
def test_obr_completed_lockfile(host):
lockfile = host.file('/media/atl/downloads/jira-servicedesk-application-3.16.1.obr_completed')
assert lockfile.exists
assert lockfile.user == 'root'
def test_obr_is_unpacked(host):
jsdjar = host.file('/media/atl/jira/shared/plugins/installed-plugins/jira-servicedesk-application-3.16.1.jar')
assert jsdjar.exists
assert jsdjar.user == 'jira'
assert jsdjar.mode == 0o0750

View File

@@ -23,7 +23,7 @@ def test_latest_is_downloaded(host):
upstream_json = json.load(upstream_fd) upstream_json = json.load(upstream_fd)
upstream = upstream_json['version'] upstream = upstream_json['version']
installer = host.file('/media/atl/jira/shared/downloads/jira-core.'+upstream+'-x64.bin') installer = host.file('/media/atl/downloads/jira-core.'+upstream+'-x64.bin')
assert installer.exists assert installer.exists
assert installer.user == 'root' assert installer.user == 'root'
@@ -32,6 +32,6 @@ def test_completed_lockfile(host):
upstream_json = json.load(upstream_fd) upstream_json = json.load(upstream_fd)
upstream = upstream_json['version'] upstream = upstream_json['version']
lockfile = host.file('/media/atl/jira/shared/downloads/jira-core.'+upstream+'-x64.bin_completed') lockfile = host.file('/media/atl/downloads/jira-core.'+upstream+'-x64.bin_completed')
assert lockfile.exists assert lockfile.exists
assert lockfile.user == 'root' assert lockfile.user == 'root'