|
| 1 | +# Copyright 2019 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +"""Build attributes of every testcase.""" |
| 15 | + |
| 16 | +import datetime |
| 17 | +import sys |
| 18 | + |
| 19 | +from clusterfuzz._internal.base import tasks |
| 20 | +from clusterfuzz._internal.cron import manage_vms |
| 21 | +from clusterfuzz._internal.datastore import data_handler |
| 22 | +from clusterfuzz._internal.bot.tasks import commands |
| 23 | +from clusterfuzz._internal.bot.tasks import setup |
| 24 | +from clusterfuzz._internal.system import environment |
| 25 | +from clusterfuzz._internal.fuzzing import fuzzer_selection |
| 26 | +from clusterfuzz._internal.cron import batch_fuzzer_jobs |
| 27 | +from clusterfuzz._internal.cron import project_setup |
| 28 | +from clusterfuzz._internal.datastore import data_types |
| 29 | +from clusterfuzz._internal.datastore import data_handler |
| 30 | +from clusterfuzz._internal.datastore import ndb_utils |
| 31 | +# from local.butler.run_bot |
| 32 | + |
| 33 | +def execute(args): |
| 34 | + """Build keywords.""" |
| 35 | + three_days_ago = datetime.datetime.now() - datetime.timedelta(days=3) |
| 36 | + query = ndb_utils.get_all_from_query( |
| 37 | + data_types.Testcase.query( |
| 38 | + data_types.Testcase.timestamp >= three_days_ago)) |
| 39 | + testcases = [] |
| 40 | + for t in query: |
| 41 | + if t.archive_state != 1: |
| 42 | + print('unarchived', t.archive_state) |
| 43 | + continue |
| 44 | + if not t.fuzzed_keys: |
| 45 | + print('not fuzzed') |
| 46 | + continue |
| 47 | + t.archive_state = 0 |
| 48 | + testcases.append(t) |
| 49 | + # break |
| 50 | + print(testcases) |
| 51 | + print(len(testcases)) |
| 52 | + # ndb_utils.put_multi(testcases) |
0 commit comments