This repository has been archived by the owner on Aug 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from newrelic/functional_tests
Adding some more functional tests
- Loading branch information
Showing
17 changed files
with
336 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Molecule managed | ||
|
||
{% if item.registry is defined %} | ||
FROM {{ item.registry.url }}/{{ item.image }} | ||
{% else %} | ||
FROM {{ item.image }} | ||
{% endif %} | ||
|
||
{% if item.env is defined %} | ||
{% for var, value in item.env.items() %} | ||
{% if value %} | ||
ENV {{ var }} {{ value }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 openjdk-8-jre tomcat8 unzip sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean; \ | ||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \ | ||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ | ||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python3 sudo bash iproute2 && zypper clean -a; \ | ||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python3 sudo bash ca-certificates; \ | ||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python3 sudo bash ca-certificates iproute2 && xbps-remove -O; fi | ||
|
||
# Create pre-existing yml file to test backup | ||
RUN mkdir /var/lib/tomcat8/newrelic | ||
RUN echo "Old App Name" >> /var/lib/tomcat8/newrelic/newrelic.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
******* | ||
Docker driver installation guide | ||
******* | ||
|
||
Requirements | ||
============ | ||
|
||
* Docker Engine | ||
|
||
Install | ||
======= | ||
|
||
Please refer to the `Virtual environment`_ documentation for installation best | ||
practices. If not using a virtual environment, please consider passing the | ||
widely recommended `'--user' flag`_ when invoking ``pip``. | ||
|
||
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ | ||
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site | ||
|
||
.. code-block:: bash | ||
$ python3 -m pip install 'molecule[docker]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
tasks: | ||
- name: "Run agent install role" | ||
include_role: | ||
name: "newrelic-java-agent-ansible-role" | ||
vars: | ||
nr_java_agent_config: | ||
license_key: YOUR_LICENSE_KEY | ||
app_name: Molecule backup test | ||
collector_host: localhost | ||
|
||
server_type: tomcat | ||
server_root: /var/lib/tomcat8 | ||
jvm_conf_file: /usr/share/tomcat8/bin/setenv.sh | ||
server_user: tomcat8 | ||
server_group: tomcat8 | ||
restart_web_server: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: ubuntu:18.04 | ||
pre_build_image: False | ||
privileged: True | ||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
tasks: | ||
- name: Make sure the backup file was created | ||
wait_for: | ||
path: /var/lib/tomcat8/newrelic/newrelic.yml.orig | ||
search_regex: Old App Name | ||
timeout: 1 | ||
|
||
- name: Make sure the new app name is in the newrelic.yml file | ||
wait_for: | ||
path: /var/lib/tomcat8/newrelic/newrelic.yml | ||
search_regex: Molecule backup test | ||
timeout: 1 | ||
|
||
- name: Make sure .prev is _not_ created | ||
block: | ||
- stat: | ||
path: /var/lib/tomcat8/newrelic/newrelic.yml.prev | ||
register: prev | ||
- assert: | ||
that: not prev.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Molecule managed | ||
|
||
{% if item.registry is defined %} | ||
FROM {{ item.registry.url }}/{{ item.image }} | ||
{% else %} | ||
FROM {{ item.image }} | ||
{% endif %} | ||
|
||
{% if item.env is defined %} | ||
{% for var, value in item.env.items() %} | ||
{% if value %} | ||
ENV {{ var }} {{ value }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 openjdk-8-jre tomcat8 unzip sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean; \ | ||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \ | ||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ | ||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python3 sudo bash iproute2 && zypper clean -a; \ | ||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python3 sudo bash ca-certificates; \ | ||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python3 sudo bash ca-certificates iproute2 && xbps-remove -O; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
******* | ||
Docker driver installation guide | ||
******* | ||
|
||
Requirements | ||
============ | ||
|
||
* Docker Engine | ||
|
||
Install | ||
======= | ||
|
||
Please refer to the `Virtual environment`_ documentation for installation best | ||
practices. If not using a virtual environment, please consider passing the | ||
widely recommended `'--user' flag`_ when invoking ``pip``. | ||
|
||
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ | ||
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site | ||
|
||
.. code-block:: bash | ||
$ python3 -m pip install 'molecule[docker]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
tasks: | ||
- name: "Run agent install role once" | ||
include_role: | ||
name: "newrelic-java-agent-ansible-role" | ||
vars: | ||
nr_java_agent_config: | ||
license_key: YOUR_LICENSE_KEY | ||
app_name: Molecule backup first run | ||
collector_host: localhost | ||
|
||
server_type: tomcat | ||
server_root: /var/lib/tomcat8 | ||
jvm_conf_file: /usr/share/tomcat8/bin/setenv.sh | ||
server_user: tomcat8 | ||
server_group: tomcat8 | ||
restart_web_server: false | ||
|
||
- name: "Run agent install role again - create .orig" | ||
include_role: | ||
name: "newrelic-java-agent-ansible-role" | ||
vars: | ||
nr_java_agent_config: | ||
license_key: YOUR_LICENSE_KEY | ||
app_name: Molecule backup second run | ||
collector_host: localhost | ||
|
||
server_type: tomcat | ||
server_root: /var/lib/tomcat8 | ||
jvm_conf_file: /usr/share/tomcat8/bin/setenv.sh | ||
server_user: tomcat8 | ||
server_group: tomcat8 | ||
restart_web_server: false | ||
|
||
- name: "Run agent install role once more - create .prev" | ||
include_role: | ||
name: "newrelic-java-agent-ansible-role" | ||
vars: | ||
nr_java_agent_config: | ||
license_key: YOUR_LICENSE_KEY | ||
app_name: Molecule backup third run | ||
collector_host: localhost | ||
|
||
server_type: tomcat | ||
server_root: /var/lib/tomcat8 | ||
jvm_conf_file: /usr/share/tomcat8/bin/setenv.sh | ||
server_user: tomcat8 | ||
server_group: tomcat8 | ||
restart_web_server: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: ubuntu:18.04 | ||
pre_build_image: False | ||
privileged: True | ||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
tasks: | ||
- name: Make sure the .orig backup file was created correctly | ||
wait_for: | ||
path: /var/lib/tomcat8/newrelic/newrelic.yml.orig | ||
search_regex: Molecule backup first run | ||
timeout: 1 | ||
|
||
- name: Make sure the .prev backup file was created correctly | ||
wait_for: | ||
path: /var/lib/tomcat8/newrelic/newrelic.yml.prev | ||
search_regex: Molecule backup second run | ||
timeout: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Molecule managed | ||
|
||
{% if item.registry is defined %} | ||
FROM {{ item.registry.url }}/{{ item.image }} | ||
{% else %} | ||
FROM {{ item.image }} | ||
{% endif %} | ||
|
||
{% if item.env is defined %} | ||
{% for var, value in item.env.items() %} | ||
{% if value %} | ||
ENV {{ var }} {{ value }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python3 openjdk-8-jre tomcat8 unzip sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean; \ | ||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \ | ||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ | ||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python3 sudo bash iproute2 && zypper clean -a; \ | ||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python3 sudo bash ca-certificates; \ | ||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python3 sudo bash ca-certificates iproute2 && xbps-remove -O; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
******* | ||
Docker driver installation guide | ||
******* | ||
|
||
Requirements | ||
============ | ||
|
||
* Docker Engine | ||
|
||
Install | ||
======= | ||
|
||
Please refer to the `Virtual environment`_ documentation for installation best | ||
practices. If not using a virtual environment, please consider passing the | ||
widely recommended `'--user' flag`_ when invoking ``pip``. | ||
|
||
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ | ||
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site | ||
|
||
.. code-block:: bash | ||
$ python3 -m pip install 'molecule[docker]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
tasks: | ||
- name: "Include newrelic-java-agent" | ||
include_role: | ||
name: "newrelic-java-agent-ansible-role" | ||
vars: | ||
nr_java_agent_config: | ||
license_key: YOUR_LICENSE_KEY | ||
app_name: Tomcat Molecule test | ||
collector_host: localhost | ||
|
||
server_type: tomcat | ||
server_root: /var/lib/tomcat8 | ||
jvm_conf_file: /usr/share/tomcat8/bin/setenv.sh | ||
server_user: tomcat8 | ||
server_group: tomcat8 | ||
service_name: tomcat8 | ||
restart_web_server: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: ubuntu:18.04 | ||
pre_build_image: False | ||
privileged: True | ||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
tasks: | ||
- name: Wait for tomcat to (not) restart | ||
pause: | ||
seconds: 10 | ||
- name: Make sure agent log does not exist | ||
block: | ||
- name: | ||
stat: | ||
path: /var/lib/tomcat8/newrelic/logs/newrelic_agent.log | ||
register: log_file | ||
- assert: | ||
that: not log_file.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters