Skip to content

Commit 82e1441

Browse files
committed
Added memcache support for test status
1 parent 7bb11e4 commit 82e1441

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

internal/process_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,15 @@ def generate_har(self):
10411041
else:
10421042
logging.debug("Not uploading HAR")
10431043

1044+
# mark successful tests as having been run in memcache
1045+
is_new_test = False
1046+
if 'memcache' in self.job:
1047+
is_new_test = self.job['memcache'].add(self.task['id'], 1)
1048+
if not is_new_test:
1049+
logging.debug("Test %s already exists in memcache", self.task['id'])
1050+
1051+
# TODO: change this to use memcache as the source of the test already having been processed
1052+
# if is_new_test and needs_upload and os.path.exists(har_file):
10441053
if uploaded:
10451054
if self.job['success'] and 'bq_datastore' in self.job:
10461055
self.upload_bigquery(har, har_filename, self.job['bq_datastore'])

wptagent.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(self, options, browsers):
4444
self.job = None
4545
self.beanstalk_job = None
4646
self.beanstalk = None
47+
self.memcache = None
4748
self.task = None
4849
self.xvfb = None
4950
self.hostname = socket.gethostname()
@@ -240,6 +241,12 @@ def get_beanstalk_job(self):
240241
import zlib
241242
if self.beanstalk is None:
242243
self.beanstalk = greenstalk.Client((self.options.beanstalk, 11300), encoding=None, watch='crawl', use='alive')
244+
if self.memcache is None:
245+
try:
246+
from pymemcache.client.base import Client
247+
self.memcache = Client(self.options.beanstalk, connect_timeout=10, timeout=10, no_delay=True)
248+
except Exception:
249+
logging.exception("Error connecting to memcache")
243250
self.beanstalk_job = self.beanstalk.reserve(30)
244251
stats = self.beanstalk.stats_job(self.beanstalk_job)
245252
if stats and 'timeouts' in stats and stats['timeouts'] >= 3:
@@ -255,6 +262,8 @@ def get_beanstalk_job(self):
255262
raw = self.beanstalk_job.body
256263
test_json = json.loads(zlib.decompress(raw).decode())
257264
self.job = self.wpt.process_job_json(test_json)
265+
if self.memcache is not None:
266+
self.job['memcache'] = self.memcache
258267
except greenstalk.TimedOutError:
259268
pass
260269
except Exception:

0 commit comments

Comments
 (0)