ITPLT-4737 Migrate remaining Marketplace tests to v3

This commit is contained in:
Lee Goolsbee
2026-09-04 11:20:53 -05:00
parent fdf9d08429
commit e263b3394c
9 changed files with 289 additions and 209 deletions

View File

@@ -1,55 +1,65 @@
import json
import os
from six.moves import urllib
import json
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
MARKETPLACE_LATEST_VERSION_URL = (
"https://marketplace.atlassian.com/rest/3/parent-software/crowd/versions"
"?state=ACTIVE&limit=1")
def get_latest_version():
req = urllib.request.Request(MARKETPLACE_LATEST_VERSION_URL)
req.add_header('User-Agent', 'ansible-httpget')
upstream_fd = urllib.request.urlopen(req)
try:
upstream_json = json.load(upstream_fd)
finally:
upstream_fd.close()
return upstream_json['versions'][0]['versionNumber']
latest_version = get_latest_version()
def test_version_downloaded(host):
verfile = host.file('/media/atl/crowd/shared/crowd.version')
assert verfile.exists
def test_symlink_created(host):
target = host.file('/opt/atlassian/crowd/current')
assert target.exists
assert target.is_symlink
def test_unpacked(host):
verfile = host.file('/opt/atlassian/crowd/current/start_crowd.sh')
assert verfile.exists
def test_version_file_is_latest(host):
verfile = host.file('/media/atl/crowd/shared/crowd.version')
assert verfile.exists
assert verfile.content.decode("UTF-8").strip() == latest_version.strip()
req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions")
req.add_header('User-Agent', 'ansible-httpget')
upstream_fd = urllib.request.urlopen(req)
upstream_json = json.load(upstream_fd)
upstream = upstream_json['_embedded']['versions'][0]['name']
assert verfile.content.decode("UTF-8").strip() == upstream.strip()
def test_latest_is_downloaded(host):
req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions")
req.add_header('User-Agent', 'ansible-httpget')
upstream_fd = urllib.request.urlopen(req)
upstream_json = json.load(upstream_fd)
upstream = upstream_json['_embedded']['versions'][0]['name']
installer = host.file('/media/atl/downloads/crowd.' + upstream + '.tar.gz')
installer = host.file(
'/media/atl/downloads/crowd.' + latest_version + '.tar.gz')
assert installer.exists
assert installer.user == 'root'
def test_completed_lockfile(host):
req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions")
req.add_header('User-Agent', 'ansible-httpget')
upstream_fd = urllib.request.urlopen(req)
upstream_json = json.load(upstream_fd)
upstream = upstream_json['_embedded']['versions'][0]['name']
lockfile = host.file('/media/atl/downloads/crowd.' + upstream + '.tar.gz_completed')
def test_completed_lockfile(host):
lockfile = host.file(
'/media/atl/downloads/crowd.'
+ latest_version
+ '.tar.gz_completed')
assert lockfile.exists
assert lockfile.user == 'root'