mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-14 14:25:36 +01:00
Merge pull request #4141 from wy65701436/dump-harbor-version
Dump harbor version for CI
This commit is contained in:
commit
07a75ed266
@ -89,6 +89,11 @@ if build_type == "ova" :
|
||||
logger.info("Harbor is not ready after 10 minutes.")
|
||||
sys.exit(-1)
|
||||
logger.info("%s is ready for test now..." % item)
|
||||
# ----- log harbor version -----
|
||||
harbor_version = harbor_util.get_harbor_version(item, 'admin', 'Harbor12345')
|
||||
logger.info("Harbor version: %s ..." % harbor_version)
|
||||
with open(os.getcwd() + '/build.properties', 'w') as the_file:
|
||||
the_file.write('harbor_version=%s' % harbor_version)
|
||||
|
||||
# ----- execute test cases -----
|
||||
try:
|
||||
|
@ -1,6 +1,33 @@
|
||||
from urllib2 import urlopen
|
||||
import ssl
|
||||
import time
|
||||
import os
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
def request(harbor_endpoint, url, method, user, pwd, **kwargs):
|
||||
url = "https://" + harbor_endpoint + "/api" + url
|
||||
kwargs.setdefault('headers', kwargs.get('headers', {}))
|
||||
kwargs['headers']['Accept'] = 'application/json'
|
||||
if 'body' in kwargs:
|
||||
kwargs['headers']['Content-Type'] = 'application/json'
|
||||
kwargs['data'] = json.dumps(kwargs['body'])
|
||||
del kwargs['body']
|
||||
|
||||
resp = requests.request(method, url, verify=False, auth=(user, pwd), **kwargs)
|
||||
if resp.status_code >= 400:
|
||||
raise Exception("Error: %s" % resp.text)
|
||||
try:
|
||||
body = json.loads(resp.text)
|
||||
except ValueError:
|
||||
body = resp.text
|
||||
return body
|
||||
|
||||
# wait for 10 minutes as OVA needs about 7 minutes to startup harbor.
|
||||
def wait_for_harbor_ready(harbor_endpoint, timeout=600):
|
||||
@ -21,3 +48,6 @@ def wait_for_harbor_ready(harbor_endpoint, timeout=600):
|
||||
continue
|
||||
timeout -= interval
|
||||
time.sleep(interval)
|
||||
|
||||
def get_harbor_version(harbor_endpoint, harbor_user, harbor_pwd):
|
||||
return request(harbor_endpoint, '/systeminfo', 'get', harbor_user, harbor_pwd)['harbor_version']
|
||||
|
Loading…
Reference in New Issue
Block a user