Skip to content

Commit

Permalink
test: add real tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srsp committed Feb 22, 2019
1 parent 6c243c9 commit 605ec53
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 5 deletions.
14 changes: 9 additions & 5 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_hosts_file(host):
f = host.file('/etc/hosts')
def test_java(host):

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
assert host.exists("java")
assert host.exists("javac")
assert host.exists("jar")

if (host.system_info.distribution != "opensuse-leap"):
assert host.exists("keytool")

assert host.run_test("java -version")
14 changes: 14 additions & 0 deletions molecule/ubuntu1804/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -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 python2-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
27 changes: 27 additions & 0 deletions molecule/ubuntu1804/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ubuntu1804
image: ubuntu:18.04
volumes:
- /tmp/java:/tmp/java
groups:
- ubuntu
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: ubuntu1804
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8
14 changes: 14 additions & 0 deletions molecule/ubuntu1810/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -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 python2-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
27 changes: 27 additions & 0 deletions molecule/ubuntu1810/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: ubuntu1810
image: ubuntu:18.10
volumes:
- /tmp/java:/tmp/java
groups:
- ubuntu
provisioner:
name: ansible
playbooks:
converge: ../default/playbook.yml
lint:
name: ansible-lint
scenario:
name: ubuntu1810
verifier:
name: testinfra
directory: ../default/tests/
lint:
name: flake8

0 comments on commit 605ec53

Please sign in to comment.