[experiments] Dont check expiry dates in sanity (#31212)

* [experiments] Dont check expiry dates in sanity

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/31222/head
Craig Tiller 2 years ago committed by GitHub
parent 42e45f93a8
commit 46d17e1304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      tools/codegen/core/gen_experiments.py
  2. 2
      tools/distrib/gen_experiments_and_format.sh

@ -33,6 +33,11 @@ import sys
import yaml
# TODO(ctiller): if we ever add another argument switch this to argparse
check_dates = True
if sys.argv[1:] == ["--check"]:
check_dates = False # for formatting checks we don't verify expiry dates
with open('src/core/lib/experiments/experiments.yaml') as f:
attrs = yaml.load(f.read(), Loader=yaml.FullLoader)
@ -70,21 +75,23 @@ for attr in attrs:
print("invalid default for experiment %s: %r" %
(attr['name'], attr['default']))
error = True
if 'expiry' not in attr:
print("no expiry for experiment %s" % attr['name'])
error = True
if 'owner' not in attr:
print("no owner for experiment %s" % attr['name'])
error = True
expiry = datetime.datetime.strptime(attr['expiry'], '%Y/%m/%d').date()
if expiry < today:
print("experiment %s expired on %s" % (attr['name'], attr['expiry']))
error = True
if expiry > two_quarters_from_now:
print("experiment %s expires far in the future on %s" %
(attr['name'], attr['expiry']))
print("expiry should be no more than two quarters from now")
if 'expiry' not in attr:
print("no expiry for experiment %s" % attr['name'])
error = True
expiry = datetime.datetime.strptime(attr['expiry'], '%Y/%m/%d').date()
if check_dates:
if expiry < today:
print("experiment %s expired on %s" %
(attr['name'], attr['expiry']))
error = True
if expiry > two_quarters_from_now:
print("experiment %s expires far in the future on %s" %
(attr['name'], attr['expiry']))
print("expiry should be no more than two quarters from now")
error = True
if error:
sys.exit(1)

@ -15,7 +15,7 @@
set -e
cd $(dirname $0)/../..
tools/codegen/core/gen_experiments.py
tools/codegen/core/gen_experiments.py $@
# clang format
TEST='' \
CHANGED_FILES="$(git status --porcelain | awk '{print $2}' | tr '\n' ' ')" \

Loading…
Cancel
Save