blob: 7b78c00a383296e21a0539d3a3401bca4a39a364 [file] [log] [blame]
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Export the bot db to cloud storage."""
import collections
import json
from recipe_engine.post_process import DropExpectation
DEPS = [
def thaw_and_remove_unserializable(v):
if isinstance(v, collections.Mapping):
return {
thaw_and_remove_unserializable(k): thaw_and_remove_unserializable(v)
for k, v in v.items()}
if isinstance(v, (list, tuple, set, frozenset)):
return [thaw_and_remove_unserializable(e) for e in v]
except TypeError:
return None
return v
def RunSteps(api):
bucket =['gs_bucket']
object_path =['gs_object']
# We allow overriding the content to export from a property to allow test to
# inject values, as we don't want to have the expectations of this recipe
# change every time the bot_db changes, also because it's massive.
builders = thaw_and_remove_unserializable('builders') or
api.gsutil.upload(api.json.input(builders), bucket, object_path)
def GenTests(api):
yield api.test('with_mock_bdb') +
'mockmaster': {
'mockbuilder': {
# Something frozen.
'something': frozenset([]),
# Something not serializable.
'something_else': object()}}})
yield api.test('with_real_bdb_no_expect') +
gs_object='data.json') + api.post_process(DropExpectation)