Update saucelabs endpoint
Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
parent
346ff25843
commit
d68f7679df
|
@ -39,8 +39,8 @@ PyYAML==5.3.1
|
||||||
repoze.lru==0.7
|
repoze.lru==0.7
|
||||||
requests==2.25.0
|
requests==2.25.0
|
||||||
rlp==1.2.0
|
rlp==1.2.0
|
||||||
sauceclient==1.0.0
|
|
||||||
scrypt==0.8.17
|
scrypt==0.8.17
|
||||||
|
sauceclient==1.0.0
|
||||||
selenium==3.14.1
|
selenium==3.14.1
|
||||||
six==1.10.0
|
six==1.10.0
|
||||||
urllib3==1.25.9
|
urllib3==1.25.9
|
||||||
|
|
|
@ -30,7 +30,7 @@ class AbstractTestCase:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def executor_sauce_lab(self):
|
def executor_sauce_lab(self):
|
||||||
return 'http://%s:%s@ondemand.saucelabs.com:80/wd/hub' % (self.sauce_username, self.sauce_access_key)
|
return 'https://%s:%s@ondemand.eu-central-1.saucelabs.com:443/wd/hub' % (self.sauce_username, self.sauce_access_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def executor_local(self):
|
def executor_local(self):
|
||||||
|
@ -59,7 +59,6 @@ class AbstractTestCase:
|
||||||
def capabilities_sauce_lab(self):
|
def capabilities_sauce_lab(self):
|
||||||
desired_caps = dict()
|
desired_caps = dict()
|
||||||
desired_caps['app'] = 'sauce-storage:' + test_suite_data.apk_name
|
desired_caps['app'] = 'sauce-storage:' + test_suite_data.apk_name
|
||||||
|
|
||||||
desired_caps['build'] = pytest_config_global['build']
|
desired_caps['build'] = pytest_config_global['build']
|
||||||
desired_caps['name'] = test_suite_data.current_test.name
|
desired_caps['name'] = test_suite_data.current_test.name
|
||||||
desired_caps['platformName'] = 'Android'
|
desired_caps['platformName'] = 'Android'
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
from os import environ
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from sauceclient import SauceClient, SauceException
|
||||||
|
|
||||||
|
try:
|
||||||
|
import http.client as http_client
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
except ImportError:
|
||||||
|
import httplib as http_client
|
||||||
|
from urllib import urlencode
|
||||||
|
|
||||||
|
|
||||||
|
sauce_username = environ.get('SAUCE_USERNAME')
|
||||||
|
sauce_access_key = environ.get('SAUCE_ACCESS_KEY')
|
||||||
|
|
||||||
|
sauce = SauceClient(sauce_username, sauce_access_key)
|
||||||
|
apibase = 'eu-central-1.saucelabs.com'
|
||||||
|
|
||||||
|
|
||||||
|
def request(method, url, body=None, content_type='application/json'):
|
||||||
|
"""This is to monkey patch further this method in order to use apibase"""
|
||||||
|
headers = sauce.make_auth_headers(content_type)
|
||||||
|
connection = http_client.HTTPSConnection(apibase)
|
||||||
|
connection.request(method, url, body, headers=headers)
|
||||||
|
response = connection.getresponse()
|
||||||
|
data = response.read()
|
||||||
|
connection.close()
|
||||||
|
if response.status not in [200, 201]:
|
||||||
|
raise SauceException('{}: {}.\nSauce Status NOT OK'.format(
|
||||||
|
response.status, response.reason), response=response)
|
||||||
|
return json.loads(data.decode('utf-8'))
|
||||||
|
|
||||||
|
sauce.request = request
|
||||||
|
|
||||||
|
def upload_from_url(apk_path = str()):
|
||||||
|
response = requests.get(apk_path, stream=True)
|
||||||
|
response.raise_for_status()
|
||||||
|
apk_name = apk_path.split("/")[-1]
|
||||||
|
file = BytesIO(response.content)
|
||||||
|
del response
|
||||||
|
requests.post('https://eu-central-1.saucelabs.com/rest/v1/storage/'
|
||||||
|
+ sauce_username + '/' + apk_name + '?overwrite=true',
|
||||||
|
auth=(sauce_username, sauce_access_key),
|
||||||
|
data=file,
|
||||||
|
headers={'Content-Type': 'application/octet-stream'})
|
|
@ -8,19 +8,16 @@ from support.test_rerun import should_rerun_test
|
||||||
from tests import test_suite_data, appium_container
|
from tests import test_suite_data, appium_container
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from os import environ
|
from os import environ
|
||||||
from io import BytesIO
|
from sauceclient import SauceException
|
||||||
from sauceclient import SauceClient, SauceException
|
import tests.cloudbase_test_api
|
||||||
from support.api.network_api import NetworkApi
|
from support.api.network_api import NetworkApi
|
||||||
from support.github_report import GithubHtmlReport
|
from support.github_report import GithubHtmlReport
|
||||||
from support.testrail_report import TestrailReport
|
from support.testrail_report import TestrailReport
|
||||||
from tests.users import transaction_senders
|
from tests.users import transaction_senders
|
||||||
import tests
|
import tests
|
||||||
|
|
||||||
sauce_username = environ.get('SAUCE_USERNAME')
|
|
||||||
sauce_access_key = environ.get('SAUCE_ACCESS_KEY')
|
|
||||||
github_token = environ.get('GIT_HUB_TOKEN')
|
github_token = environ.get('GIT_HUB_TOKEN')
|
||||||
|
|
||||||
sauce = SauceClient(sauce_username, sauce_access_key)
|
|
||||||
github_report = GithubHtmlReport()
|
github_report = GithubHtmlReport()
|
||||||
testrail_report = TestrailReport()
|
testrail_report = TestrailReport()
|
||||||
|
|
||||||
|
@ -141,7 +138,7 @@ def is_master(config):
|
||||||
|
|
||||||
|
|
||||||
def is_uploaded():
|
def is_uploaded():
|
||||||
stored_files = sauce.storage.get_stored_files()
|
stored_files = tests.cloudbase_test_api.sauce.storage.get_stored_files()
|
||||||
for i in range(len(stored_files['files'])):
|
for i in range(len(stored_files['files'])):
|
||||||
if stored_files['files'][i]['name'] == test_suite_data.apk_name:
|
if stored_files['files'][i]['name'] == test_suite_data.apk_name:
|
||||||
return True
|
return True
|
||||||
|
@ -173,18 +170,11 @@ def pytest_configure(config):
|
||||||
description='e2e tests are running')
|
description='e2e tests are running')
|
||||||
if config.getoption('env') == 'sauce':
|
if config.getoption('env') == 'sauce':
|
||||||
if not is_uploaded():
|
if not is_uploaded():
|
||||||
if 'http' in config.getoption('apk'):
|
apk = config.getoption('apk')
|
||||||
response = requests.get(config.getoption('apk'), stream=True)
|
if 'http' in apk:
|
||||||
response.raise_for_status()
|
tests.cloudbase_test_api.upload_from_url(apk)
|
||||||
file = BytesIO(response.content)
|
|
||||||
del response
|
|
||||||
requests.post('http://saucelabs.com/rest/v1/storage/'
|
|
||||||
+ sauce_username + '/' + test_suite_data.apk_name + '?overwrite=true',
|
|
||||||
auth=(sauce_username, sauce_access_key),
|
|
||||||
data=file,
|
|
||||||
headers={'Content-Type': 'application/octet-stream'})
|
|
||||||
else:
|
else:
|
||||||
sauce.storage.upload_file(config.getoption('apk'))
|
tests.cloudbase_test_api.sauce.storage.upload_file(apk)
|
||||||
|
|
||||||
|
|
||||||
def pytest_unconfigure(config):
|
def pytest_unconfigure(config):
|
||||||
|
@ -253,7 +243,7 @@ def pytest_runtest_makereport(item, call):
|
||||||
def update_sauce_jobs(test_name, job_ids, passed):
|
def update_sauce_jobs(test_name, job_ids, passed):
|
||||||
for job_id in job_ids.keys():
|
for job_id in job_ids.keys():
|
||||||
try:
|
try:
|
||||||
sauce.jobs.update_job(job_id, name=test_name, passed=passed)
|
tests.cloudbase_test_api.sauce.jobs.update_job(job_id, name=test_name, passed=passed)
|
||||||
except (RemoteDisconnected, SauceException):
|
except (RemoteDisconnected, SauceException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue