mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2026-11-27 10:50:46 -06:00
ITSD-611934: Compare cached/supplied versions case-insensitively
LooseVersion only tokenises lowercase letters, so an uppercase qualifier such as 11.0.0-CONFDCDEV-4353-m02 became a single '-CONFDCDEV-' component that sorted above the GA '-z' marker. The cached milestone therefore won over the supplied GA release and upgrades silently reinstalled the milestone. Lowercase both values before comparing (comparison only). Adds product_install/confluence_cached_with_upgrade as a regression test.
This commit is contained in:
@@ -30,7 +30,7 @@ pipelines:
|
|||||||
- step:
|
- step:
|
||||||
name: Pre Parallelization stage
|
name: Pre Parallelization stage
|
||||||
script:
|
script:
|
||||||
- echo "Running tests in 38 batches"
|
- echo "Running tests in 39 batches"
|
||||||
|
|
||||||
- step:
|
- step:
|
||||||
name: Check if the template is up-to-date
|
name: Check if the template is up-to-date
|
||||||
@@ -38,7 +38,7 @@ pipelines:
|
|||||||
- |
|
- |
|
||||||
actual_scenario_count=$(find ./roles -type f -name "molecule.yml" -exec dirname {} ';' | wc -l | sed -e 's/^[[:space:]]*//')
|
actual_scenario_count=$(find ./roles -type f -name "molecule.yml" -exec dirname {} ';' | wc -l | sed -e 's/^[[:space:]]*//')
|
||||||
if ! grep -q "Running tests in ${actual_scenario_count} batches" bitbucket-pipelines.yml; then
|
if ! grep -q "Running tests in ${actual_scenario_count} batches" bitbucket-pipelines.yml; then
|
||||||
echo "Mismatch between expected (38) and actual number (${actual_scenario_count}) of scenarios. Please look at https://bitbucket.org/atlassian/dc-deployments-automation/src/master/DEVELOPMENT.md for instructions on how to fix this error."
|
echo "Mismatch between expected (39) and actual number (${actual_scenario_count}) of scenarios. Please look at https://bitbucket.org/atlassian/dc-deployments-automation/src/master/DEVELOPMENT.md for instructions on how to fix this error."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -295,6 +295,20 @@ pipelines:
|
|||||||
- ./bin/install-ansible --dev
|
- ./bin/install-ansible --dev
|
||||||
- cd roles/product_install
|
- cd roles/product_install
|
||||||
- pipenv run molecule test -s bitbucket_latest
|
- pipenv run molecule test -s bitbucket_latest
|
||||||
|
- step:
|
||||||
|
name: product_install/confluence_cached_with_upgrade
|
||||||
|
caches:
|
||||||
|
- ansible-collections
|
||||||
|
- docker
|
||||||
|
- pip
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
script:
|
||||||
|
- apt-get update && apt-get install -y rsync
|
||||||
|
- export ANSIBLE_CONFIG=./ansible.cfg
|
||||||
|
- ./bin/install-ansible --dev
|
||||||
|
- cd roles/product_install
|
||||||
|
- pipenv run molecule test -s confluence_cached_with_upgrade
|
||||||
- step:
|
- step:
|
||||||
name: product_install/confluence_latest
|
name: product_install/confluence_latest
|
||||||
caches:
|
caches:
|
||||||
|
|||||||
@@ -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 python3 sudo bash ca-certificates file && apt-get clean; \
|
||||||
|
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python3.11 sudo python3.11-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
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
# Regression test for ITSD-611934: upgrading from a cached milestone that has
|
||||||
|
# an uppercase qualifier (e.g. 11.0.0-CONFDCDEV-4353-m02) to the matching GA
|
||||||
|
# release. Before the fix, LooseVersion sorted the uppercase qualifier above
|
||||||
|
# the GA '-z' marker, so the cached milestone won and the GA was never
|
||||||
|
# installed.
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
atl_product_family: "confluence"
|
||||||
|
atl_product_edition: "confluence"
|
||||||
|
atl_product_user: "confluence"
|
||||||
|
# NOTE: This should be honoured as it is the GA of the cached milestone.
|
||||||
|
atl_product_version: "7.20.0"
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Create cache dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: '/media/atl/confluence/shared-home/'
|
||||||
|
state: directory
|
||||||
|
- name: Seed cached uppercase milestone version
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: '/media/atl/confluence/shared-home/confluence.version'
|
||||||
|
content: "7.20.0-CONFSERVER-63193-m01"
|
||||||
|
force: false # For idempotency check
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: linux_common
|
||||||
|
- role: product_common
|
||||||
|
- role: product_install
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
platforms:
|
||||||
|
- name: amazon_linux2023
|
||||||
|
image: amazonlinux:2023
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
platform: linux/amd64
|
||||||
|
- name: ubuntu_lts
|
||||||
|
image: ubuntu:jammy
|
||||||
|
groups:
|
||||||
|
- aws_node_local
|
||||||
|
platform: linux/amd64
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
env:
|
||||||
|
ANSIBLE_COLLECTIONS_PATH: "../../../../"
|
||||||
|
options:
|
||||||
|
skip-tags: runtime_pkg
|
||||||
|
inventory:
|
||||||
|
links:
|
||||||
|
group_vars: ../../../../group_vars/
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_version_cache_upgraded_to_ga(host):
|
||||||
|
verfile = host.file('/media/atl/confluence/shared-home/confluence.version')
|
||||||
|
assert verfile.exists
|
||||||
|
assert verfile.content.decode("UTF-8").strip() == "7.20.0"
|
||||||
|
|
||||||
|
|
||||||
|
def test_ga_is_unpacked(host):
|
||||||
|
installdir = host.file('/opt/atlassian/confluence/7.20.0')
|
||||||
|
assert installdir.exists
|
||||||
|
assert installdir.is_directory
|
||||||
|
|
||||||
|
|
||||||
|
def test_milestone_not_installed(host):
|
||||||
|
assert not host.file('/opt/atlassian/confluence/7.20.0-CONFSERVER-63193-m01').exists
|
||||||
|
|
||||||
|
|
||||||
|
def test_current_points_to_ga(host):
|
||||||
|
current = host.file('/opt/atlassian/confluence/current')
|
||||||
|
assert current.is_symlink
|
||||||
|
assert current.linked_to == '/opt/atlassian/confluence/7.20.0'
|
||||||
@@ -66,6 +66,13 @@
|
|||||||
# there is some test logic hack to allow atlassian specfic versioning
|
# there is some test logic hack to allow atlassian specfic versioning
|
||||||
# requirements to work as expected ie - (7.2.0 to upgrade over 7.2.0-rc1) and
|
# requirements to work as expected ie - (7.2.0 to upgrade over 7.2.0-rc1) and
|
||||||
# (7.2.0-beta1 to upgrade over 7.2.0-m01) in "version is not latest"
|
# (7.2.0-beta1 to upgrade over 7.2.0-m01) in "version is not latest"
|
||||||
|
#
|
||||||
|
# The comparison values are lowercased first. LooseVersion only splits
|
||||||
|
# lowercase letters into their own components, so an uppercase qualifier
|
||||||
|
# (e.g. 11.0.0-CONFDCDEV-4353-m02) would otherwise become a single '-CONFDCDEV-'
|
||||||
|
# component that sorts *above* the GA '-z' marker, causing the cached
|
||||||
|
# milestone to win over the supplied GA release. Lowercasing only affects
|
||||||
|
# the comparison; the real version strings are left untouched.
|
||||||
|
|
||||||
- name: "Case: Version is latest"
|
- name: "Case: Version is latest"
|
||||||
block:
|
block:
|
||||||
@@ -91,8 +98,8 @@
|
|||||||
|
|
||||||
- name: "create atlassian ordered versioning for comparison"
|
- name: "create atlassian ordered versioning for comparison"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
atl_product_normalised_version: "{{ atl_z_product_version | replace('-m', '-am') }}"
|
atl_product_normalised_version: "{{ atl_z_product_version | lower | replace('-m', '-am') }}"
|
||||||
atl_cached_normalised_version: "{{ atl_z_cached_version | replace('-m', '-am') }}"
|
atl_cached_normalised_version: "{{ atl_z_cached_version | lower | replace('-m', '-am') }}"
|
||||||
|
|
||||||
- name: "Case: No cached version, or supplied is higher; use supplied"
|
- name: "Case: No cached version, or supplied is higher; use supplied"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
|||||||
Reference in New Issue
Block a user