diff --git a/tests/benchmark/milvus_benchmark/update.py b/tests/benchmark/milvus_benchmark/update.py index d0a46cef0a..611a42fbc4 100644 --- a/tests/benchmark/milvus_benchmark/update.py +++ b/tests/benchmark/milvus_benchmark/update.py @@ -10,100 +10,6 @@ import requests import json -def get_token(url): - """ get the request token and return the value """ - rep = requests.get(url) - data = json.loads(rep.text) - if 'token' in data: - token = data['token'] - else: - token = '' - print("Can not get token.") - return token - - -def get_tags(url, token): - headers = {'Content-type': "application/json", - "charset": "UTF-8", - "Accept": "application/vnd.docker.distribution.manifest.v2+json", - "Authorization": "Bearer %s" % token} - try: - rep = requests.get(url, headers=headers) - data = json.loads(rep.text) - - tags = [] - if 'tags' in data: - tags = data["tags"] - else: - print("Can not get the tag list") - return tags - except: - print("Can not get the tag list") - return [] - - -def get_master_tags(tags_list): - _list = [] - tag_name = "master" - - if not isinstance(tags_list, list): - print("tags_list is not a list.") - return _list - - for tag in tags_list: - if tag_name in tag and tag != tag_name + "-latest": - _list.append(tag) - return _list - - -def get_config_digest(url, token): - headers = {'Content-type': "application/json", - "charset": "UTF-8", - "Accept": "application/vnd.docker.distribution.manifest.v2+json", - "Authorization": "Bearer %s" % token} - try: - rep = requests.get(url, headers=headers) - data = json.loads(rep.text) - - digest = '' - if 'config' in data and 'digest' in data["config"]: - digest = data["config"]["digest"] - else: - print("Can not get the digest") - return digest - except: - print("Can not get the digest") - return "" - - -def get_latest_tag(limit=200): - """ get the latest tag of master """ - - auth_url = "" - tags_url = "" - tag_url = "" - master_latest = "master-latest" - - master_latest_digest = get_config_digest(tag_url + master_latest, get_token(auth_url)) - tags = get_tags(tags_url, get_token(auth_url)) - tag_list = get_master_tags(tags) - - latest_tag = "" - for i in range(1, len(tag_list) + 1): - tag_name = str(tag_list[-i]) - tag_digest = get_config_digest(tag_url + tag_name, get_token(auth_url)) - if tag_digest == master_latest_digest: - latest_tag = tag_name - break - if i > limit: - break - - if latest_tag == "": - raise print("Can't find the latest image name") - print("The image name used is %s" % str(latest_tag)) - return latest_tag - - def get_image_tag(): url = "" headers = {"accept": "application/json"}