mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 18:55:18 +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.")
|
logger.info("Harbor is not ready after 10 minutes.")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
logger.info("%s is ready for test now..." % item)
|
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 -----
|
# ----- execute test cases -----
|
||||||
try:
|
try:
|
||||||
|
@ -1,6 +1,33 @@
|
|||||||
from urllib2 import urlopen
|
from urllib2 import urlopen
|
||||||
import ssl
|
import ssl
|
||||||
import time
|
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.
|
# wait for 10 minutes as OVA needs about 7 minutes to startup harbor.
|
||||||
def wait_for_harbor_ready(harbor_endpoint, timeout=600):
|
def wait_for_harbor_ready(harbor_endpoint, timeout=600):
|
||||||
@ -20,4 +47,7 @@ def wait_for_harbor_ready(harbor_endpoint, timeout=600):
|
|||||||
time.sleep(interval)
|
time.sleep(interval)
|
||||||
continue
|
continue
|
||||||
timeout -= interval
|
timeout -= interval
|
||||||
time.sleep(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