mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2026-09-29 07:20:49 -05:00
ITPLT-4737 Migrate remaining Marketplace tests to v3
This commit is contained in:
@@ -1,43 +1,49 @@
|
||||
import json
|
||||
import os
|
||||
from six.moves import urllib
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
import json
|
||||
|
||||
|
||||
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/jira/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_file_is_latest(host):
|
||||
verfile = host.file('/media/atl/jira/shared/jira-core.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/jira-software/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/jira-software/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/jira-core.'+upstream+'-x64.bin')
|
||||
installer = host.file(
|
||||
'/media/atl/downloads/jira-core.' + latest_version + '-x64.bin')
|
||||
assert installer.exists
|
||||
assert installer.user == 'root'
|
||||
|
||||
def test_completed_lockfile(host):
|
||||
req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/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/jira-core.'+upstream+'-x64.bin_completed')
|
||||
def test_completed_lockfile(host):
|
||||
lockfile = host.file(
|
||||
'/media/atl/downloads/jira-core.'
|
||||
+ latest_version
|
||||
+ '-x64.bin_completed')
|
||||
assert lockfile.exists
|
||||
assert lockfile.user == 'root'
|
||||
assert lockfile.user == 'root'
|
||||
|
||||
Reference in New Issue
Block a user