From 9e6eb4173417ae4225c97e89888ffa180dbac53c Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Wed, 28 Aug 2019 09:58:51 +1000 Subject: [PATCH 1/8] DCD-621: externalizes db type based in dbconfig.xml for Jira --- roles/jira_config/defaults/main.yml | 1 + roles/jira_config/molecule/default/playbook.yml | 1 + roles/jira_config/molecule/default/tests/test_default.py | 1 + roles/jira_config/templates/dbconfig.xml.j2 | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/jira_config/defaults/main.yml b/roles/jira_config/defaults/main.yml index 0a90817..776e44e 100644 --- a/roles/jira_config/defaults/main.yml +++ b/roles/jira_config/defaults/main.yml @@ -26,6 +26,7 @@ atl_db_poolminsize: '20' atl_db_poolmaxsize: '100' atl_db_minidle: '10' atl_db_maxidle: '20' +atl_db_type: 'postgres72' atl_db_maxwaitmillis: '30000' atl_db_timebetweenevictionrunsmillis: '30000' diff --git a/roles/jira_config/molecule/default/playbook.yml b/roles/jira_config/molecule/default/playbook.yml index be14065..3270e74 100644 --- a/roles/jira_config/molecule/default/playbook.yml +++ b/roles/jira_config/molecule/default/playbook.yml @@ -23,6 +23,7 @@ atl_db_removeabandonedtimeout: 1111 atl_db_testwhileidle: 'false' atl_db_testonborrow: 'true' + atl_db_type: 'postgres96' roles: - role: linux_common diff --git a/roles/jira_config/molecule/default/tests/test_default.py b/roles/jira_config/molecule/default/tests/test_default.py index 58b83f9..4626e4e 100644 --- a/roles/jira_config/molecule/default/tests/test_default.py +++ b/roles/jira_config/molecule/default/tests/test_default.py @@ -10,6 +10,7 @@ def test_dbconfig_file(host): f = host.file('/var/atlassian/application-data/jira/dbconfig.xml') assert f.exists assert f.user == 'jira' + assert f.contains("postgres96") assert f.contains("org.postgresql.Driver") assert f.contains("atljira") assert f.contains("molecule_password") diff --git a/roles/jira_config/templates/dbconfig.xml.j2 b/roles/jira_config/templates/dbconfig.xml.j2 index 18c9ed7..8ae7e81 100644 --- a/roles/jira_config/templates/dbconfig.xml.j2 +++ b/roles/jira_config/templates/dbconfig.xml.j2 @@ -3,7 +3,7 @@ defaultDS default - postgres72 + {{ atl_db_type }} public {{ atl_jdbc_url }} From 2a00f3350818458150965f2c85b1f15c50a61018 Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Wed, 28 Aug 2019 12:21:28 +1000 Subject: [PATCH 2/8] DCD-621: Uses ATL_DB_ENGINE paramerter to infer database type. If db_engine is 'aurora_postgres', then use aurrora postgres db type. Else use default postgres db_type --- group_vars/aws_node_local.yml | 1 + roles/jira_config/defaults/main.yml | 1 - .../jira_config/molecule/aurora/Dockerfile.j2 | 14 ++++ .../jira_config/molecule/aurora/molecule.yml | 36 +++++++++ .../jira_config/molecule/aurora/playbook.yml | 32 ++++++++ .../molecule/aurora/tests/test_default.py | 75 +++++++++++++++++++ .../jira_config/molecule/default/playbook.yml | 2 +- .../molecule/default/tests/test_default.py | 2 +- 8 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 roles/jira_config/molecule/aurora/Dockerfile.j2 create mode 100644 roles/jira_config/molecule/aurora/molecule.yml create mode 100644 roles/jira_config/molecule/aurora/playbook.yml create mode 100644 roles/jira_config/molecule/aurora/tests/test_default.py diff --git a/group_vars/aws_node_local.yml b/group_vars/aws_node_local.yml index ab854c1..e618de4 100644 --- a/group_vars/aws_node_local.yml +++ b/group_vars/aws_node_local.yml @@ -65,6 +65,7 @@ atl_db_removeabandoned: "{{ lookup('env', 'ATL_DB_REMOVEABANDONED') or 'true' }} atl_db_removeabandonedtimeout: "{{ lookup('env', 'ATL_DB_REMOVEABANDONEDTIMEOUT') or '300' }}" atl_db_testwhileidle: "{{ lookup('env', 'ATL_DB_TESTWHILEIDLE') or 'true'}}" atl_db_testonborrow: "{{ lookup('env', 'ATL_DB_TESTONBORROW') or 'false' }}" +atl_db_type: "{{ 'postgresaurora96' if atl_db_engine == 'aurora_postgres' else 'postgres72'}}" atl_jdbc_db_name: "{{ lookup('env', 'ATL_JDBC_DB_NAME') }}" atl_jdbc_user: "{{ lookup('env', 'ATL_JDBC_USER') }}" diff --git a/roles/jira_config/defaults/main.yml b/roles/jira_config/defaults/main.yml index 776e44e..0a90817 100644 --- a/roles/jira_config/defaults/main.yml +++ b/roles/jira_config/defaults/main.yml @@ -26,7 +26,6 @@ atl_db_poolminsize: '20' atl_db_poolmaxsize: '100' atl_db_minidle: '10' atl_db_maxidle: '20' -atl_db_type: 'postgres72' atl_db_maxwaitmillis: '30000' atl_db_timebetweenevictionrunsmillis: '30000' diff --git a/roles/jira_config/molecule/aurora/Dockerfile.j2 b/roles/jira_config/molecule/aurora/Dockerfile.j2 new file mode 100644 index 0000000..e6aa95d --- /dev/null +++ b/roles/jira_config/molecule/aurora/Dockerfile.j2 @@ -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 diff --git a/roles/jira_config/molecule/aurora/molecule.yml b/roles/jira_config/molecule/aurora/molecule.yml new file mode 100644 index 0000000..7f082f6 --- /dev/null +++ b/roles/jira_config/molecule/aurora/molecule.yml @@ -0,0 +1,36 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: amazon_linux2 + image: amazonlinux:2 + groups: + - aws_node_local + ulimits: + - nofile:262144:262144 + - name: ubuntu_lts + image: ubuntu:bionic + groups: + - aws_node_local + ulimits: + - nofile:262144:262144 +provisioner: + name: ansible + options: + skip-tags: runtime_pkg + lint: + name: ansible-lint + options: + x: ["701"] + inventory: + links: + group_vars: ../../../../group_vars/ +verifier: + name: testinfra + lint: + name: flake8 + enabled: false diff --git a/roles/jira_config/molecule/aurora/playbook.yml b/roles/jira_config/molecule/aurora/playbook.yml new file mode 100644 index 0000000..d273f47 --- /dev/null +++ b/roles/jira_config/molecule/aurora/playbook.yml @@ -0,0 +1,32 @@ +--- +- name: Converge + hosts: all + vars: + atl_product_family: "jira" + atl_product_edition: "jira-software" + atl_product_user: "jira" + atl_product_version: "7.13.2" + + # dbconfig.xml variables + atl_jdbc_user: 'atljira' + atl_jdbc_password: 'molecule_password' + atl_jvm_heap: 'PLACEHOLDER' + atl_cluster_node_id: 'FAKEID' + atl_db_poolminsize: 1111 + atl_db_poolmaxsize: 1111 + atl_db_minidle: 1111 + atl_db_maxidle: 1111 + atl_db_maxwaitmillis: 1111 + atl_db_minevictableidletimemillis: 1111 + atl_db_timebetweenevictionrunsmillis: 1111 + atl_db_removeabandoned: 'false' + atl_db_removeabandonedtimeout: 1111 + atl_db_testwhileidle: 'false' + atl_db_testonborrow: 'true' + atl_db_engine: 'aurora_postgres' + + roles: + - role: linux_common + - role: product_common + - role: product_install + - role: jira_config diff --git a/roles/jira_config/molecule/aurora/tests/test_default.py b/roles/jira_config/molecule/aurora/tests/test_default.py new file mode 100644 index 0000000..e684eb2 --- /dev/null +++ b/roles/jira_config/molecule/aurora/tests/test_default.py @@ -0,0 +1,75 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_dbconfig_file(host): + f = host.file('/var/atlassian/application-data/jira/dbconfig.xml') + assert f.exists + assert f.user == 'jira' + assert f.contains("postgresaurora96") + assert f.contains("org.postgresql.Driver") + assert f.contains("atljira") + assert f.contains("molecule_password") + + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("1111") + + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("false") + assert f.contains("1111") + assert f.contains("1111") + assert f.contains("false") + assert f.contains("1111") + assert f.contains("false") + assert f.contains("true") + + +def test_setenv_file(host): + f = host.file('/opt/atlassian/jira-software/current/bin/setenv.sh') + assert f.exists + assert f.contains('^JVM_MINIMUM_MEMORY="PLACEHOLDER"') + assert f.contains('^JVM_MAXIMUM_MEMORY="PLACEHOLDER"') + assert f.contains('^JIRA_HOME="/var/atlassian/application-data/jira"') + assert f.contains('^export CATALINA_OPTS="') + + +def test_cluster_file(host): + f = host.file('/var/atlassian/application-data/jira/cluster.properties') + assert f.exists + assert f.contains('jira.node.id = FAKEID') + assert f.contains('jira.shared.home = /media/atl/jira/shared') + + +def test_server_file(host): + f = host.file('/opt/atlassian/jira-software/current/conf/server.xml') + assert f.exists + assert f.contains('Connector port="8080"') + assert f.contains('Server port="8005"') + assert f.contains('postgres96") + assert f.contains("postgres72") assert f.contains("org.postgresql.Driver") assert f.contains("atljira") assert f.contains("molecule_password") From afb572576194928a8caa17b6adb35b1b203e2df3 Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Wed, 28 Aug 2019 14:42:56 +1000 Subject: [PATCH 3/8] DCD-621: Uses a map to define db_type for a db_engine --- group_vars/aws_node_local.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/group_vars/aws_node_local.yml b/group_vars/aws_node_local.yml index e618de4..ed82c17 100644 --- a/group_vars/aws_node_local.yml +++ b/group_vars/aws_node_local.yml @@ -65,7 +65,10 @@ atl_db_removeabandoned: "{{ lookup('env', 'ATL_DB_REMOVEABANDONED') or 'true' }} atl_db_removeabandonedtimeout: "{{ lookup('env', 'ATL_DB_REMOVEABANDONEDTIMEOUT') or '300' }}" atl_db_testwhileidle: "{{ lookup('env', 'ATL_DB_TESTWHILEIDLE') or 'true'}}" atl_db_testonborrow: "{{ lookup('env', 'ATL_DB_TESTONBORROW') or 'false' }}" -atl_db_type: "{{ 'postgresaurora96' if atl_db_engine == 'aurora_postgres' else 'postgres72'}}" +atl_db_engine_to_db_type_map: + aurora_postgres: "postgresaurora96" + rds_postgres: "postgres72" +atl_db_type: "{{ atl_db_engine_to_db_type_map[atl_db_engine] | default('postgres72') }}" atl_jdbc_db_name: "{{ lookup('env', 'ATL_JDBC_DB_NAME') }}" atl_jdbc_user: "{{ lookup('env', 'ATL_JDBC_USER') }}" From 7114795020d41d6002ee970dd2be80889d8d285b Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Wed, 28 Aug 2019 15:24:21 +1000 Subject: [PATCH 4/8] DCD-621: bumps up size to 2x --- bitbucket-pipelines.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 6b5f0dd..a19258c 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,11 +1,13 @@ --- image: atlassian/default-image:2 +options: + size: 2x definitions: services: docker: - memory: 3072 + memory: 4096 pipelines: default: From 2d8358580336a83be156e54ece4e44d05b14549a Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Thu, 29 Aug 2019 12:50:52 +1000 Subject: [PATCH 5/8] DCD-621: fixes installer tests - Test should assert for full file name for installer. Previously, tests were missing checking for -x64 installer suffix --- .../molecule/bitbucket_latest/tests/test_default.py | 8 +++++--- .../molecule/confluence_latest/tests/test_default.py | 2 +- .../molecule/default/tests/test_default.py | 2 +- .../molecule/jira_software_latest/tests/test_default.py | 2 +- .../molecule/jira_version_latest/tests/test_default.py | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/roles/product_install/molecule/bitbucket_latest/tests/test_default.py b/roles/product_install/molecule/bitbucket_latest/tests/test_default.py index 7157e10..55c71c6 100644 --- a/roles/product_install/molecule/bitbucket_latest/tests/test_default.py +++ b/roles/product_install/molecule/bitbucket_latest/tests/test_default.py @@ -24,17 +24,19 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/bitbucket/shared/bitbucket.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/bitbucket/versions/latest") + upstream_fd = urllib.request.urlopen( + "https://marketplace.atlassian.com/rest/2/applications/bitbucket/versions/latest") upstream_json = json.load(upstream_fd) upstream = upstream_json['version'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/applications/bitbucket/versions/latest") + upstream_fd = urllib.request.urlopen( + "https://marketplace.atlassian.com/rest/2/applications/bitbucket/versions/latest") upstream_json = json.load(upstream_fd) upstream = upstream_json['version'] - installer = host.file('/opt/atlassian/tmp/bitbucket.'+upstream+'.bin') + installer = host.file('/opt/atlassian/tmp/bitbucket.' + upstream + '-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/confluence_latest/tests/test_default.py b/roles/product_install/molecule/confluence_latest/tests/test_default.py index 72a5adf..47245a4 100644 --- a/roles/product_install/molecule/confluence_latest/tests/test_default.py +++ b/roles/product_install/molecule/confluence_latest/tests/test_default.py @@ -35,6 +35,6 @@ def test_latest_is_downloaded(host): upstream_json = json.load(upstream_fd) upstream = upstream_json['version'] - installer = host.file('/opt/atlassian/tmp/confluence.'+upstream+'.bin') + installer = host.file('/opt/atlassian/tmp/confluence.'+upstream+'-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/default/tests/test_default.py b/roles/product_install/molecule/default/tests/test_default.py index 18c41a2..70839b9 100644 --- a/roles/product_install/molecule/default/tests/test_default.py +++ b/roles/product_install/molecule/default/tests/test_default.py @@ -23,6 +23,6 @@ def test_latest_is_downloaded(host): upstream_json = json.load(upstream_fd) upstream = upstream_json['version'] - installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'.bin') + installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/jira_software_latest/tests/test_default.py b/roles/product_install/molecule/jira_software_latest/tests/test_default.py index ff6fa8b..63451c8 100644 --- a/roles/product_install/molecule/jira_software_latest/tests/test_default.py +++ b/roles/product_install/molecule/jira_software_latest/tests/test_default.py @@ -35,6 +35,6 @@ def test_latest_is_downloaded(host): upstream_json = json.load(upstream_fd) upstream = upstream_json['version'] - installer = host.file('/opt/atlassian/tmp/jira-software.'+upstream+'.bin') + installer = host.file('/opt/atlassian/tmp/jira-software.'+upstream+'-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/jira_version_latest/tests/test_default.py b/roles/product_install/molecule/jira_version_latest/tests/test_default.py index 18c41a2..70839b9 100644 --- a/roles/product_install/molecule/jira_version_latest/tests/test_default.py +++ b/roles/product_install/molecule/jira_version_latest/tests/test_default.py @@ -23,6 +23,6 @@ def test_latest_is_downloaded(host): upstream_json = json.load(upstream_fd) upstream = upstream_json['version'] - installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'.bin') + installer = host.file('/opt/atlassian/tmp/jira-core.'+upstream+'-x64.bin') assert installer.exists assert installer.user == 'root' From 856e60abe691e2ab3af34ebdbd0177c5884e0308 Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Thu, 29 Aug 2019 14:58:51 +1000 Subject: [PATCH 6/8] DCD-621: fixes installer tests for most scenarios under product_install --- roles/product_install/molecule/bitbucket_latest/playbook.yml | 1 - .../molecule/jira_cached_with_downgrade/tests/test_default.py | 2 +- .../molecule/jira_cached_with_upgrade/tests/test_default.py | 2 +- .../molecule/jira_version_from_file/tests/test_default.py | 2 +- .../molecule/jira_version_override/tests/test_default.py | 2 +- .../product_install/molecule/servicedesk3/tests/test_default.py | 2 +- .../product_install/molecule/servicedesk4/tests/test_default.py | 2 +- .../molecule/servicedesk_latest/tests/test_default.py | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) diff --git a/roles/product_install/molecule/bitbucket_latest/playbook.yml b/roles/product_install/molecule/bitbucket_latest/playbook.yml index 907928d..55ad545 100644 --- a/roles/product_install/molecule/bitbucket_latest/playbook.yml +++ b/roles/product_install/molecule/bitbucket_latest/playbook.yml @@ -7,7 +7,6 @@ atl_product_user: "bitbucket" atl_product_home: "{{ atl_shared_mountpoint }}/{{ atl_product_edition }}" - roles: - role: linux_common - role: product_common diff --git a/roles/product_install/molecule/jira_cached_with_downgrade/tests/test_default.py b/roles/product_install/molecule/jira_cached_with_downgrade/tests/test_default.py index e21a7a2..05a6bb3 100644 --- a/roles/product_install/molecule/jira_cached_with_downgrade/tests/test_default.py +++ b/roles/product_install/molecule/jira_cached_with_downgrade/tests/test_default.py @@ -14,7 +14,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == "7.10.2" def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/jira-core.7.10.2.bin') + installer = host.file('/opt/atlassian/tmp/jira-core.7.10.2-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/jira_cached_with_upgrade/tests/test_default.py b/roles/product_install/molecule/jira_cached_with_upgrade/tests/test_default.py index 9e9cc48..ead6adf 100644 --- a/roles/product_install/molecule/jira_cached_with_upgrade/tests/test_default.py +++ b/roles/product_install/molecule/jira_cached_with_upgrade/tests/test_default.py @@ -14,7 +14,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == "7.10.1" def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/jira-core.7.10.1.bin') + installer = host.file('/opt/atlassian/tmp/jira-core.7.10.1-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/jira_version_from_file/tests/test_default.py b/roles/product_install/molecule/jira_version_from_file/tests/test_default.py index 102cf44..5f00577 100644 --- a/roles/product_install/molecule/jira_version_from_file/tests/test_default.py +++ b/roles/product_install/molecule/jira_version_from_file/tests/test_default.py @@ -14,7 +14,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == "7.9.0" def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/jira-core.7.9.0.bin') + installer = host.file('/opt/atlassian/tmp/jira-core.7.9.0-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/jira_version_override/tests/test_default.py b/roles/product_install/molecule/jira_version_override/tests/test_default.py index a6407d7..8b5c7a4 100644 --- a/roles/product_install/molecule/jira_version_override/tests/test_default.py +++ b/roles/product_install/molecule/jira_version_override/tests/test_default.py @@ -14,7 +14,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == "7.13.2" def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/jira-core.7.13.2.bin') + installer = host.file('/opt/atlassian/tmp/jira-core.7.13.2-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/servicedesk3/tests/test_default.py b/roles/product_install/molecule/servicedesk3/tests/test_default.py index 2ec583f..24afb62 100644 --- a/roles/product_install/molecule/servicedesk3/tests/test_default.py +++ b/roles/product_install/molecule/servicedesk3/tests/test_default.py @@ -14,7 +14,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == "3.9.0" def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/servicedesk.3.9.0.bin') + installer = host.file('/opt/atlassian/tmp/servicedesk.3.9.0-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/servicedesk4/tests/test_default.py b/roles/product_install/molecule/servicedesk4/tests/test_default.py index dff1ffe..b660f23 100644 --- a/roles/product_install/molecule/servicedesk4/tests/test_default.py +++ b/roles/product_install/molecule/servicedesk4/tests/test_default.py @@ -14,7 +14,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == "4.1.0" def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/servicedesk.4.1.0.bin') + installer = host.file('/opt/atlassian/tmp/servicedesk.4.1.0-x64.bin') assert installer.exists assert installer.user == 'root' diff --git a/roles/product_install/molecule/servicedesk_latest/tests/test_default.py b/roles/product_install/molecule/servicedesk_latest/tests/test_default.py index 7168f06..2190295 100644 --- a/roles/product_install/molecule/servicedesk_latest/tests/test_default.py +++ b/roles/product_install/molecule/servicedesk_latest/tests/test_default.py @@ -23,7 +23,7 @@ def test_version_is_correct(host): assert verfile.content.decode("UTF-8").strip() == sd def test_is_downloaded(host): - installer = host.file('/opt/atlassian/tmp/servicedesk.'+sd+'.bin') + installer = host.file('/opt/atlassian/tmp/servicedesk.'+sd+'-x64.bin') assert installer.exists assert installer.user == 'root' From 8cf01382af2627269279f6da3ebd753a08bc94bc Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Thu, 29 Aug 2019 16:12:14 +1000 Subject: [PATCH 7/8] DCD-621: Changes pipelines to run scenarios in parallel. (9 batches of 3 scenarios each) --- bin/run-tests-in-batches | 50 +++++++++++++++++++++++++ bitbucket-pipelines.yml | 81 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 5 deletions(-) create mode 100755 bin/run-tests-in-batches diff --git a/bin/run-tests-in-batches b/bin/run-tests-in-batches new file mode 100755 index 0000000..ca3bd78 --- /dev/null +++ b/bin/run-tests-in-batches @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e +#set -x + +# Install dev packages from Pipfile.lock if necessary. +#pipenv sync --dev + +BATCH_NUMBER="" +batch_args="$1" + +case $batch_args in + -b|--batch) + BATCH_NUMBER="$2" + ;; + --default) + BATCH_NUMBER="" + ;; +esac + +if [[ -z "$BATCH_NUMBER" ]]; then + echo "Batch number not passed in. Please pass a batch number to run tests." + exit -1 +fi + +case ${BATCH_NUMBER} in + ''|*[1-9]*) ;; + *) echo "Bad Input for Batch number. ${BATCH_NUMBER} is not a valid batch number (Should be a number >= 1)" && exit -1 ;; +esac + +scenarios=( $(ls -d1 roles/**/molecule/* | sort) ) + +offset=$(( ${BATCH_NUMBER} - 1)) +test_start_index=$(( ${offset} * 3 )) + +for scenario in "${scenarios[@]:$test_start_index:3}"; do + pushd $(dirname $(dirname $scenario)) + pipenv run \ + molecule test --all + popd +done; + + + +#for role in `find roles/ -name molecule | sort`; do +# pushd `dirname $role` +# pipenv run \ +# molecule test --all +# popd +#done diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index a19258c..5239424 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -12,9 +12,80 @@ definitions: pipelines: default: - step: - services: - - docker + name: Pre Parallelization stage script: - - apt-get update && apt-get install -y virtualenv python-dev - - ./bin/install-ansible - - ./bin/run-all-tests + - echo "Running tests in 9 batches of 3 scenarios (max) each" + - parallel: + - step: + name: Molecule test batch 1 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 1 + - step: + name: Molecule test batch 2 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 2 + - step: + name: Molecule test batch 3 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 3 + - step: + name: Molecule test batch 4 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 4 + - step: + name: Molecule test batch 5 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 5 + - step: + name: Molecule test batch 6 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 6 + - step: + name: Molecule test batch 7 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 7 + - step: + name: Molecule test batch 8 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 8 + - step: + name: Molecule test batch 9 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 9 + From 90cd3f5f98797bf04f10d3c57062caa4b3fd4fdb Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Thu, 29 Aug 2019 16:34:58 +1000 Subject: [PATCH 8/8] DCD-621: Cleans up comments & extracts batch number to a variable --- bin/run-tests-in-batches | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/bin/run-tests-in-batches b/bin/run-tests-in-batches index ca3bd78..54b8d1b 100755 --- a/bin/run-tests-in-batches +++ b/bin/run-tests-in-batches @@ -4,8 +4,9 @@ set -e #set -x # Install dev packages from Pipfile.lock if necessary. -#pipenv sync --dev +pipenv sync --dev +BATCH_SIZE=3 BATCH_NUMBER="" batch_args="$1" @@ -31,20 +32,14 @@ esac scenarios=( $(ls -d1 roles/**/molecule/* | sort) ) offset=$(( ${BATCH_NUMBER} - 1)) -test_start_index=$(( ${offset} * 3 )) +test_start_index=$(( ${offset} * $BATCH_SIZE )) +scenario_batch="${scenarios[@]:$test_start_index:$BATCH_SIZE}" -for scenario in "${scenarios[@]:$test_start_index:3}"; do +echo "Scenarios that will be executed as part of this batch: ${scenario_batch}" + +for scenario in ${scenario_batch}; do pushd $(dirname $(dirname $scenario)) pipenv run \ molecule test --all popd done; - - - -#for role in `find roles/ -name molecule | sort`; do -# pushd `dirname $role` -# pipenv run \ -# molecule test --all -# popd -#done